summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2018-10-24 19:51:10 -0700
committerGuy Harris <guy@alum.mit.edu>2018-10-24 19:51:10 -0700
commit703c9c2120effe49546097f4e5866251378f320c (patch)
treef8586619b1312cde75734bf6e9258e22498ac461
parent392914eaf691f7cb0a80d59bffe090cffbab8b93 (diff)
downloadlibpcap-703c9c2120effe49546097f4e5866251378f320c.tar.gz
Attempt to deal with OSes that require you to link with -lpthread.
Leave CMAKE_EXE_LINKER_FLAGS and CMAKE_SHARED_LINKER_FLAGS alone; instead, just add SANITIZER_FLAGS as the LINK_FLAGS property to shared library and executable targets.
-rw-r--r--CMakeLists.txt9
-rw-r--r--rpcapd/CMakeLists.txt5
-rw-r--r--testprogs/CMakeLists.txt4
-rw-r--r--testprogs/fuzz/CMakeLists.txt12
4 files changed, 26 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 82d4c3a5..ad3fbf0c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -293,8 +293,7 @@ endif(USE_STATIC_RT)
#
# Test if the each of the sanitizers in the ENABLE_SANITIZERS list are
# supported by the compiler, and, if so, adds the appropriate flags to
-# CMAKE_C_FLAGS, CMAKE_CXX_FLAGS, CMAKE_EXE_LINKER_FLAGS, and
-# CMAKE_SHARED_LINKER_FLAGS. If not, it fails.
+# CMAKE_C_FLAGS, CMAKE_CXX_FLAGS, and SANITIZER_FLAGS. If not, it fails.
#
set(SANITIZER_FLAGS "")
foreach(sanitizer IN LISTS ENABLE_SANITIZERS)
@@ -344,8 +343,6 @@ endforeach()
if(NOT "${SANITIZER_FLAGS}" STREQUAL "")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O1 -g ${SANITIZER_FLAGS} -fno-omit-frame-pointer -fno-optimize-sibling-calls")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1 -g ${SANITIZER_FLAGS} -fno-omit-frame-pointer -fno-optimize-sibling-calls")
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${SANITIZER_FLAGS}")
- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${SANITIZER_FLAGS}")
endif()
###################################################################
@@ -1975,6 +1972,10 @@ if(BUILD_SHARED_LIBS)
add_dependencies(${LIBRARY_NAME} SerializeTarget)
set_target_properties(${LIBRARY_NAME} PROPERTIES
COMPILE_DEFINITIONS BUILDING_PCAP)
+ if(NOT "${SANITIZER_FLAGS}" STREQUAL "")
+ set_target_properties(${LIBRARY_NAME} PROPERTIES
+ LINK_FLAGS "${SANITIZER_FLAGS}")
+ endif()
endif(BUILD_SHARED_LIBS)
add_library(${LIBRARY_NAME}_static STATIC
diff --git a/rpcapd/CMakeLists.txt b/rpcapd/CMakeLists.txt
index a42eda79..0b59d140 100644
--- a/rpcapd/CMakeLists.txt
+++ b/rpcapd/CMakeLists.txt
@@ -71,6 +71,11 @@ if(WIN32 OR ((CMAKE_USE_PTHREADS_INIT OR PTHREADS_FOUND) AND HAVE_CRYPT))
set_target_properties(rpcapd PROPERTIES COMPILE_FLAGS ${C_ADDITIONAL_FLAGS})
endif()
+ if(NOT "${SANITIZER_FLAGS}" STREQUAL "")
+ set_target_properties(rpcapd PROPERTIES
+ LINK_FLAGS "${SANITIZER_FLAGS}")
+ endif()
+
#
# By default, build rpcapd universal with the appropriate set of
# architectures for the OS on which we're doing the build.
diff --git a/testprogs/CMakeLists.txt b/testprogs/CMakeLists.txt
index 3d77c06d..b9863eec 100644
--- a/testprogs/CMakeLists.txt
+++ b/testprogs/CMakeLists.txt
@@ -19,6 +19,10 @@ macro(add_test_executable _executable)
target_link_libraries(${_executable}
${ARGN} ${LIBRARY_NAME}_static ${PCAP_LINK_LIBRARIES})
endif(WIN32)
+ if(NOT "${SANITIZER_FLAGS}" STREQUAL "")
+ set_target_properties(${_executable} PROPERTIES
+ LINK_FLAGS "${SANITIZER_FLAGS}")
+ endif()
add_dependencies(testprogs ${_executable})
endmacro()
diff --git a/testprogs/fuzz/CMakeLists.txt b/testprogs/fuzz/CMakeLists.txt
index 3376a98c..4a2862f9 100644
--- a/testprogs/fuzz/CMakeLists.txt
+++ b/testprogs/fuzz/CMakeLists.txt
@@ -1,8 +1,20 @@
add_executable(fuzz_pcap onefile.c fuzz_pcap.c)
target_link_libraries(fuzz_pcap ${ARGN} ${LIBRARY_NAME}_static ${PCAP_LINK_LIBRARIES})
+if(NOT "${SANITIZER_FLAGS}" STREQUAL "")
+ set_target_properties(fuzz_pcap PROPERTIES
+ LINK_FLAGS "${SANITIZER_FLAGS}")
+endif()
add_executable(fuzz_filter onefile.c fuzz_filter.c)
target_link_libraries(fuzz_filter ${ARGN} ${LIBRARY_NAME}_static ${PCAP_LINK_LIBRARIES})
+if(NOT "${SANITIZER_FLAGS}" STREQUAL "")
+ set_target_properties(fuzz_filter PROPERTIES
+ LINK_FLAGS "${SANITIZER_FLAGS}")
+endif()
add_executable(fuzz_both onefile.c fuzz_both.c)
target_link_libraries(fuzz_both ${ARGN} ${LIBRARY_NAME}_static ${PCAP_LINK_LIBRARIES})
+if(NOT "${SANITIZER_FLAGS}" STREQUAL "")
+ set_target_properties(fuzz_both PROPERTIES
+ LINK_FLAGS "${SANITIZER_FLAGS}")
+endif()