From fe344be938fb5d4644553a6886f6455fa337ce72 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 11 Aug 2013 19:21:03 +0200 Subject: Only link with librt when necessary --- CMakeLists.txt | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 0fa9d72..9a98adb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,10 +28,11 @@ endif() include(CheckCSourceCompiles) include(CheckPrototypeDefinition) +include(CheckSymbolExists) include(CheckTypeSize) -set(CMAKE_EXTRA_INCLUDE_FILES "netinet/if_ether.h") set(CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE") + check_c_source_compiles(" #include #include @@ -42,11 +43,29 @@ int main() { } " HAVE_AI_ADDRCONFIG) + check_prototype_definition("get_current_dir_name" "char *get_current_dir_name(void)" "NULL" "unistd.h" HAVE_GET_CURRENT_DIR_NAME) + +set(RT_LIBRARY "") +check_symbol_exists("clock_gettime" "time.h" HAVE_CLOCK_GETTIME) + +if(NOT HAVE_CLOCK_GETTIME) + set(RT_LIBRARY "rt") + list(append CMAKE_REQUIRED_LIBRARIES "rt") + + check_symbol_exists("clock_gettime" "time.h" HAVE_CLOCK_GETTIME) + if(NOT HAVE_CLOCK_GETTIME) + message(FATAL_ERROR "clock_gettime() not found") + endif(NOT HAVE_CLOCK_GETTIME) +endif(NOT HAVE_CLOCK_GETTIME) + + +set(CMAKE_EXTRA_INCLUDE_FILES "netinet/if_ether.h") check_type_size("struct ethhdr" SIZEOF_ETHHDR) string(COMPARE NOTEQUAL "${SIZEOF_ETHHDR}" "" HAVE_ETHHDR) + set(USE_BINDTODEVICE ${LINUX}) set(USE_PMTU ${LINUX}) set(USE_PKTINFO ${LINUX}) -- cgit v1.2.3