Add line breakpoint calibration test
[hiphop-php.git] / CMake / FollySetup.cmake
blob476f7dcb3ad010b7a3644773510dd67e6d7d7bad
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\")));
10 " FOLLY_IFUNC)
11 if (FOLLY_IFUNC)
12   add_definitions("-DHAVE_IFUNC=1")
13 endif()
15 if (LINUX OR FREEBSD)
16   set(CMAKE_REQUIRED_LIBRARIES rt ${LIBPTHREAD_LIBRARIES})
17 else()
18   set(CMAKE_REQUIRED_LIBRARIES ${LIBPTHREAD_LIBRARIES})
19 endif()
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")
28 endif()
29 if (HAVE_PTHREAD_ATFORK)
30   add_definitions("-DFOLLY_HAVE_PTHREAD_ATFORK=1")
31 endif()
32 if (HAVE_PTHREAD_SPINLOCK)
33   add_definitions("-DFOLLY_HAVE_PTHREAD_SPINLOCK_T=1")
34 endif()
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")
41 endif()
43 if(CYGWIN)
44 # cygwin has c99 issues with cxx compiler and headers
45   add_definitions("-D_GLIBCXX_USE_C99_DYNAMIC")
46 endif()
48 if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
49   if(NOT CLANG_FORCE_LIBSTDCXX)
50     add_definitions("-DFOLLY_USE_LIBCPP=1")
51   endif()
52 endif()
54 CHECK_CXX_SOURCE_COMPILES("
55 int main(int argc, char** argv) {
56   unsigned size = argc;
57   char data[size];
58   return 0;
60 " FOLLY_HAVE_VLA)
61 if (FOLLY_HAVE_VLA)
62   add_definitions("-DFOLLY_HAVE_VLA=1")
63 elseif()
64   add_definitions("-DFOLLY_HAVE_VLA=0")
65 endif()