1 ###############################################################################
2 # Top contributors (to current version):
3 # Mathias Preiner, Gereon Kremer, Aina Niemetz
5 # This file is part of the cvc5 project.
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 # #############################################################################
13 # The build system configuration.
16 # libmain source files
28 #-----------------------------------------------------------------------------#
29 # Build object library since we will use the object files for cvc5-bin and
32 add_library(main OBJECT ${libmain_src_files})
33 target_compile_definitions(main PRIVATE -D__BUILDING_CVC5DRIVER)
35 set_target_properties(main PROPERTIES POSITION_INDEPENDENT_CODE ON)
38 # We can't use target_link_libraries(main ...) here since this is only
39 # supported for cmake version >= 3.12. Hence, we have to manually add the
40 # library dependencies for main. As a consequence, include directories from
41 # dependencies are not propagated and we need to manually add the include
42 # directories of libcvc5 to main.
43 add_dependencies(main cvc5 cvc5parser gen-tokens)
45 # Note: This should not be required anymore as soon as we get rid of the
46 # smt_engine.h include in src/main. smt_engine.h has transitive includes
47 # of GMP and CLN via sexpr.h and therefore needs GMP/CLN headers.
49 get_target_property(CLN_INCLUDES CLN INTERFACE_INCLUDE_DIRECTORIES)
50 target_include_directories(main PRIVATE ${CLN_INCLUDES})
52 get_target_property(GMP_INCLUDES GMP INTERFACE_INCLUDE_DIRECTORIES)
53 target_include_directories(main PRIVATE ${GMP_INCLUDES})
55 # main-test library is only used for linking against api and unit tests so
56 # that we don't have to include all object files of main into each api/unit
57 # test. Do not link against main-test in any other case.
58 add_library(main-test driver_unified.cpp $<TARGET_OBJECTS:main>)
59 target_compile_definitions(main-test PRIVATE -D__BUILDING_CVC5DRIVER)
60 target_link_libraries(main-test PUBLIC cvc5 cvc5parser)
62 target_link_libraries(main-test PUBLIC CLN)
64 target_link_libraries(main-test PUBLIC GMP)
66 #-----------------------------------------------------------------------------#
67 # cvc5 binary configuration
69 add_executable(cvc5-bin driver_unified.cpp main.cpp $<TARGET_OBJECTS:main>)
70 target_compile_definitions(cvc5-bin PRIVATE -D__BUILDING_CVC5DRIVER)
71 set_target_properties(cvc5-bin
74 RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
75 target_link_libraries(cvc5-bin PUBLIC cvc5 cvc5parser)
77 target_link_libraries(cvc5-bin PUBLIC CLN)
79 target_link_libraries(cvc5-bin PUBLIC GMP)
83 $<TARGET_FILE:cvc5-bin>
84 DESTINATION ${CMAKE_INSTALL_BINDIR}
85 RENAME ${PROGRAM_PREFIX}cvc5)
87 install(TARGETS cvc5-bin
88 DESTINATION ${CMAKE_INSTALL_BINDIR})
91 # In order to get a fully static executable we have to make sure that we also
92 # use the static system libraries.
93 # https://cmake.org/cmake/help/v3.0/prop_tgt/LINK_SEARCH_START_STATIC.html
94 # https://cmake.org/cmake/help/v3.0/prop_tgt/LINK_SEARCH_END_STATIC.html
95 if(ENABLE_STATIC_BINARY)
96 set_target_properties(cvc5-bin PROPERTIES LINK_FLAGS -static)
97 set_target_properties(cvc5-bin PROPERTIES LINK_SEARCH_START_STATIC ON)
98 set_target_properties(cvc5-bin PROPERTIES LINK_SEARCH_END_STATIC ON)
102 target_link_libraries(cvc5-bin PUBLIC ${Editline_LIBRARIES})
103 target_link_libraries(main-test PUBLIC ${Editline_LIBRARIES})
104 target_include_directories(main PUBLIC ${Editline_INCLUDE_DIRS})
107 #-----------------------------------------------------------------------------#
108 # Generate language tokens header files.
110 foreach(lang Cvc Smt2 Tptp)
111 string(TOLOWER ${lang} lang_lc)
113 OUTPUT ${lang_lc}_tokens.h
115 sh ${CMAKE_CURRENT_LIST_DIR}/gen-token-header.sh
116 ${CMAKE_CURRENT_LIST_DIR}/../parser/${lang_lc}/${lang}.g
117 ${CMAKE_CURRENT_BINARY_DIR}/${lang_lc}_tokens.h
118 DEPENDS ../parser/${lang_lc}/${lang}.g
122 # Create target used as a dependency for libmain.
123 add_custom_target(gen-tokens