[Openvpn-devel,3/4] Check if the -wrap argument is actually supported by the platform's ld

Message ID 20230629215611.3292788-5-arne@rfc2549.org
State Superseded
Headers show
Series Restore ability to compile on macOS/FreeBSD with Cmake | expand

Commit Message

Arne Schwabe June 29, 2023, 9:56 p.m. UTC
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.

Change-Id: Id26676bdc576c7d3d6726afa43fe6c7a397c579b
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
---
 CMakeLists.txt | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Comments

Frank Lichtenheld June 30, 2023, 8:48 a.m. UTC | #1
On Thu, Jun 29, 2023 at 11:56:10PM +0200, Arne Schwabe wrote:
> 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.

NAK. Breaks build on mingw. Will investigate why.

Regards,

Patch

diff --git a/CMakeLists.txt b/CMakeLists.txt
index acebbb73c..d2445b414 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -16,6 +16,7 @@  find_package(PkgConfig REQUIRED)
 include(CheckSymbolExists)
 include(CheckIncludeFiles)
 include(CheckCCompilerFlag)
+include(CheckLinkerFlag)
 include(CheckTypeSize)
 include(CheckStructHasMember)
 include(CTest)
@@ -560,18 +561,20 @@  if (BUILD_TESTING)
             )
     endif ()
 
-    if (NOT MSVC)
-        # MSVC does not support --wrap
+    # MSVC and Apple's LLVM ld do not support --wrap
+    check_linker_flag(C -Wl,--wrap=parse_line LD_SUPPORTS_WRAP)
+
+    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 ()