Skip to content

Commit 0ca29d8

Browse files
authored
Merge pull request #7644 from tautschnig/features/cmake-minisat-system
CMake build system: support system-provided MiniSat
2 parents 6ff62a7 + d8646ca commit 0ca29d8

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/libcprover-cpp/CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,16 @@ 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+
else()
67+
find_library(dep_path ${dep})
68+
string(REGEX REPLACE "[.]so$" ".a" dep_static_path ${dep_path})
69+
if (NOT EXISTS "${dep_static_path}")
70+
message(FATAL_ERROR "libcprover-cpp cannot be linked as dependency ${dep_path} does not have a static correspondent file (${dep_static_path})")
71+
endif()
72+
list(APPEND DEPENDENCY_TARGETS ${dep_static_path})
73+
endif()
6574
endforeach(dep LIBRARY_DEPENDENCIES)
6675
string(REPLACE ";" " " DEPENDENCY_TARGETS "${DEPENDENCY_TARGETS}")
6776

src/solvers/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,20 @@ 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+
find_path(minisat_header_found "minisat/simp/SimpSolver.h")
95+
if(minisat_header_found)
96+
message(STATUS "Building solvers with minisat2 (${minisat_header_found})")
97+
target_compile_definitions(solvers PUBLIC SATCHECK_MINISAT2 HAVE_MINISAT2)
98+
target_sources(solvers PRIVATE ${minisat2_source})
99+
target_include_directories(solvers PRIVATE ${minisat_header_found})
100+
target_link_libraries(solvers minisat)
101+
else()
102+
message(FATAL_ERROR "Unable to find header file for preinstalled minisat2")
103+
endif()
90104
elseif("${SOLVER}" STREQUAL "glucose")
91105
message(STATUS "Building solvers with glucose")
92106

0 commit comments

Comments
 (0)