--- src/CMakeLists.txt.orig 2020-09-10 12:51:28.000000000 -0600 +++ src/CMakeLists.txt 2020-11-04 20:46:35.000000000 -0700 @@ -113,6 +113,7 @@ set(lib_type "STATIC") endif() add_library(libz3 ${lib_type} ${object_files}) +add_library(libz3-static STATIC ${object_files}) target_include_directories(libz3 INTERFACE $ $) @@ -127,6 +128,11 @@ VERSION ${Z3_VERSION} SOVERSION ${Z3_VERSION_MAJOR}.${Z3_VERSION_MINOR}) +set_target_properties(libz3-static PROPERTIES + VERSION ${Z3_VERSION} + SOVERSION ${Z3_VERSION_MAJOR}.${Z3_VERSION_MINOR}) +set_target_properties(libz3-static PROPERTIES OUTPUT_NAME z3) + if (NOT MSVC) # On UNIX like platforms if we don't change the OUTPUT_NAME # the library gets a name like ``liblibz3.so`` so we change it @@ -141,6 +147,7 @@ # shared library the dependent libraries are specified on the link command line # so that if those are also shared libraries they are referenced by `libz3.so`. target_link_libraries(libz3 PRIVATE ${Z3_DEPENDENT_LIBS}) +target_link_libraries(libz3-static PRIVATE ${Z3_DEPENDENT_LIBS}) # This is currently only for the OpenMP flags. It needs to be set # via `target_link_libraries()` rather than `z3_append_linker_flag_list_to_target()` @@ -148,6 +155,7 @@ # the link dependencies need to be exported too. foreach (flag_name ${Z3_DEPENDENT_EXTRA_CXX_LINK_FLAGS}) target_link_libraries(libz3 PRIVATE ${flag_name}) + target_link_libraries(libz3-static PRIVATE ${flag_name}) endforeach() # Declare which header file are the public header files of libz3 @@ -174,7 +182,7 @@ set_property(TARGET libz3 APPEND PROPERTY PUBLIC_HEADER "${CMAKE_CURRENT_BINARY_DIR}/util/z3_version.h") -install(TARGETS libz3 +install(TARGETS libz3 libz3-static EXPORT Z3_EXPORTED_TARGETS LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" # On Windows this installs ``libz3.lib`` which CMake calls the "corresponding import library". Do we want this installed?