diff --git a/CMakeLists.txt b/CMakeLists.txt index f0099cc90..5974b5c92 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,44 +63,33 @@ endif() # # Look for C library functions # -set(CMAKE_EXTRA_INCLUDE_FILES string.h) -check_function_exists(rawmemchr HAS_RAWMEMCHR) -set(HAS_RAWMEMCHR ${HAS_RAWMEMCHR}) -set(CMAKE_EXTRA_INCLUDE_FILES stdlib.h) -check_function_exists(reallocarray HAS_REALLOCARRAY) -set(HAS_REALLOCARRAY ${HAS_REALLOCARRAY}) +set(CMAKE_EXTRA_INCLUDE_FILES + fcntl.h + stdlib.h + sys/socket.h + sys/types.h + string.h + time.h + unistd.h +) +set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) +check_function_exists(rawmemchr HAS_RAWMEMCHR) +check_function_exists(reallocarray HAS_REALLOCARRAY) check_function_exists(mempcpy HAS_MEMPCPY) -set(HAS_MEMPCPY ${HAS_MEMPCPY}) - check_function_exists(memrchr HAS_MEMRCHR) -set(HAS_MEMRCHR ${HAS_MEMRCHR}) - -set(CMAKE_EXTRA_INCLUDE_FILES unistd.h) check_function_exists(pipe2 HAS_PIPE2) -set(HAS_PIPE2 ${HAS_PIPE2}) - -set(CMAKE_EXTRA_INCLUDE_FILES sys/types.h sys/socket.h) check_function_exists(accept4 HAS_ACCEPT4) -set(HAS_ACCEPT4 ${HAS_ACCEPT4}) - -set(CMAKE_EXTRA_INCLUDE_FILES fcntl.h) check_function_exists(readahead HAS_READAHEAD) -set(HAS_READAHEAD ${HAS_READAHEAD}) - check_function_exists(mkostemp HAS_MKOSTEMP) -set(HAS_MKOSTEMP ${HAS_MKOSTEMP}) - -set(CMAKE_EXTRA_INCLUDE_FILES time.h) check_function_exists(clock_gettime HAS_CLOCK_GETTIME) +check_function_exists(pthread_barrier_init HAS_PTHREADBARRIER) + if (NOT HAS_CLOCK_GETTIME AND ${CMAKE_SYSTEM_NAME} MATCHES "Linux") list(APPEND ADDITIONAL_LIBRARIES rt) endif () -set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) -check_function_exists(pthread_barrier_init HAS_PTHREADBARRIER) - # # Ensure compiler is compatible with GNU99 standard