summaryrefslogtreecommitdiff
path: root/cmake/FindCryptoMiniSat.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/FindCryptoMiniSat.cmake')
-rw-r--r--cmake/FindCryptoMiniSat.cmake92
1 files changed, 83 insertions, 9 deletions
diff --git a/cmake/FindCryptoMiniSat.cmake b/cmake/FindCryptoMiniSat.cmake
index 821511fdd..318907797 100644
--- a/cmake/FindCryptoMiniSat.cmake
+++ b/cmake/FindCryptoMiniSat.cmake
@@ -13,16 +13,90 @@
# CryptoMiniSat_INCLUDE_DIR - the CryptoMiniSat include directory
# CryptoMiniSat_LIBRARIES - Libraries needed to use CryptoMiniSat
+include(deps-helper)
-find_path(CryptoMiniSat_INCLUDE_DIR NAMES cryptominisat5/cryptominisat.h)
-find_library(CryptoMiniSat_LIBRARIES NAMES cryptominisat5)
+find_package(cryptominisat5 ${CryptoMiniSat_FIND_VERSION} QUIET)
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(CryptoMiniSat
- DEFAULT_MSG
- CryptoMiniSat_INCLUDE_DIR CryptoMiniSat_LIBRARIES)
+set(CryptoMiniSat_FOUND_SYSTEM FALSE)
+if(cryptominisat5_FOUND)
+ set(CryptoMiniSat_FOUND_SYSTEM TRUE)
+ add_library(CryptoMiniSat INTERFACE IMPORTED GLOBAL)
+ target_link_libraries(CryptoMiniSat INTERFACE cryptominisat5)
+ # TODO(gereon): remove this when
+ # https://github.com/msoos/cryptominisat/pull/645 is merged
+ set_target_properties(
+ CryptoMiniSat PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
+ "${CRYPTOMINISAT5_INCLUDE_DIRS}"
+ )
-mark_as_advanced(CryptoMiniSat_INCLUDE_DIR CryptoMiniSat_LIBRARIES)
-if(CryptoMiniSat_LIBRARIES)
- message(STATUS "Found CryptoMiniSat libs: ${CryptoMiniSat_LIBRARIES}")
+endif()
+
+if(NOT CryptoMiniSat_FOUND_SYSTEM)
+ include(ExternalProject)
+
+ set(CryptoMiniSat_VERSION "5.8.0")
+
+ ExternalProject_Add(
+ CryptoMiniSat-EP
+ PREFIX ${DEPS_PREFIX}
+ URL https://github.com/msoos/cryptominisat/archive/refs/tags/${CryptoMiniSat_VERSION}.tar.gz
+ URL_HASH SHA1=f79dfa1ffc6c9c75b3a33f76d3a89a3df2b3f4c2
+ PATCH_COMMAND
+ patch <SOURCE_DIR>/src/packedmatrix.h
+ ${CMAKE_CURRENT_LIST_DIR}/deps-utils/CryptoMiniSat-patch-ba6f76e3.patch
+ CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release
+ # make sure not to register with cmake
+ -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON
+ -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
+ -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
+ -DENABLE_ASSERTIONS=OFF
+ -DENABLE_PYTHON_INTERFACE=OFF
+ # disable what is not needed
+ -DNOBREAKID=ON
+ -DNOM4RI=ON
+ -DNOSQLITE=ON
+ -DNOZLIB=ON
+ -DONLY_SIMPLE=ON
+ -DSTATICCOMPILE=ON
+ BUILD_BYPRODUCTS <INSTALL_DIR>/lib/libcryptominisat5.a
+ )
+ # remove unused stuff to keep folder small
+ ExternalProject_Add_Step(
+ CryptoMiniSat-EP cleanup
+ DEPENDEES install
+ COMMAND ${CMAKE_COMMAND} -E remove <BINARY_DIR>/cryptominisat5_simple
+ COMMAND ${CMAKE_COMMAND} -E remove <INSTALL_DIR>/bin/cryptominisat5_simple
+ )
+
+ set(CryptoMiniSat_INCLUDE_DIR "${DEPS_BASE}/include/")
+ set(CryptoMiniSat_LIBRARIES "${DEPS_BASE}/lib/libcryptominisat5.a")
+
+ add_library(CryptoMiniSat STATIC IMPORTED GLOBAL)
+ set_target_properties(
+ CryptoMiniSat PROPERTIES IMPORTED_LOCATION "${CryptoMiniSat_LIBRARIES}"
+ )
+ set_target_properties(
+ CryptoMiniSat PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
+ "${CryptoMiniSat_INCLUDE_DIR}"
+ )
+endif()
+
+set(CryptoMiniSat_FOUND TRUE)
+
+mark_as_advanced(CryptoMiniSat_FOUND)
+mark_as_advanced(CryptoMiniSat_FOUND_SYSTEM)
+mark_as_advanced(CryptoMiniSat_INCLUDE_DIR)
+mark_as_advanced(CryptoMiniSat_LIBRARIES)
+
+if(CryptoMiniSat_FOUND_SYSTEM)
+ message(
+ STATUS
+ "Found CryptoMiniSat ${CryptoMiniSat_VERSION}: ${CryptoMiniSat_LIBRARIES}"
+ )
+else()
+ message(
+ STATUS
+ "Building CryptoMiniSat ${CryptoMiniSat_VERSION}: ${CryptoMiniSat_LIBRARIES}"
+ )
+ add_dependencies(CryptoMiniSat CryptoMiniSat-EP)
endif()
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback