]> The Tcpdump Group git mirrors - tcpdump/commitdiff
CMake: force -fPIC on Haiku, as we do with autotools.
authorGuy Harris <[email protected]>
Sun, 12 Feb 2023 21:31:57 +0000 (13:31 -0800)
committerGuy Harris <[email protected]>
Sun, 12 Feb 2023 21:32:39 +0000 (13:32 -0800)
This, and 64f81903ba4bbee414776b2884f8e88d3c9ae24f, address some of the
issues in #996; in particular, they fix link errors.

CMakeLists.txt

index 635c430aa1e116bfbc28e9adef47d9d7cdb8b858..63a7e5eeee4e7511236ae660d45151a0b97b5e83 100644 (file)
@@ -278,6 +278,23 @@ if(MSVC)
     add_definitions(-D_CRT_SECURE_NO_WARNINGS)
 endif(MSVC)
 
+if(CMAKE_SYSTEM_NAME STREQUAL "Haiku")
+    #
+    # On Haiku, all executables are built as shared objects,
+    # and must have their code build as PIC.
+    #
+    # At least some versions of Haiku's GCC default to PIC,
+    # with a -fno-pic option for cases where that's not desired.
+    #
+    # Clang hasn't been modified in that fashion, so Clang
+    # builds of tcpdump fail.
+    #
+    # Force the use of -fPIC (even for GCC; adding -fPIC for GCC
+    # won't break anything).
+    #
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
+endif(CMAKE_SYSTEM_NAME STREQUAL "Haiku")
+
 if(MSVC)
     if (USE_STATIC_RT)
         MESSAGE(STATUS "Use STATIC runtime")