Remove public option wrappers (#6716)
[cvc5.git] / src / main / CMakeLists.txt
1 ###############################################################################
2 # Top contributors (to current version):
3 # Mathias Preiner, Gereon Kremer, Aina Niemetz
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 # libmain source files
17 set(libmain_src_files
18 command_executor.cpp
19 interactive_shell.cpp
20 interactive_shell.h
21 main.h
22 signal_handlers.cpp
23 signal_handlers.h
24 time_limit.cpp
25 time_limit.h
26 )
27
28 #-----------------------------------------------------------------------------#
29 # Build object library since we will use the object files for cvc5-bin and
30 # main-test library.
31
32 add_library(main OBJECT ${libmain_src_files})
33 target_compile_definitions(main PRIVATE -D__BUILDING_CVC5DRIVER)
34 if(ENABLE_SHARED)
35 set_target_properties(main PROPERTIES POSITION_INDEPENDENT_CODE ON)
36 endif()
37
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)
44
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.
48 if(USE_CLN)
49 get_target_property(CLN_INCLUDES CLN INTERFACE_INCLUDE_DIRECTORIES)
50 target_include_directories(main PRIVATE ${CLN_INCLUDES})
51 endif()
52 get_target_property(GMP_INCLUDES GMP INTERFACE_INCLUDE_DIRECTORIES)
53 target_include_directories(main PRIVATE ${GMP_INCLUDES})
54
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)
61 if(USE_CLN)
62 target_link_libraries(main-test PUBLIC CLN)
63 endif()
64 target_link_libraries(main-test PUBLIC GMP)
65
66 #-----------------------------------------------------------------------------#
67 # cvc5 binary configuration
68
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
72 PROPERTIES
73 OUTPUT_NAME cvc5
74 RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
75 target_link_libraries(cvc5-bin PUBLIC cvc5 cvc5parser)
76 if(USE_CLN)
77 target_link_libraries(cvc5-bin PUBLIC CLN)
78 endif()
79 target_link_libraries(cvc5-bin PUBLIC GMP)
80
81 if(PROGRAM_PREFIX)
82 install(PROGRAMS
83 $<TARGET_FILE:cvc5-bin>
84 DESTINATION ${CMAKE_INSTALL_BINDIR}
85 RENAME ${PROGRAM_PREFIX}cvc5)
86 else()
87 install(TARGETS cvc5-bin
88 DESTINATION ${CMAKE_INSTALL_BINDIR})
89 endif()
90
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)
99 endif()
100
101 if(USE_EDITLINE)
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})
105 endif()
106
107 #-----------------------------------------------------------------------------#
108 # Generate language tokens header files.
109
110 foreach(lang Cvc Smt2 Tptp)
111 string(TOLOWER ${lang} lang_lc)
112 add_custom_command(
113 OUTPUT ${lang_lc}_tokens.h
114 COMMAND
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
119 )
120 endforeach()
121
122 # Create target used as a dependency for libmain.
123 add_custom_target(gen-tokens
124 DEPENDS
125 cvc_tokens.h
126 smt2_tokens.h
127 tptp_tokens.h
128 )
129