Skip to content

Commit

Permalink
CMakeLists: make static lib optional
Browse files Browse the repository at this point in the history
Build static lib only if BUILD_STATIC_LIBS is specified.
  • Loading branch information
Jiri Slaby committed Nov 4, 2019
1 parent c65ff70 commit 295a4a7
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ project(minisat)
# Configurable options:

option(STATIC_BINARIES "Link binaries statically." ON)
option(BUILD_STATIC_LIBS "Build static library." ON)
option(USE_SORELEASE "Use SORELEASE in shared library filename." ON)

#--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -51,11 +52,19 @@ set(MINISAT_LIB_SOURCES
minisat/core/Solver.cc
minisat/simp/SimpSolver.cc)

add_library(minisat-lib-static STATIC ${MINISAT_LIB_SOURCES})
add_library(minisat-lib-shared SHARED ${MINISAT_LIB_SOURCES})
if (BUILD_STATIC_LIBS OR STATIC_BINARIES)
add_library(minisat-lib-static STATIC ${MINISAT_LIB_SOURCES})
target_link_libraries(minisat-lib-static ${ZLIB_LIBRARY})
set_target_properties(minisat-lib-static PROPERTIES OUTPUT_NAME "minisat")
endif()

add_library(minisat-lib-shared SHARED ${MINISAT_LIB_SOURCES})
target_link_libraries(minisat-lib-shared ${ZLIB_LIBRARY})
target_link_libraries(minisat-lib-static ${ZLIB_LIBRARY})
set_target_properties(minisat-lib-shared
PROPERTIES
OUTPUT_NAME "minisat"
VERSION ${MINISAT_VERSION}
SOVERSION ${MINISAT_SOVERSION})

add_executable(minisat_core minisat/core/Main.cc)
add_executable(minisat_simp minisat/simp/Main.cc)
Expand All @@ -68,21 +77,19 @@ else()
target_link_libraries(minisat_simp minisat-lib-shared)
endif()

set_target_properties(minisat-lib-static PROPERTIES OUTPUT_NAME "minisat")
set_target_properties(minisat-lib-shared
PROPERTIES
OUTPUT_NAME "minisat"
VERSION ${MINISAT_VERSION}
SOVERSION ${MINISAT_SOVERSION})

set_target_properties(minisat_simp PROPERTIES OUTPUT_NAME "minisat")

#--------------------------------------------------------------------------------------------------
# Installation targets:

set(CMAKE_INSTALL_LIBDIR lib CACHE STRING "Output directory for libraries")

install(TARGETS minisat-lib-static minisat-lib-shared minisat_core minisat_simp
if (BUILD_STATIC_LIBS)
install(TARGETS minisat-lib-static
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()

install(TARGETS minisat-lib-shared minisat_core minisat_simp
RUNTIME DESTINATION bin
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
Expand Down

0 comments on commit 295a4a7

Please sign in to comment.