Add cardinality class definition (#6302)
[cvc5.git] / cmake / ConfigureCVC4.cmake
1 #####################
2 ## ConfigureCVC4.cmake
3 ## Top contributors (to current version):
4 ## Mathias Preiner, Gereon Kremer, Makai Mann
5 ## This file is part of the CVC4 project.
6 ## Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
7 ## in the top-level source directory and their institutional affiliations.
8 ## All rights reserved. See the file COPYING in the top-level source
9 ## directory for licensing information.
10 ##
11 include(CheckCXXSourceCompiles)
12 include(CheckIncludeFile)
13 include(CheckIncludeFileCXX)
14 include(CheckSymbolExists)
15 include(CheckLibraryExists)
16
17 # Check whether "long" and "int64_t" are distinct types w.r.t. overloading.
18 # Even if they have the same size, they can be distinct, and some platforms
19 # can have problems with ambiguous function calls when auto-converting
20 # int64_t to long, and others will complain if you overload a function
21 # that takes an int64_t with one that takes a long (giving a redefinition
22 # error). So we have to keep both happy. Probably the same underlying
23 # issue as the hash specialization below, but let's check separately
24 # for flexibility.
25 check_cxx_source_compiles(
26 "
27 #include <stdint.h>
28 void foo(long) {}
29 void foo(int64_t) {}
30 int main() { return 0; }
31 "
32 CVC4_NEED_INT64_T_OVERLOADS
33 )
34 if(NOT CVC4_NEED_INT64_T_OVERLOADS)
35 set(CVC4_NEED_INT64_T_OVERLOADS 0)
36 endif()
37
38 # Check to see if this version/architecture of GNU C++ explicitly
39 # instantiates std::hash<uint64_t> or not. Some do, some don't.
40 # See src/util/hash.h.
41 check_cxx_source_compiles(
42 "
43 #include <cstdint>
44 #include <functional>
45 namespace std { template<> struct hash<uint64_t> {}; }
46 int main() { return 0; }
47 "
48 CVC4_NEED_HASH_UINT64_T_OVERLOAD
49 )
50 if(CVC4_NEED_HASH_UINT64_T_OVERLOAD)
51 add_definitions(-DCVC4_NEED_HASH_UINT64_T)
52 endif()
53
54 check_include_file(unistd.h HAVE_UNISTD_H)
55 check_include_file_cxx(ext/stdio_filebuf.h HAVE_EXT_STDIO_FILEBUF_H)
56
57 # For Windows builds check if clock_gettime is available via -lpthread
58 # (pthread_time.h).
59 if(CVC4_WINDOWS_BUILD)
60 set(CMAKE_REQUIRED_FLAGS -pthread)
61 check_symbol_exists(clock_gettime "time.h" HAVE_CLOCK_GETTIME)
62 unset(CMAKE_REQUIRED_FLAGS)
63 if(HAVE_CLOCK_GETTIME)
64 add_c_cxx_flag(-pthread)
65 endif()
66 else()
67 check_symbol_exists(clock_gettime "time.h" HAVE_CLOCK_GETTIME)
68 if(NOT HAVE_CLOCK_GETTIME)
69 unset(HAVE_CLOCK_GETTIME CACHE)
70 check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME)
71 find_library(RT_LIBRARIES NAMES rt)
72 endif()
73 endif()
74 check_symbol_exists(ffs "strings.h" HAVE_FFS)
75 check_symbol_exists(optreset "getopt.h" HAVE_DECL_OPTRESET)
76 check_symbol_exists(sigaltstack "signal.h" HAVE_SIGALTSTACK)
77 check_symbol_exists(strerror_r "string.h" HAVE_STRERROR_R)
78 check_symbol_exists(strtok_r "string.h" HAVE_STRTOK_R)
79 check_symbol_exists(setitimer "sys/time.h" HAVE_SETITIMER)
80
81 # on non-POSIX systems, time limit is implemented with threads
82 if(NOT HAVE_SETITIMER)
83 find_package(Threads REQUIRED)
84 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_THREAD_LIBS_INIT}")
85 endif()
86
87 # Determine if we have the POSIX (int) or GNU (char *) variant of strerror_r.
88 check_c_source_compiles(
89 "
90 #include <string.h>
91 int main(void)
92 {
93 char buf[1];
94 char c = *strerror_r(0, buf, 0);
95 return 0;
96 }
97 "
98 STRERROR_R_CHAR_P
99 )
100
101 # Defined if using the CLN multi-precision arithmetic library.
102 set(CVC4_CLN_IMP ${CVC4_USE_CLN_IMP})
103 # Defined if using the GMP multi-precision arithmetic library.
104 set(CVC4_GMP_IMP ${CVC4_USE_GMP_IMP})
105 # Defined if using the libpoly polynomial library.
106 set(CVC4_POLY_IMP ${CVC4_USE_POLY_IMP})
107 # Define the full name of this package.
108 set(CVC4_PACKAGE_NAME "${PROJECT_NAME}")