]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
CMake: Make sure to treat UNIT_TEST_SOURCEDIR as path
authorFrank Lichtenheld <frank@lichtenheld.com>
Wed, 7 May 2025 12:12:20 +0000 (14:12 +0200)
committerGert Doering <gert@greenie.muc.de>
Wed, 7 May 2025 12:20:13 +0000 (14:20 +0200)
This makes sure that it is properly normalized, and
on Windows seems to prevent CMake from using back
slashes which would break the build due to "unknown escape
sequence" errors.

Change-Id: I2551edfaaf5107649398a3fa1db2009ee8644671
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Message-Id: <20250507121226.13824-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31587.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
CMakeLists.txt

index a8fb64b6468f6d605b6e77dbc0764a08846a3eef..6687b56f124bcfeecd9ee749b98d6bbd469667df 100644 (file)
@@ -679,11 +679,11 @@ if (BUILD_TESTING)
     endif ()
 
     foreach (test_name ${unit_tests})
+        cmake_path(SET _UT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tests/unit_tests/openvpn)
         # test_networking needs special environment
         if (NOT ${test_name} STREQUAL "test_networking")
             add_test(${test_name} ${test_name})
             # for compat with autotools make check
-            set(_UT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tests/unit_tests/openvpn)
             set_tests_properties(${test_name} PROPERTIES
                 ENVIRONMENT "srcdir=${_UT_SOURCE_DIR}")
         endif ()
@@ -703,7 +703,7 @@ if (BUILD_TESTING)
 
         # for compat with IDEs like Clion that ignore the tests properties
         # for the environment variable srcdir when running tests as fallback
-        target_compile_definitions(${test_name} PRIVATE "-DUNIT_TEST_SOURCEDIR=\"${CMAKE_SOURCE_DIR}/tests/unit_tests/openvpn\"")
+        target_compile_definitions(${test_name} PRIVATE "UNIT_TEST_SOURCEDIR=\"${_UT_SOURCE_DIR}\"")
 
         if (NOT ${test_name} STREQUAL "test_buffer")
             target_sources(${test_name} PRIVATE