1 # folly-config.h is a generated file from autotools
2 # We need to do the equivalent checks here and use
3 # add_definitions as needed
4 add_definitions(-DFOLLY_NO_CONFIG=1)
6 INCLUDE(CheckCXXSourceCompiles)
7 CHECK_CXX_SOURCE_COMPILES("
8 extern \"C\" void (*test_ifunc(void))() { return 0; }
9 void func() __attribute__((ifunc(\"test_ifunc\")));
12 add_definitions("-DHAVE_IFUNC=1")
16 set(CMAKE_REQUIRED_LIBRARIES rt ${LIBPTHREAD_LIBRARIES})
18 set(CMAKE_REQUIRED_LIBRARIES ${LIBPTHREAD_LIBRARIES})
21 include(CheckFunctionExists)
22 CHECK_FUNCTION_EXISTS("clock_gettime" HAVE_CLOCK_GETTIME)
23 CHECK_FUNCTION_EXISTS("pthread_atfork" HAVE_PTHREAD_ATFORK)
24 CHECK_FUNCTION_EXISTS("pthread_spin_lock" HAVE_PTHREAD_SPINLOCK)
26 if (HAVE_CLOCK_GETTIME)
27 add_definitions("-DFOLLY_HAVE_CLOCK_GETTIME=1")
29 if (HAVE_PTHREAD_ATFORK)
30 add_definitions("-DFOLLY_HAVE_PTHREAD_ATFORK=1")
32 if (HAVE_PTHREAD_SPINLOCK)
33 add_definitions("-DFOLLY_HAVE_PTHREAD_SPINLOCK_T=1")
35 set(CMAKE_REQUIRED_LIBRARIES)
37 find_path(FEATURES_H_INCLUDE_DIR NAMES features.h)
38 if (FEATURES_H_INCLUDE_DIR)
39 include_directories("${FEATURES_H_INCLUDE_DIR}")
40 add_definitions("-DFOLLY_HAVE_FEATURES_H=1")
44 # cygwin has c99 issues with cxx compiler and headers
45 add_definitions("-D_GLIBCXX_USE_C99_DYNAMIC")
48 if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
49 if(NOT CLANG_FORCE_LIBSTDCXX)
50 add_definitions("-DFOLLY_USE_LIBCPP=1")
54 CHECK_CXX_SOURCE_COMPILES("
55 int main(int argc, char** argv) {
62 add_definitions("-DFOLLY_HAVE_VLA=1")
64 add_definitions("-DFOLLY_HAVE_VLA=0")