1 include(CheckCXXSourceCompiles)
2 include(CheckCXXSourceRuns)
3 include(CheckFunctionExists)
4 include(CheckIncludeFile)
5 include(CheckSymbolExists)
7 CHECK_INCLUDE_FILE_CXX(malloc.h FOLLY_HAVE_MALLOC_H)
8 CHECK_INCLUDE_FILE_CXX(bits/functexcept.h FOLLY_HAVE_BITS_FUNCTEXCEPT_H)
10 if (FOLLY_HAVE_PTHREAD)
11 set(CMAKE_REQUIRED_LIBRARIES
12 "${CMAKE_REQUIRED_LIBRARIES} ${LIBPTHREAD_LIBRARIES}")
13 set(CMAKE_REQUIRED_INCLUDES
14 "${CMAKE_REQUIRED_INCLUDES} ${LIBPTHREAD_INCLUDE_DIRS}")
16 check_symbol_exists(pthread_atfork pthread.h FOLLY_HAVE_PTHREAD_ATFORK)
18 # Unfortunately check_symbol_exists() does not work for memrchr():
19 # it fails complaining that there are multiple overloaded versions of memrchr()
20 check_function_exists(memrchr FOLLY_HAVE_MEMRCHR)
21 check_symbol_exists(preadv sys/uio.h FOLLY_HAVE_PREADV)
22 check_symbol_exists(pwritev sys/uio.h FOLLY_HAVE_PWRITEV)
23 check_symbol_exists(clock_gettime time.h FOLLY_HAVE_CLOCK_GETTIME)
25 check_cxx_source_compiles("
26 #pragma GCC diagnostic error \"-Wattributes\"
27 extern \"C\" void (*test_ifunc(void))() { return 0; }
28 void func() __attribute__((ifunc(\"test_ifunc\")));
29 int main() { return 0; }"
32 check_cxx_source_compiles("
33 #include <type_traits>
34 const bool val = std::is_trivially_copyable<bool>::value;
35 int main() { return 0; }"
36 FOLLY_HAVE_STD__IS_TRIVIALLY_COPYABLE
38 check_cxx_source_runs("
39 int main(int, char**) {
41 unsigned long *ptr = (unsigned long *)(buf + 1);
43 return (*ptr & 0xff) == 0xef ? 0 : 1;
45 FOLLY_HAVE_UNALIGNED_ACCESS
47 check_cxx_source_compiles("
48 int main(int argc, char** argv) {
55 check_cxx_source_compiles("
56 extern \"C\" void configure_link_extern_weak_test() __attribute__((weak));
57 int main(int argc, char** argv) {
58 return configure_link_extern_weak_test == nullptr;
60 FOLLY_HAVE_WEAK_SYMBOLS