summaryrefslogtreecommitdiff
path: root/src/parser/CMakeLists.txt
diff options
context:
space:
mode:
authorGereon Kremer <nafur42@gmail.com>2021-09-30 12:15:24 -0700
committerGitHub <noreply@github.com>2021-09-30 19:15:24 +0000
commit65e5a909b10855d2e6b3844f7bc4efb7fbe4fe2f (patch)
treebb541a32e3985be59ffdc323038677bbace24ede /src/parser/CMakeLists.txt
parent5a824c9e67789a529e34b7e2a7229986412bf979 (diff)
Refactor our static builds (#7251)
This PR does a major refactoring on how we organize our builds to allow both shared and static builds. We now build the libraries using object libraries to allow building the libraries both dynamically and statically in the same build folder, though the static library is optional (ENABLE_STATIC_LIBRARY). The binary is linked either dynamically or statically (depending on ENABLE_STATIC_BINARY).
Diffstat (limited to 'src/parser/CMakeLists.txt')
-rw-r--r--src/parser/CMakeLists.txt29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/parser/CMakeLists.txt b/src/parser/CMakeLists.txt
index 589bfad1f..32ddfee52 100644
--- a/src/parser/CMakeLists.txt
+++ b/src/parser/CMakeLists.txt
@@ -98,16 +98,33 @@ endforeach()
#-----------------------------------------------------------------------------#
# libcvc5parser configuration
-add_library(cvc5parser ${libcvc5parser_src_files})
-set_target_properties(cvc5parser PROPERTIES SOVERSION ${CVC5_SOVERSION})
-target_compile_definitions(cvc5parser PRIVATE -D__BUILDING_CVC5PARSERLIB)
-target_link_libraries(cvc5parser PUBLIC cvc5)
-target_link_libraries(cvc5parser PRIVATE ANTLR3)
+add_library(cvc5parser-objs OBJECT ${libcvc5parser_src_files})
+set_target_properties(cvc5parser-objs PROPERTIES POSITION_INDEPENDENT_CODE ON)
+target_compile_definitions(cvc5parser-objs PUBLIC -D__BUILDING_CVC5PARSERLIB)
+target_link_libraries(cvc5parser-objs PRIVATE ANTLR3)
-install(TARGETS cvc5parser
+
+add_library(cvc5parser-shared SHARED)
+set_target_properties(cvc5parser-shared PROPERTIES SOVERSION ${CVC5_SOVERSION})
+set_target_properties(cvc5parser-shared PROPERTIES OUTPUT_NAME cvc5parser)
+target_link_libraries(cvc5parser-shared PRIVATE cvc5-shared)
+target_link_libraries(cvc5parser-shared PRIVATE cvc5parser-objs)
+
+install(TARGETS cvc5parser-shared
EXPORT cvc5-targets
DESTINATION ${CMAKE_INSTALL_LIBDIR})
+if(ENABLE_STATIC_LIBRARY)
+ add_library(cvc5parser-static STATIC)
+ set_target_properties(cvc5parser-static PROPERTIES OUTPUT_NAME cvc5parser)
+ target_link_libraries(cvc5parser-static PRIVATE cvc5parser-objs)
+ target_link_libraries(cvc5parser-static PRIVATE cvc5-static)
+
+ install(TARGETS cvc5parser-objs cvc5parser-static
+ EXPORT cvc5-targets
+ DESTINATION ${CMAKE_INSTALL_LIBDIR})
+endif()
+
# The generated lexer/parser files define some functions as
# __declspec(dllexport) via the ANTLR3_API macro, which leads to lots of
# unresolved symbols when linking against libcvc5parser.
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback