fix(conan): openvpn support in MSVC+Ninja setup (#2616)

This commit is contained in:
Yaroslav Gurov
2026-05-21 12:09:52 +02:00
committed by GitHub
parent 8749d683e3
commit d3de5f0f48
4 changed files with 82 additions and 1 deletions
+4
View File
@@ -0,0 +1,4 @@
patches:
"2.7.0":
- patch_file: "patches/0001-carefully-handle-CMAKE_GENERATOR_PLATFORM.patch"
- patch_file: "patches/0002-explicitly-pass-unicode-everywhere.patch"
+3 -1
View File
@@ -1,5 +1,5 @@
from conan import ConanFile
from conan.tools.files import get, copy, replace_in_file
from conan.tools.files import get, copy, replace_in_file, apply_conandata_patches, export_conandata_patches
from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps, PkgConfigDeps
from conan.tools.layout import basic_layout
from conan.tools.cmake import cmake_layout, CMakeToolchain, CMake, CMakeDeps
@@ -17,6 +17,7 @@ class Openvpn(ConanFile):
return str(self.settings.os).startswith("Windows")
def export_sources(self):
export_conandata_patches(self)
copy(self, "*applink.c", src=self.recipe_folder, dst=self.export_sources_folder)
def layout(self):
@@ -84,6 +85,7 @@ class Openvpn(ConanFile):
deps.generate()
def build(self):
apply_conandata_patches(self)
if self._is_windows:
cmake = CMake(self)
cmake.configure()
@@ -0,0 +1,25 @@
From 693bee38daaec5962ea3f0939c71e869f202c08a Mon Sep 17 00:00:00 2001
From: Yaroslav Gurov <ygurov@proton.me>
Date: Mon, 18 May 2026 16:58:00 +0200
Subject: [PATCH] carefully handle CMAKE_GENERATOR_PLATFORM
---
CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 198c98ff..7341db70 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -108,7 +108,7 @@ if (MSVC)
"$<$<CONFIG:Release>:/OPT:REF>"
"$<$<CONFIG:Release>:/OPT:ICF>"
)
- if (${CMAKE_GENERATOR_PLATFORM} STREQUAL "x64" OR ${CMAKE_GENERATOR_PLATFORM} STREQUAL "x86")
+ if ("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "x64" OR "${CMAKE_GENERATOR_PLATFORM}" STREQUAL "x86")
add_link_options("$<$<CONFIG:Release>:/CETCOMPAT>")
endif()
else ()
--
2.46.0.windows.1
@@ -0,0 +1,50 @@
From 9a42a0350abaa1a329ad56e40b1900ef78183323 Mon Sep 17 00:00:00 2001
From: Yaroslav Gurov <ygurov@proton.me>
Date: Mon, 18 May 2026 18:05:09 +0200
Subject: [PATCH] explicitly pass unicode everywhere
---
src/openvpnmsica/CMakeLists.txt | 1 +
src/openvpnserv/CMakeLists.txt | 1 +
src/tapctl/CMakeLists.txt | 1 +
3 files changed, 3 insertions(+)
diff --git a/src/openvpnmsica/CMakeLists.txt b/src/openvpnmsica/CMakeLists.txt
index 9126b80f..23f979d6 100644
--- a/src/openvpnmsica/CMakeLists.txt
+++ b/src/openvpnmsica/CMakeLists.txt
@@ -22,6 +22,7 @@ target_sources(openvpnmsica PRIVATE
openvpnmsica_resources.rc
)
target_compile_options(openvpnmsica PRIVATE
+ -DUNICODE
-D_UNICODE
-UNTDDI_VERSION
-D_WIN32_WINNT=_WIN32_WINNT_VISTA
diff --git a/src/openvpnserv/CMakeLists.txt b/src/openvpnserv/CMakeLists.txt
index fc153822..b3a0cff1 100644
--- a/src/openvpnserv/CMakeLists.txt
+++ b/src/openvpnserv/CMakeLists.txt
@@ -19,6 +19,7 @@ function(add_common_options target)
${MC_GEN_DIR}
)
target_compile_options(${target} PRIVATE
+ -DUNICODE
-D_UNICODE
-UNTDDI_VERSION
-D_WIN32_WINNT=_WIN32_WINNT_VISTA
diff --git a/src/tapctl/CMakeLists.txt b/src/tapctl/CMakeLists.txt
index 97702c01..81da46b8 100644
--- a/src/tapctl/CMakeLists.txt
+++ b/src/tapctl/CMakeLists.txt
@@ -19,6 +19,7 @@ target_sources(tapctl PRIVATE
tapctl_resources.rc
)
target_compile_options(tapctl PRIVATE
+ -DUNICODE
-D_UNICODE
-UNTDDI_VERSION
-D_WIN32_WINNT=_WIN32_WINNT_VISTA
--
2.46.0.windows.1