[Openvpn-devel,S] Change in openvpn[master]: Use mingw compile definition also to unit tests

Message ID cf217b90dcef2dfad3e8d0d6646b10933606199c-HTML@gerrit.openvpn.net
State Superseded
Headers show
Series [Openvpn-devel,S] Change in openvpn[master]: Use mingw compile definition also to unit tests | expand

Commit Message

its_Giaan (Code Review) Dec. 7, 2023, 5:49 p.m. UTC
Attention is currently required from: flichtenheld.

Hello flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/469?usp=email

to review the following change.


Change subject: Use mingw compile definition also to unit tests
......................................................................

Use mingw compile definition also to unit tests

Currently we only apply the defines for windows APIs and Unicode to
OpenVPN itself. We should rather treat the unit tests the same as
our main binary to reduce potential differences.

Change-Id: Ie5aa643ab6190262f7c8b9e614bedb398e85859b
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
---
M CMakeLists.txt
1 file changed, 14 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/69/469/1

Patch

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 577bc5d..8c24cca 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -259,6 +259,15 @@ 
 
     endif ()
 
+    if (MINGW)
+        target_compile_options(${target} PRIVATE
+                -DWIN32_LEAN_AND_MEAN
+                -DNTDDI_VERSION=NTDDI_VISTA -D_WIN32_WINNT=_WIN32_WINNT_VISTA
+        )
+        target_compile_options(${target} PRIVATE -municode -UUNICODE)
+        target_link_options(${target} PRIVATE -municode)
+    endif()
+
     # optional dependencies
     target_link_libraries(${target} PUBLIC
         $<TARGET_NAME_IF_EXISTS:PkgConfig::liblz4>
@@ -514,14 +523,6 @@ 
 
 add_library_deps(openvpn)
 
-if (MINGW)
-    target_compile_options(openvpn PRIVATE
-        -DWIN32_LEAN_AND_MEAN
-        -DNTDDI_VERSION=NTDDI_VISTA -D_WIN32_WINNT=_WIN32_WINNT_VISTA
-        )
-    target_compile_options(openvpn PRIVATE -municode -UUNICODE)
-    target_link_options(openvpn PRIVATE -municode)
-endif()
 
 if (MSVC)
     # we have our own manifest
@@ -634,6 +635,11 @@ 
 
         target_include_directories(${test_name} PRIVATE src/openvpn)
 
+        if (MINGW)
+            # when compiling with -municode, mingw looks for wmain instead of main
+            target_compile_definitions(${test_name} PRIVATE -Dmain=wmain)
+        endif ()
+
         if (NOT ${test_name} STREQUAL "test_buffer")
             target_sources(${test_name} PRIVATE
                 src/openvpn/buffer.c