Skip to content

Commit 5ce5e2e

Browse files
committed
CMake build system: support system-provided MiniSat
Some operating systems provide packaged versions of MiniSat. When building distribution packages it may then be preferable to use the pre-installed library instead of building the solver object from scratch. With this patch it is now possible to select "system-minisat2" as a solver, alongside any other solvers that may be built from scratch.
1 parent 40401ce commit 5ce5e2e

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/libcprover-cpp/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ target_link_libraries(cprover-api-cpp
6161
# Here we prepare a space-separated list of cmake generators that will resolved in absolute paths.
6262
set(DEPENDENCY_TARGETS "")
6363
foreach(dep ${LIBRARY_DEPENDENCIES})
64-
list(APPEND DEPENDENCY_TARGETS "$<TARGET_FILE:${dep}>")
64+
if(TARGET ${dep})
65+
list(APPEND DEPENDENCY_TARGETS "$<TARGET_FILE:${dep}>")
66+
endif()
6567
endforeach(dep LIBRARY_DEPENDENCIES)
6668
string(REPLACE ";" " " DEPENDENCY_TARGETS "${DEPENDENCY_TARGETS}")
6769

src/solvers/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,17 @@ foreach(SOLVER ${sat_impl})
8787
target_sources(solvers PRIVATE ${minisat2_source})
8888

8989
target_link_libraries(solvers minisat2-condensed)
90+
elseif("${SOLVER}" STREQUAL "system-minisat2")
91+
include(CheckIncludeFileCXX)
92+
# if/when we move to CMake 3.12 (or later) we could also check for the
93+
# library via CMAKE_REQUIRED_LIBRARIES
94+
CHECK_INCLUDE_FILE_CXX("minisat/simp/SimpSolver.h" minisat_header_found)
95+
if(${minisat_header_found})
96+
message(STATUS "Building solvers with minisat2 (pre-built)")
97+
target_compile_definitions(solvers PUBLIC SATCHECK_MINISAT2 HAVE_MINISAT2)
98+
target_sources(solvers PRIVATE ${minisat2_source})
99+
target_link_libraries(solvers minisat)
100+
endif()
90101
elseif("${SOLVER}" STREQUAL "glucose")
91102
message(STATUS "Building solvers with glucose")
92103

0 commit comments

Comments
 (0)