]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Check if the -wrap argument is actually supported by the platform's ld
authorArne Schwabe <arne@rfc2549.org>
Wed, 12 Jul 2023 09:55:29 +0000 (11:55 +0200)
committerGert Doering <gert@greenie.muc.de>
Mon, 17 Jul 2023 17:34:00 +0000 (19:34 +0200)
This avoids build errors on macOS. Also the test_tls_crypt command works
just fine on FreeBSD with its linkers, so do not make that test Linux only.

Patch v2: allow running with old cmake version (cmake 3 on RHEL7 with EPEL
          is only 3.17)
Patch v3: add OPTIONAL keyword to Incldue required by some cmake versions

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

index 2d0cd5dd001cfa8065fc7c88829e2496a577eab3..7dae6655d2e8ce639bd39943f169beb0f7ab76f6 100644 (file)
@@ -16,6 +16,7 @@ find_package(PkgConfig REQUIRED)
 include(CheckSymbolExists)
 include(CheckIncludeFiles)
 include(CheckCCompilerFlag)
+include(CheckLinkerFlag OPTIONAL)
 include(CheckTypeSize)
 include(CheckStructHasMember)
 include(CTest)
@@ -564,18 +565,24 @@ if (BUILD_TESTING)
             )
     endif ()
 
-    if (NOT MSVC)
-        # MSVC does not support --wrap
+    # MSVC and Apple's LLVM ld do not support --wrap
+    # This test requires cmake >= 3.18, so check if check_linker_flag is
+    # available
+    if (COMMAND check_linker_flag)
+        check_linker_flag(C -Wl,--wrap=parse_line LD_SUPPORTS_WRAP)
+    endif()
+
+    if (${LD_SUPPORTS_WRAP})
         list(APPEND unit_tests
             "test_argv"
+            "test_tls_crypt"
             )
     endif ()
 
-    # These tests work on only on Linux since they depend on special linker features
+    # These tests work on only on Linux since they depend on special Linux features
     if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
         list(APPEND unit_tests
             "test_networking"
-            "test_tls_crypt"
             )
     endif ()