Fix tangent plane lemmas (#5455)
[cvc5.git] / CMakeLists.txt
1 #####################
2 ## CMakeLists.txt
3 ## Top contributors (to current version):
4 ## Mathias Preiner, Aina Niemetz, Gereon Kremer
5 ## This file is part of the CVC4 project.
6 ## Copyright (c) 2009-2020 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 cmake_minimum_required(VERSION 3.4)
12
13 #-----------------------------------------------------------------------------#
14 # Project configuration
15
16 project(cvc4)
17
18 include(GNUInstallDirs)
19
20 set(CVC4_MAJOR 1) # Major component of the version of CVC4.
21 set(CVC4_MINOR 9) # Minor component of the version of CVC4.
22 set(CVC4_RELEASE 0) # Release component of the version of CVC4.
23
24 # Extraversion component of the version of CVC4.
25 set(CVC4_EXTRAVERSION "-prerelease")
26
27 # Shared library versioning. Increment SOVERSION for every new CVC4 release.
28 set(CVC4_SOVERSION 7)
29
30 # Full release string for CVC4.
31 if(CVC4_RELEASE)
32 set(CVC4_RELEASE_STRING
33 "${CVC4_MAJOR}.${CVC4_MINOR}.${CVC4_RELEASE}${CVC4_EXTRAVERSION}")
34 else()
35 set(CVC4_RELEASE_STRING "${CVC4_MAJOR}.${CVC4_MINOR}${CVC4_EXTRAVERSION}")
36 endif()
37
38 set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
39 set(CMAKE_C_STANDARD 99)
40 set(CMAKE_CXX_STANDARD 11)
41 set(CMAKE_CXX_EXTENSIONS OFF)
42
43 # Generate compile_commands.json, which can be used for various code completion
44 # plugins.
45 set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
46
47 #-----------------------------------------------------------------------------#
48 # Policies
49
50 # Required for FindGLPK since it sets CMAKE_REQUIRED_LIBRARIES
51 if(POLICY CMP0075)
52 cmake_policy(SET CMP0075 NEW)
53 endif()
54
55 #-----------------------------------------------------------------------------#
56 # Tell CMake where to find our dependencies
57
58 if(ABC_DIR)
59 list(APPEND CMAKE_PREFIX_PATH "${ABC_DIR}")
60 endif()
61 if(ANTLR_DIR)
62 list(APPEND CMAKE_PREFIX_PATH "${ANTLR_DIR}")
63 endif()
64 if(CADICAL_DIR)
65 list(APPEND CMAKE_PREFIX_PATH "${CADICAL_DIR}")
66 endif()
67 if(CRYPTOMINISAT_DIR)
68 list(APPEND CMAKE_PREFIX_PATH "${CRYPTOMINISAT_DIR}")
69 endif()
70 if(CXXTEST_DIR)
71 list(APPEND CMAKE_PREFIX_PATH "${CXXTEST_DIR}")
72 endif()
73 if(DRAT2ER_DIR)
74 list(APPEND CMAKE_PREFIX_PATH "${DRAT2ER_DIR}")
75 endif()
76 if(GLPK_DIR)
77 list(APPEND CMAKE_PREFIX_PATH "${GLPK_DIR}")
78 endif()
79 if(GMP_DIR)
80 list(APPEND CMAKE_PREFIX_PATH "${GMP_DIR}")
81 endif()
82 if(KISSAT_DIR)
83 list(APPEND CMAKE_PREFIX_PATH "${KISSAT_DIR}")
84 endif()
85 if(LFSC_DIR)
86 list(APPEND CMAKE_PREFIX_PATH "${LFSC_DIR}")
87 endif()
88 if(POLY_DIR)
89 list(APPEND CMAKE_PREFIX_PATH "${POLY_DIR}")
90 endif()
91 if(SYMFPU_DIR)
92 list(APPEND CMAKE_PREFIX_PATH "${SYMFPU_DIR}")
93 endif()
94
95 # By default the contrib/get-* scripts install dependencies to deps/install.
96 list(APPEND CMAKE_PREFIX_PATH "${PROJECT_SOURCE_DIR}/deps/install")
97
98 #-----------------------------------------------------------------------------#
99
100 include(Helpers)
101
102 #-----------------------------------------------------------------------------#
103 # User options
104
105 # License
106 option(ENABLE_GPL "Enable GPL dependencies")
107
108 # General build options
109 #
110 # >> 3-valued: IGNORE ON OFF
111 # > allows to detect if set by user (default: IGNORE)
112 # > only necessary for options set for build types
113 cvc4_option(ENABLE_ASAN "Enable ASAN build")
114 cvc4_option(ENABLE_UBSAN "Enable UBSan build")
115 cvc4_option(ENABLE_TSAN "Enable TSan build")
116 cvc4_option(ENABLE_ASSERTIONS "Enable assertions")
117 cvc4_option(ENABLE_COMP_INC_TRACK
118 "Enable optimizations for incremental SMT-COMP tracks")
119 cvc4_option(ENABLE_DEBUG_SYMBOLS "Enable debug symbols")
120 cvc4_option(ENABLE_DUMPING "Enable dumping")
121 cvc4_option(ENABLE_MUZZLE "Suppress ALL non-result output")
122 cvc4_option(ENABLE_PROOFS "Enable proof support")
123 cvc4_option(ENABLE_STATISTICS "Enable statistics")
124 cvc4_option(ENABLE_TRACING "Enable tracing")
125 cvc4_option(ENABLE_UNIT_TESTING "Enable unit testing")
126 cvc4_option(ENABLE_VALGRIND "Enable valgrind instrumentation")
127 cvc4_option(ENABLE_SHARED "Build as shared library")
128 cvc4_option(ENABLE_STATIC_BINARY
129 "Build static binaries with statically linked system libraries")
130 # >> 2-valued: ON OFF
131 # > for options where we don't need to detect if set by user (default: OFF)
132 option(ENABLE_BEST "Enable dependencies known to give best performance")
133 option(ENABLE_COVERAGE "Enable support for gcov coverage testing")
134 option(ENABLE_DEBUG_CONTEXT_MM "Enable the debug context memory manager")
135 option(ENABLE_PROFILING "Enable support for gprof profiling")
136
137 # Optional dependencies
138 #
139 # >> 3-valued: IGNORE ON OFF
140 # > allows to detect if set by user (default: IGNORE)
141 # > only necessary for options set for ENABLE_BEST
142 cvc4_option(USE_ABC "Use ABC for AIG bit-blasting")
143 cvc4_option(USE_CADICAL "Use CaDiCaL SAT solver")
144 cvc4_option(USE_CLN "Use CLN instead of GMP")
145 cvc4_option(USE_CRYPTOMINISAT "Use CryptoMiniSat SAT solver")
146 cvc4_option(USE_GLPK "Use GLPK simplex solver")
147 cvc4_option(USE_KISSAT "Use Kissat SAT solver")
148 cvc4_option(USE_EDITLINE "Use Editline for better interactive support")
149 # >> 2-valued: ON OFF
150 # > for options where we don't need to detect if set by user (default: OFF)
151 option(USE_DRAT2ER "Include drat2er for making eager BV proofs")
152 option(USE_LFSC "Use LFSC proof checker")
153 option(USE_POLY "Use LibPoly for polynomial arithmetic")
154 option(USE_SYMFPU "Use SymFPU for floating point support")
155 option(USE_PYTHON2 "Prefer using Python 2 (for Python bindings)")
156 option(USE_PYTHON3 "Prefer using Python 3 (for Python bindings)")
157
158 # Custom install directories for dependencies
159 # If no directory is provided by the user, we first check if the dependency was
160 # installed via the corresponding contrib/get-* script and if not found, we
161 # check the intalled system version. If the user provides a directory we
162 # immediately fail if the dependency was not found at the specified location.
163 set(ABC_DIR "" CACHE STRING "Set ABC install directory")
164 set(ANTLR_DIR "" CACHE STRING "Set ANTLR3 install directory")
165 set(CADICAL_DIR "" CACHE STRING "Set CaDiCaL install directory")
166 set(CRYPTOMINISAT_DIR "" CACHE STRING "Set CryptoMiniSat install directory")
167 set(CXXTEST_DIR "" CACHE STRING "Set CxxTest install directory")
168 set(DRAT2ER_DIR "" CACHE STRING "Set drat2er install directory")
169 set(GLPK_DIR "" CACHE STRING "Set GLPK install directory")
170 set(GMP_DIR "" CACHE STRING "Set GMP install directory")
171 set(KISSAT_DIR "" CACHE STRING "Set Kissat install directory")
172 set(LFSC_DIR "" CACHE STRING "Set LFSC install directory")
173 set(POLY_DIR "" CACHE STRING "Set LibPoly install directory")
174 set(SYMFPU_DIR "" CACHE STRING "Set SymFPU install directory")
175
176 # Prepend binaries with prefix on make install
177 set(PROGRAM_PREFIX "" CACHE STRING "Program prefix on make install")
178
179 # Supprted language bindings based on new C++ API
180 option(BUILD_BINDINGS_PYTHON "Build Python bindings based on new C++ API ")
181 option(BUILD_BINDINGS_JAVA "Build Java bindings based on new C++ API ")
182
183 # Build limitations
184 option(BUILD_LIB_ONLY "Only build the library")
185
186 #-----------------------------------------------------------------------------#
187 # Internal cmake variables
188
189 set(OPTIMIZATION_LEVEL 3)
190 set(GPL_LIBS "")
191
192 #-----------------------------------------------------------------------------#
193 # Determine number of threads available, used to configure (default) parallel
194 # execution of custom test targets (can be overriden with ARGS=-jN).
195
196 include(ProcessorCount)
197 ProcessorCount(CTEST_NTHREADS)
198 if(CTEST_NTHREADS EQUAL 0)
199 set(CTEST_NTHREADS 1)
200 endif()
201
202 #-----------------------------------------------------------------------------#
203 # Build types
204
205 # Note: Module CodeCoverage requires the name of the debug build to conform
206 # to cmake standards (first letter uppercase).
207 set(BUILD_TYPES Production Debug Testing Competition)
208
209 if(ENABLE_ASAN OR ENABLE_UBSAN OR ENABLE_TSAN)
210 set(CMAKE_BUILD_TYPE Debug)
211 endif()
212
213 # Set the default build type to Production
214 if(NOT CMAKE_BUILD_TYPE)
215 set(CMAKE_BUILD_TYPE
216 Production CACHE STRING "Options are: ${BUILD_TYPES}" FORCE)
217 # Provide drop down menu options in cmake-gui
218 set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${BUILD_TYPES})
219 endif()
220
221 # Check if specified build type is valid.
222 list(FIND BUILD_TYPES ${CMAKE_BUILD_TYPE} FOUND_BUILD_TYPE)
223 if(${FOUND_BUILD_TYPE} EQUAL -1)
224 message(FATAL_ERROR
225 "'${CMAKE_BUILD_TYPE}' is not a valid build type. "
226 "Available builds are: ${BUILD_TYPES}")
227 endif()
228
229 message(STATUS "Building ${CMAKE_BUILD_TYPE} build")
230 include(Config${CMAKE_BUILD_TYPE})
231
232 #-----------------------------------------------------------------------------#
233 # Compiler flags
234
235 add_check_c_cxx_flag("-O${OPTIMIZATION_LEVEL}")
236 add_check_c_cxx_flag("-Wall")
237 add_check_c_flag("-fexceptions")
238 add_check_c_cxx_flag("-Wno-deprecated")
239 add_check_cxx_flag("-Wsuggest-override")
240 add_check_cxx_flag("-Wnon-virtual-dtor")
241 add_check_c_cxx_flag("-Wimplicit-fallthrough")
242 add_check_c_cxx_flag("-Wshadow")
243
244 # Temporarily disable -Wclass-memaccess to suppress 'no trivial copy-assignment'
245 # cdlist.h warnings. Remove when fixed.
246 add_check_cxx_flag("-Wno-class-memaccess")
247
248 if (WIN32)
249 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--stack,100000000")
250 endif ()
251
252 #-----------------------------------------------------------------------------#
253 # Use ld.gold if available
254
255 execute_process(COMMAND ${CMAKE_C_COMPILER}
256 -fuse-ld=gold
257 -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
258 if ("${LD_VERSION}" MATCHES "GNU gold")
259 string(APPEND CMAKE_EXE_LINKER_FLAGS " -fuse-ld=gold")
260 string(APPEND CMAKE_SHARED_LINKER_FLAGS " -fuse-ld=gold")
261 string(APPEND CMAKE_MODULE_LINKER_FLAGS " -fuse-ld=gold")
262 message(STATUS "Using GNU gold linker.")
263 endif ()
264
265 #-----------------------------------------------------------------------------#
266 # Option defaults (three-valued options (cvc4_option(...)))
267 #
268 # These options are only set if their value is IGNORE. Otherwise, the user
269 # already set the option, which we don't want to overwrite.
270
271 if(ENABLE_STATIC_BINARY)
272 cvc4_set_option(ENABLE_SHARED OFF)
273 else()
274 cvc4_set_option(ENABLE_SHARED ON)
275 endif()
276
277 #-----------------------------------------------------------------------------#
278 # Set options for best configuration
279
280 if(ENABLE_BEST)
281 cvc4_set_option(USE_ABC ON)
282 cvc4_set_option(USE_CADICAL ON)
283 cvc4_set_option(USE_CLN ON)
284 cvc4_set_option(USE_CRYPTOMINISAT ON)
285 cvc4_set_option(USE_GLPK ON)
286 cvc4_set_option(USE_EDITLINE ON)
287 endif()
288
289 # Only enable unit testing if assertions are enabled. Otherwise, unit tests
290 # that expect AssertionException to be thrown will fail.
291 if(NOT ENABLE_ASSERTIONS)
292 message(WARNING "Disabling unit tests since assertions are disabled.")
293 set(ENABLE_UNIT_TESTING OFF)
294 endif()
295
296 #-----------------------------------------------------------------------------#
297 # Shared/static libraries
298 #
299 # This needs to be set before any find_package(...) command since we want to
300 # search for static libraries with suffix .a.
301
302 if(ENABLE_SHARED)
303 set(BUILD_SHARED_LIBS ON)
304 if(ENABLE_STATIC_BINARY)
305 set(ENABLE_STATIC_BINARY OFF)
306 message(WARNING "Disabling static binary since shared build is enabled.")
307 endif()
308
309 # Embed the installation prefix as an RPATH in the executable such that the
310 # linker can find our libraries (such as libcvc4parser) when executing the
311 # cvc4 binary. This is for example useful when installing CVC4 with a custom
312 # prefix on macOS (e.g. when using homebrew in a non-standard directory). If
313 # we do not set this option, then the linker will not be able to find the
314 # required libraries when trying to run CVC4.
315 #
316 # Also embed the installation prefix of the installed contrib libraries as an
317 # RPATH. This allows to install a dynamically linked binary that depends on
318 # dynamically linked libraries. This is dangerous, as the installed binary
319 # breaks if the contrib library is removed or changes in other ways, we thus
320 # print a big warning and only allow if installing to a custom installation
321 # prefix.
322 #
323 # More information on RPATH in CMake:
324 # https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling
325 set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR};${PROJECT_SOURCE_DIR}/deps/install/lib")
326 else()
327 # When building statically, we *only* want static archives/libraries
328 if (WIN32)
329 set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a)
330 else()
331 set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
332 endif()
333 set(BUILD_SHARED_LIBS OFF)
334 cvc4_set_option(ENABLE_STATIC_BINARY ON)
335
336 # Never build unit tests as static binaries, otherwise we'll end up with
337 # ~300MB per unit test.
338 if(ENABLE_UNIT_TESTING)
339 message(WARNING "Disabling unit tests since static build is enabled.")
340 set(ENABLE_UNIT_TESTING OFF)
341 endif()
342
343 if (BUILD_BINDINGS_PYTHON)
344 message(FATAL_ERROR "Building Python bindings is not possible "
345 "when building statically")
346 endif()
347 endif()
348
349 #-----------------------------------------------------------------------------#
350 # Enable the ctest testing framework
351
352 # This needs to be enabled here rather than in subdirectory test in order to
353 # allow calling ctest from the root build directory.
354 enable_testing()
355
356 #-----------------------------------------------------------------------------#
357 # Check GCC version.
358 #
359 # GCC version 4.5.1 builds MiniSat incorrectly with -O2, which results in
360 # incorrect answers.
361
362 if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
363 execute_process(
364 COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
365 OUTPUT_VARIABLE GCC_VERSION
366 OUTPUT_STRIP_TRAILING_WHITESPACE)
367 if(GCC_VERSION VERSION_EQUAL "4.5.1")
368 message(FATAL_ERROR
369 "GCC 4.5.1's optimizer is known to build MiniSat incorrectly "
370 "(and by extension CVC4).")
371 endif()
372 endif()
373
374 #-----------------------------------------------------------------------------#
375 # Check options, find packages and configure build.
376
377 if(USE_PYTHON2)
378 find_package(PythonInterp 2.7 REQUIRED)
379 elseif(USE_PYTHON3)
380 find_package(PythonInterp 3 REQUIRED)
381 else()
382 find_package(PythonInterp REQUIRED)
383 endif()
384
385 find_package(GMP REQUIRED)
386
387 if(ENABLE_ASAN)
388 # -fsanitize=address requires CMAKE_REQUIRED_FLAGS to be explicitely set,
389 # otherwise the -fsanitize=address check will fail while linking.
390 set(CMAKE_REQUIRED_FLAGS -fsanitize=address)
391 add_required_c_cxx_flag("-fsanitize=address")
392 unset(CMAKE_REQUIRED_FLAGS)
393 add_required_c_cxx_flag("-fno-omit-frame-pointer")
394 add_check_c_cxx_flag("-fsanitize-recover=address")
395 endif()
396
397 if(ENABLE_UBSAN)
398 add_required_c_cxx_flag("-fsanitize=undefined")
399 add_definitions(-DCVC4_USE_UBSAN)
400 endif()
401
402 if(ENABLE_TSAN)
403 # -fsanitize=thread requires CMAKE_REQUIRED_FLAGS to be explicitely set,
404 # otherwise the -fsanitize=thread check will fail while linking.
405 set(CMAKE_REQUIRED_FLAGS -fsanitize=thread)
406 add_required_c_cxx_flag("-fsanitize=thread")
407 unset(CMAKE_REQUIRED_FLAGS)
408 endif()
409
410 if(ENABLE_ASSERTIONS)
411 add_definitions(-DCVC4_ASSERTIONS)
412 else()
413 add_definitions(-DNDEBUG)
414 endif()
415
416 if(ENABLE_COVERAGE)
417 include(CodeCoverage)
418 APPEND_COVERAGE_COMPILER_FLAGS()
419 add_definitions(-DCVC4_COVERAGE)
420 # Note: The ctest command returns a non-zero exit code if tests fail or run
421 # into a timeout. As a consequence, the coverage report is not generated. To
422 # prevent this we always return with exit code 0 after the ctest command has
423 # finished.
424 setup_target_for_coverage_gcovr_html(
425 NAME coverage
426 EXECUTABLE
427 ctest -j${CTEST_NTHREADS} -LE "example"
428 --output-on-failure $$ARGS || exit 0
429 DEPENDS
430 build-tests)
431 endif()
432
433 if(ENABLE_DEBUG_CONTEXT_MM)
434 add_definitions(-DCVC4_DEBUG_CONTEXT_MEMORY_MANAGER)
435 endif()
436
437 if(ENABLE_DEBUG_SYMBOLS)
438 add_check_c_cxx_flag("-ggdb3")
439 endif()
440
441 if(ENABLE_COMP_INC_TRACK)
442 add_definitions(-DCVC4_SMTCOMP_APPLICATION_TRACK)
443 endif()
444
445 if(ENABLE_MUZZLE)
446 add_definitions(-DCVC4_MUZZLE)
447 endif()
448
449 if(ENABLE_DUMPING)
450 add_definitions(-DCVC4_DUMPING)
451 endif()
452
453 if(ENABLE_PROFILING)
454 add_definitions(-DCVC4_PROFILING)
455 add_check_c_cxx_flag("-pg")
456 endif()
457
458 if(ENABLE_PROOFS)
459 set(RUN_REGRESSION_ARGS ${RUN_REGRESSION_ARGS} --enable-proof)
460 add_definitions(-DCVC4_PROOF)
461 endif()
462
463 if(ENABLE_TRACING)
464 add_definitions(-DCVC4_TRACING)
465 endif()
466
467 if(ENABLE_STATISTICS)
468 add_definitions(-DCVC4_STATISTICS_ON)
469 endif()
470
471 if(ENABLE_VALGRIND)
472 find_package(Valgrind REQUIRED)
473 add_definitions(-DCVC4_VALGRIND)
474 endif()
475
476 if(USE_ABC)
477 find_package(ABC REQUIRED)
478 add_definitions(-DCVC4_USE_ABC ${ABC_ARCH_FLAGS})
479 endif()
480
481 if(USE_CADICAL)
482 find_package(CaDiCaL REQUIRED)
483 add_definitions(-DCVC4_USE_CADICAL)
484 endif()
485
486 if(USE_CLN)
487 set(GPL_LIBS "${GPL_LIBS} cln")
488 find_package(CLN 1.2.2 REQUIRED)
489 set(CVC4_USE_CLN_IMP 1)
490 set(CVC4_USE_GMP_IMP 0)
491 else()
492 set(CVC4_USE_CLN_IMP 0)
493 set(CVC4_USE_GMP_IMP 1)
494 endif()
495
496 if(USE_CRYPTOMINISAT)
497 # CryptoMiniSat requires pthreads support
498 set(THREADS_PREFER_PTHREAD_FLAG ON)
499 find_package(Threads REQUIRED)
500 if(THREADS_HAVE_PTHREAD_ARG)
501 add_c_cxx_flag(-pthread)
502 endif()
503 find_package(CryptoMiniSat REQUIRED)
504 add_definitions(-DCVC4_USE_CRYPTOMINISAT)
505 endif()
506
507 if(USE_DRAT2ER)
508 find_package(Drat2Er REQUIRED)
509 add_definitions(-DCVC4_USE_DRAT2ER)
510 endif()
511
512 if(USE_GLPK)
513 set(GPL_LIBS "${GPL_LIBS} glpk")
514 find_package(GLPK REQUIRED)
515 add_definitions(-DCVC4_USE_GLPK)
516 endif()
517
518 if(USE_KISSAT)
519 find_package(Kissat REQUIRED)
520 add_definitions(-DCVC4_USE_KISSAT)
521 endif()
522
523 if(USE_LFSC)
524 set(RUN_REGRESSION_ARGS ${RUN_REGRESSION_ARGS} --with-lfsc)
525 find_package(LFSC REQUIRED)
526 add_definitions(-DCVC4_USE_LFSC)
527 endif()
528
529 if(USE_POLY)
530 find_package(Poly REQUIRED)
531 add_definitions(-DCVC4_USE_POLY)
532 set(CVC4_USE_POLY_IMP 1)
533 else()
534 set(CVC4_USE_POLY_IMP 0)
535 endif()
536
537 if(USE_EDITLINE)
538 find_package(Editline REQUIRED)
539 set(HAVE_LIBEDITLINE 1)
540 if(Editline_COMPENTRY_FUNC_RETURNS_CHARPTR)
541 set(EDITLINE_COMPENTRY_FUNC_RETURNS_CHARP 1)
542 endif()
543 endif()
544
545 if(USE_SYMFPU)
546 find_package(SymFPU REQUIRED)
547 add_definitions(-DCVC4_USE_SYMFPU)
548 set(CVC4_USE_SYMFPU 1)
549 else()
550 set(CVC4_USE_SYMFPU 0)
551 endif()
552
553 if(GPL_LIBS)
554 if(NOT ENABLE_GPL)
555 message(FATAL_ERROR
556 "Bad configuration detected: BSD-licensed code only, but also requested "
557 "GPLed libraries: ${GPL_LIBS}")
558 endif()
559 set(CVC4_GPL_DEPS 1)
560 endif()
561
562 #-----------------------------------------------------------------------------#
563 # Generate CVC4's cvc4autoconfig.h header
564
565 include(ConfigureCVC4)
566 if(NOT ENABLE_SHARED)
567 set(CVC4_STATIC_BUILD ON)
568 endif()
569 configure_file(cvc4autoconfig.h.in cvc4autoconfig.h)
570 unset(CVC4_STATIC_BUILD)
571 include_directories(${CMAKE_CURRENT_BINARY_DIR})
572
573 #-----------------------------------------------------------------------------#
574 # Add subdirectories
575
576 # signatures needs to come before src since it adds source files to libcvc4.
577 if(ENABLE_PROOFS)
578 add_subdirectory(proofs/signatures)
579 endif()
580
581 add_subdirectory(doc)
582 add_subdirectory(src)
583 add_subdirectory(test)
584
585 if(BUILD_BINDINGS_PYTHON)
586 set(BUILD_BINDINGS_PYTHON_VERSION ${PYTHON_VERSION_MAJOR})
587 add_subdirectory(src/api/python)
588 endif()
589
590 if(BUILD_BINDINGS_JAVA)
591 message(FATAL_ERROR
592 "Java bindings for the new API are not implemented yet.")
593 endif()
594
595 #-----------------------------------------------------------------------------#
596 # Package configuration
597 #
598 # Export CVC4 targets to support find_package(CVC4) in other cmake projects.
599
600 include(CMakePackageConfigHelpers)
601
602 # If we install a dynamically linked binary that also uses dynamically used
603 # libraries from deps/install/lib, we need to be cautious. Changing these
604 # shared libraries from deps/install/lib most probably breaks the binary.
605 # We only allow such an installation for custom installation prefixes
606 # (in the assumption that only reasonably experienced users use this and
607 # also that custom installation prefixes are not used for longer periods of
608 # time anyway). Also, we print a big warning with further instructions.
609 if(NOT ENABLE_STATIC_BINARY)
610 # Get the libraries that cvc4 links against
611 get_target_property(libs cvc4 INTERFACE_LINK_LIBRARIES)
612 set(LIBS_SHARED_FROM_DEPS "")
613 foreach(lib ${libs})
614 # Filter out those that are linked dynamically and come from deps/install
615 if(lib MATCHES ".*/deps/install/lib/.*\.so")
616 list(APPEND LIBS_SHARED_FROM_DEPS ${lib})
617 endif()
618 endforeach()
619 list(LENGTH LIBS_SHARED_FROM_DEPS list_len)
620 # Check if we actually use such "dangerous" libraries
621 if(list_len GREATER 0)
622 # Print a generic warning
623 install(CODE "message(WARNING \"You are installing a dynamically linked \
624 binary of CVC4 which may be a problem if you are using any dynamically \
625 linked third-party library that you obtained through one of the \
626 contrib/get-xxx scripts. The binary uses the rpath mechanism to find these \
627 locally, hence executing such a contrib script removing the \
628 \\\"deps/install\\\" folder most probably breaks the installed binary! \
629 Consider installing the dynamically linked dependencies on your system \
630 manually or link cvc4 statically.\")")
631 # Print the libraries in question
632 foreach(lib ${LIBS_SHARED_FROM_DEPS})
633 install(CODE "message(WARNING \"The following library is used by the cvc4 binary: ${lib}\")")
634 endforeach()
635 # Check if we use a custom installation prefix
636 if(CMAKE_INSTALL_PREFIX STREQUAL "/usr/local")
637 install(CODE "message(FATAL_ERROR \"To avoid installing a \
638 soon-to-be-broken binary, system-wide installation is disabled if the \
639 binary depends on locally-built shared libraries.\")")
640 else()
641 install(CODE "message(WARNING \"You have selected a custom install \
642 directory ${CMAKE_INSTALL_PREFIX}, so we expect you understood the \
643 previous warning and know what you are doing.\")")
644 endif()
645 endif()
646 endif()
647
648 install(EXPORT cvc4-targets
649 FILE CVC4Targets.cmake
650 NAMESPACE CVC4::
651 DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/CVC4)
652
653 configure_package_config_file(
654 ${CMAKE_SOURCE_DIR}/cmake/CVC4Config.cmake.in
655 ${CMAKE_BINARY_DIR}/cmake/CVC4Config.cmake
656 INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/CVC4
657 PATH_VARS CMAKE_INSTALL_LIBDIR
658 )
659
660 write_basic_package_version_file(
661 ${CMAKE_CURRENT_BINARY_DIR}/CVC4ConfigVersion.cmake
662 VERSION ${CVC4_RELEASE_STRING}
663 COMPATIBILITY ExactVersion
664 )
665
666 install(FILES
667 ${CMAKE_BINARY_DIR}/cmake/CVC4Config.cmake
668 ${CMAKE_BINARY_DIR}/CVC4ConfigVersion.cmake
669 DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/CVC4
670 )
671
672
673 #-----------------------------------------------------------------------------#
674 # Print build configuration
675
676 # Convert build type to lower case.
677 string(TOLOWER ${CMAKE_BUILD_TYPE} CVC4_BUILD_PROFILE_STRING)
678
679 # Get all definitions added via add_definitions.
680 get_directory_property(CVC4_DEFINITIONS COMPILE_DEFINITIONS)
681 string(REPLACE ";" " " CVC4_DEFINITIONS "${CVC4_DEFINITIONS}")
682
683 message("CVC4 ${CVC4_RELEASE_STRING}")
684 message("")
685 if(ENABLE_COMP_INC_TRACK)
686 message("Build profile : ${CVC4_BUILD_PROFILE_STRING} (incremental)")
687 else()
688 message("Build profile : ${CVC4_BUILD_PROFILE_STRING}")
689 endif()
690 message("")
691 print_config("GPL :" ENABLE_GPL)
692 print_config("Best configuration :" ENABLE_BEST)
693 print_config("Optimization level :" OPTIMIZATION_LEVEL)
694 message("")
695 print_config("Assertions :" ENABLE_ASSERTIONS)
696 print_config("Debug symbols :" ENABLE_DEBUG_SYMBOLS)
697 print_config("Debug context mem mgr :" ENABLE_DEBUG_CONTEXT_MM)
698 message("")
699 print_config("Dumping :" ENABLE_DUMPING)
700 print_config("Muzzle :" ENABLE_MUZZLE)
701 print_config("Proofs :" ENABLE_PROOFS)
702 print_config("Statistics :" ENABLE_STATISTICS)
703 print_config("Tracing :" ENABLE_TRACING)
704 message("")
705 print_config("ASan :" ENABLE_ASAN)
706 print_config("UBSan :" ENABLE_UBSAN)
707 print_config("TSan :" ENABLE_TSAN)
708 print_config("Coverage (gcov) :" ENABLE_COVERAGE)
709 print_config("Profiling (gprof) :" ENABLE_PROFILING)
710 print_config("Unit tests :" ENABLE_UNIT_TESTING)
711 print_config("Valgrind :" ENABLE_VALGRIND)
712 message("")
713 print_config("Shared libs :" ENABLE_SHARED)
714 print_config("Static binary :" ENABLE_STATIC_BINARY)
715 print_config("Python bindings :" BUILD_BINDINGS_PYTHON)
716 print_config("Java bindings :" BUILD_BINDINGS_JAVA)
717 print_config("Python2 :" USE_PYTHON2)
718 print_config("Python3 :" USE_PYTHON3)
719 message("")
720 print_config("ABC :" USE_ABC)
721 print_config("CaDiCaL :" USE_CADICAL)
722 print_config("CryptoMiniSat :" USE_CRYPTOMINISAT)
723 print_config("drat2er :" USE_DRAT2ER)
724 print_config("GLPK :" USE_GLPK)
725 print_config("Kissat :" USE_KISSAT)
726 print_config("LFSC :" USE_LFSC)
727 print_config("LibPoly :" USE_POLY)
728 message("")
729 print_config("BUILD_LIB_ONLY :" BUILD_LIB_ONLY)
730
731 if(CVC4_USE_CLN_IMP)
732 message("MP library : cln")
733 else()
734 message("MP library : gmp")
735 endif()
736 print_config("Editline :" ${USE_EDITLINE})
737 print_config("SymFPU :" ${USE_SYMFPU})
738 message("")
739 if(ABC_DIR)
740 message("ABC dir : ${ABC_DIR}")
741 endif()
742 if(ANTLR_DIR)
743 message("ANTLR dir : ${ANTLR_DIR}")
744 endif()
745 if(CADICAL_DIR)
746 message("CADICAL dir : ${CADICAL_DIR}")
747 endif()
748 if(CRYPTOMINISAT_DIR)
749 message("CRYPTOMINISAT dir : ${CRYPTOMINISAT_DIR}")
750 endif()
751 if(DRAT2ER_DIR)
752 message("DRAT2ER dir : ${DRAT2ER_DIR}")
753 endif()
754 if(GLPK_DIR)
755 message("GLPK dir : ${GLPK_DIR}")
756 endif()
757 if(GMP_DIR)
758 message("GMP dir : ${GMP_DIR}")
759 endif()
760 if(KISSAT_DIR)
761 message("KISSAT dir : ${KISSAT_DIR}")
762 endif()
763 if(LFSC_DIR)
764 message("LFSC dir : ${LFSC_DIR}")
765 endif()
766 if(POLY_DIR)
767 message("LibPoly dir : ${POLY_DIR}")
768 endif()
769 if(SYMFPU_DIR)
770 message("SYMFPU dir : ${SYMFPU_DIR}")
771 endif()
772 message("")
773 message("CPPLAGS (-D...) : ${CVC4_DEFINITIONS}")
774 message("CXXFLAGS : ${CMAKE_CXX_FLAGS}")
775 message("CFLAGS : ${CMAKE_C_FLAGS}")
776 message("Linker flags : ${CMAKE_EXE_LINKER_FLAGS}")
777 message("")
778 message("Install prefix : ${CMAKE_INSTALL_PREFIX}")
779 message("")
780
781 if(GPL_LIBS)
782 message(
783 "CVC4 license : ${Yellow}GPLv3 (due to optional libraries; see below)${ResetColor}"
784 "\n"
785 "\n"
786 "Please note that CVC4 will be built against the following GPLed libraries:"
787 "\n"
788 "${GPL_LIBS}"
789 "\n"
790 "As these libraries are covered under the GPLv3, so is this build of CVC4."
791 "\n"
792 "CVC4 is also available to you under the terms of the (modified) BSD license."
793 "\n"
794 "If you prefer to license CVC4 under those terms, please configure CVC4 to"
795 "\n"
796 "disable all optional GPLed library dependencies (-DENABLE_BSD_ONLY=ON)."
797 )
798 else()
799 message(
800 "CVC4 license : modified BSD"
801 "\n"
802 "\n"
803 "Note that this configuration is NOT built against any GPL'ed libraries, so"
804 "\n"
805 "it is covered by the (modified) BSD license. This is, however, not the best"
806 "\n"
807 "performing configuration of CVC4. To build against GPL'ed libraries which"
808 "\n"
809 "improve CVC4's performance, re-configure with '-DENABLE_GPL -DENABLE_BEST'."
810 )
811 endif()
812
813 if("${CMAKE_GENERATOR}" STREQUAL "Ninja")
814 set(BUILD_COMMAND_NAME "ninja")
815 else()
816 set(BUILD_COMMAND_NAME "make")
817 endif()
818
819 message("")
820 message("Now just type '${BUILD_COMMAND_NAME}', "
821 "followed by '${BUILD_COMMAND_NAME} check' "
822 "or '${BUILD_COMMAND_NAME} install'.")
823 message("")