summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorMathias Preiner <mathias.preiner@gmail.com>2018-09-21 16:27:26 -0700
committerMathias Preiner <mathias.preiner@gmail.com>2018-09-22 16:30:59 -0700
commitb2a89b4488d6665ba23c7cb3108ad4cb8c35f4dc (patch)
tree82b356597e1ac7626aacd1a0596cbd9b6882976c /src/main
parent3b433d829ccfc0d91cb98f368a8896f5ccad1671 (diff)
cmake: Build fully static binaries with option --static.
Diffstat (limited to 'src/main')
-rw-r--r--src/main/CMakeLists.txt21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/main/CMakeLists.txt b/src/main/CMakeLists.txt
index 39c4b2779..30a246ba0 100644
--- a/src/main/CMakeLists.txt
+++ b/src/main/CMakeLists.txt
@@ -16,8 +16,8 @@ set(libmain_src_files
add_library(main OBJECT ${libmain_src_files})
target_compile_definitions(main PRIVATE -D__BUILDING_CVC4DRIVER)
-if(BUILD_SHARED_LIBS)
- set_target_properties(main PROPERTIES POSITION_INDEPENDENT_CODE 1)
+if(ENABLE_SHARED)
+ set_target_properties(main PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()
# We can't use target_link_libraries(...) here since this is only supported for
@@ -26,6 +26,7 @@ endif()
# dependencies are not propagated and we need to manually add the include
# directories of libcvc4 to main.
add_dependencies(main cvc4 cvc4parser gen-tokens)
+get_target_property(LIBCVC4_INCLUDES cvc4 INCLUDE_DIRECTORIES)
target_include_directories(main PRIVATE ${LIBCVC4_INCLUDES})
# main-test library is only used for linking against system and unit tests so
@@ -46,6 +47,16 @@ set_target_properties(cvc4-bin
target_link_libraries(cvc4-bin cvc4 cvc4parser)
install(TARGETS cvc4-bin DESTINATION bin)
+# In order to get a fully static executable we have to make sure that we also
+# use the static system libraries.
+# https://cmake.org/cmake/help/v3.0/prop_tgt/LINK_SEARCH_START_STATIC.html
+# https://cmake.org/cmake/help/v3.0/prop_tgt/LINK_SEARCH_END_STATIC.html
+if(NOT ENABLE_SHARED)
+ set_target_properties(cvc4-bin PROPERTIES LINK_FLAGS -static)
+ set_target_properties(cvc4-bin PROPERTIES LINK_SEARCH_START_STATIC ON)
+ set_target_properties(cvc4-bin PROPERTIES LINK_SEARCH_END_STATIC ON)
+endif()
+
if(ENABLE_PORTFOLIO)
set(pcvc4_src_files
main.cpp
@@ -66,6 +77,12 @@ if(ENABLE_PORTFOLIO)
target_link_libraries(pcvc4-bin cvc4 cvc4parser ${Boost_LIBRARIES})
target_include_directories(pcvc4-bin PRIVATE ${Boost_INCLUDE_DIRS})
install(TARGETS pcvc4-bin DESTINATION bin)
+
+ if(NOT ENABLE_SHARED)
+ set_target_properties(pcvc4-bin PROPERTIES LINK_FLAGS -static)
+ set_target_properties(pcvc4-bin PROPERTIES LINK_SEARCH_START_STATIC ON)
+ set_target_properties(pcvc4-bin PROPERTIES LINK_SEARCH_END_STATIC ON)
+ endif()
endif()
if(USE_READLINE)
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback