include(CheckCXXSourceCompiles) include(CheckCXXSourceRuns) include(CheckCXXSymbolExists) include(CheckFunctionExists) include(CheckIncludeFiles) include(CheckStructHasMember) include(CheckTypeSize) include(CheckLibraryExists) if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD) set(CMAKE_REQUIRED_INCLUDES /usr/local/include) elseif(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin) set(CMAKE_REQUIRED_DEFINITIONS "-D_BSD_SOURCE -D_SVID_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L") endif() list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_FILE_OFFSET_BITS=64) check_include_files(sys/vmparam.h HAVE_SYS_VMPARAM_H) check_include_files(mach/vm_types.h HAVE_MACH_VM_TYPES_H) check_include_files(mach/vm_param.h HAVE_MACH_VM_PARAM_H) check_library_exists(pthread pthread_attr_get_np "" HAVE_PTHREAD_ATTR_GET_NP) check_library_exists(pthread pthread_getattr_np "" HAVE_PTHREAD_GETATTR_NP) check_library_exists(pthread pthread_condattr_setclock "" HAVE_PTHREAD_CONDATTR_SETCLOCK) check_library_exists(pthread pthread_getthreadid_np "" HAVE_PTHREAD_GETTHREADID_NP) check_function_exists(clock_nanosleep HAVE_CLOCK_NANOSLEEP) check_function_exists(sysctl HAVE_SYSCTL) check_function_exists(sysconf HAVE_SYSCONF) check_struct_has_member ("ucontext_t" uc_mcontext.gregs[0] ucontext.h HAVE_GREGSET_T) check_struct_has_member ("ucontext_t" uc_mcontext.__gregs[0] ucontext.h HAVE___GREGSET_T) set(CMAKE_EXTRA_INCLUDE_FILES) set(CMAKE_EXTRA_INCLUDE_FILES signal.h) check_type_size(siginfo_t SIGINFO_T) set(CMAKE_EXTRA_INCLUDE_FILES) set(CMAKE_EXTRA_INCLUDE_FILES ucontext.h) check_type_size(ucontext_t UCONTEXT_T) check_cxx_symbol_exists(_SC_PHYS_PAGES unistd.h HAVE__SC_PHYS_PAGES) check_cxx_symbol_exists(_SC_AVPHYS_PAGES unistd.h HAVE__SC_AVPHYS_PAGES) check_cxx_source_compiles(" #include int main(int argc, char **argv) { return (int)_lwp_self(); }" HAVE_LWP_SELF) set(CMAKE_REQUIRED_LIBRARIES pthread) check_cxx_source_runs(" #include #include int main(void) { if (sched_getcpu() >= 0) { exit(0); } exit(1); }" HAVE_SCHED_GETCPU) set(CMAKE_REQUIRED_LIBRARIES) check_cxx_source_runs(" #include #include #include int main() { int ret; struct timespec ts; ret = clock_gettime(CLOCK_MONOTONIC, &ts); exit(ret); }" HAVE_CLOCK_MONOTONIC) check_cxx_source_runs(" #include #include #include int main() { int ret; struct timespec ts; ret = clock_gettime(CLOCK_MONOTONIC_COARSE, &ts); exit(ret); }" HAVE_CLOCK_MONOTONIC_COARSE) check_cxx_source_runs(" #include #include int main() { int ret; mach_timebase_info_data_t timebaseInfo; ret = mach_timebase_info(&timebaseInfo); mach_absolute_time(); exit(ret); }" HAVE_MACH_ABSOLUTE_TIME) check_cxx_source_compiles(" thread_local int x; int main(int argc, char **argv) { x = 1; return 0; }" HAVE_THREAD_LOCAL) configure_file(${CMAKE_CURRENT_LIST_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)