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