cmake: Add missing checks for cvc4autoconfig.h to ConfigureCVC4.cmake.
[cvc5.git] / cmake / ConfigureCVC4.cmake
1 include(CheckCXXSourceCompiles)
2 include(CheckIncludeFile)
3 include(CheckIncludeFileCXX)
4 include(CheckSymbolExists)
5
6 # Check whether "long" and "int64_t" are distinct types w.r.t. overloading.
7 # Even if they have the same size, they can be distinct, and some platforms
8 # can have problems with ambiguous function calls when auto-converting
9 # int64_t to long, and others will complain if you overload a function
10 # that takes an int64_t with one that takes a long (giving a redefinition
11 # error). So we have to keep both happy. Probably the same underlying
12 # issue as the hash specialization below, but let's check separately
13 # for flexibility.
14
15 check_cxx_source_compiles(
16 "#include <stdint.h>
17 void foo(long) {}
18 void foo(int64_t) {}
19 int main() { return 0; }"
20 CVC4_NEED_INT64_T_OVERLOADS
21 )
22 if(NOT CVC4_NEED_INT64_T_OVERLOADS)
23 set(CVC4_NEED_INT64_T_OVERLOADS 0)
24 endif()
25
26 # Check to see if this version/architecture of GNU C++ explicitly
27 # instantiates std::hash<uint64_t> or not. Some do, some don't.
28 # See src/util/hash.h.
29
30 check_cxx_source_compiles(
31 "#include <cstdint>
32 #include <functional>
33 namespace std { template<> struct hash<uint64_t> {}; }
34 int main() { return 0; }"
35 CVC4_NEED_HASH_UINT64_T_OVERLOAD
36 )
37 if(CVC4_NEED_HASH_UINT64_T_OVERLOAD)
38 add_definitions(-DCVC4_NEED_HASH_UINT64_T)
39 endif()
40
41 check_include_file(unistd.h HAVE_UNISTD_H)
42 check_include_file_cxx(ext/stdio_filebuf.h HAVE_EXT_STDIO_FILEBUF_H)
43
44 check_symbol_exists(clock_gettime "time.h" HAVE_CLOCK_GETTIME)
45 check_symbol_exists(ffs "strings.h" HAVE_FFS)
46 check_symbol_exists(optreset "getopt.h" HAVE_DECL_OPTRESET)
47 check_symbol_exists(sigaltstack "signal.h" HAVE_SIGALTSTACK)
48 check_symbol_exists(strerror_r "string.h" HAVE_STRERROR_R)
49 check_symbol_exists(strtok_r "string.h" HAVE_STRTOK_R)
50
51 # Determine if we have the POSIX (int) or GNU (char *) variant of strerror_r.
52 check_c_source_compiles(
53 "
54 #include <string.h>
55 int main(void)
56 {
57 char buf[1];
58 char c = *strerror_r(0, buf, 0);
59 return 0;
60 }
61 "
62 STRERROR_R_CHAR_P
63 )