[proofs] Adding NoSubtype node converter to Alethe (#7587)
[cvc5.git] / cmake / FindCryptoMiniSat.cmake
1 ###############################################################################
2 # Top contributors (to current version):
3 # Gereon Kremer, Mathias Preiner
4 #
5 # This file is part of the cvc5 project.
6 #
7 # Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
8 # in the top-level source directory and their institutional affiliations.
9 # All rights reserved. See the file COPYING in the top-level source
10 # directory for licensing information.
11 # #############################################################################
12 #
13 # Find CryptoMiniSat
14 # CryptoMiniSat_FOUND - system has CryptoMiniSat lib
15 # CryptoMiniSat_INCLUDE_DIR - the CryptoMiniSat include directory
16 # CryptoMiniSat_LIBRARIES - Libraries needed to use CryptoMiniSat
17 ##
18
19 include(deps-helper)
20
21 find_package(cryptominisat5 ${CryptoMiniSat_FIND_VERSION} QUIET)
22
23 set(CryptoMiniSat_FOUND_SYSTEM FALSE)
24 if(cryptominisat5_FOUND)
25 set(CryptoMiniSat_VERSION ${cryptominisat5_VERSION})
26 set(CryptoMiniSat_FOUND_SYSTEM TRUE)
27 add_library(CryptoMiniSat INTERFACE IMPORTED GLOBAL)
28 target_link_libraries(CryptoMiniSat INTERFACE cryptominisat5)
29 # TODO(gereon): remove this when
30 # https://github.com/msoos/cryptominisat/pull/645 is merged
31 set_target_properties(
32 CryptoMiniSat PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
33 "${CRYPTOMINISAT5_INCLUDE_DIRS}"
34 )
35 endif()
36
37 if(NOT CryptoMiniSat_FOUND_SYSTEM)
38 set(CryptoMiniSat_VERSION "5.8.0")
39
40 check_ep_downloaded("CryptoMiniSat-EP")
41 if(NOT CryptoMiniSat-EP_DOWNLOADED)
42 check_auto_download("CryptoMiniSat" "--no-cryptominisat")
43 endif()
44
45 include(ExternalProject)
46
47 if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
48 set(LIBFILENAME "libcryptominisat5win")
49 else()
50 set(LIBFILENAME "libcryptominisat5")
51 endif()
52
53 ExternalProject_Add(
54 CryptoMiniSat-EP
55 ${COMMON_EP_CONFIG}
56 URL https://github.com/msoos/cryptominisat/archive/refs/tags/${CryptoMiniSat_VERSION}.tar.gz
57 URL_HASH SHA1=f79dfa1ffc6c9c75b3a33f76d3a89a3df2b3f4c2
58 PATCH_COMMAND
59 patch <SOURCE_DIR>/src/packedmatrix.h
60 ${CMAKE_CURRENT_LIST_DIR}/deps-utils/CryptoMiniSat-patch-ba6f76e3.patch
61 CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release
62 # make sure not to register with cmake
63 -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON
64 -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
65 -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
66 -DENABLE_ASSERTIONS=OFF
67 -DENABLE_PYTHON_INTERFACE=OFF
68 # disable what is not needed
69 -DNOBREAKID=ON
70 -DNOM4RI=ON
71 -DNOSQLITE=ON
72 -DNOZLIB=ON
73 -DONLY_SIMPLE=ON
74 -DSTATICCOMPILE=ON
75 BUILD_BYPRODUCTS <INSTALL_DIR>/${CMAKE_INSTALL_LIBDIR}/libcryptominisat5.a
76 )
77 # remove unused stuff to keep folder small
78 ExternalProject_Add_Step(
79 CryptoMiniSat-EP cleanup
80 DEPENDEES install
81 COMMAND ${CMAKE_COMMAND} -E remove <BINARY_DIR>/cryptominisat5_simple
82 COMMAND ${CMAKE_COMMAND} -E remove <INSTALL_DIR>/bin/cryptominisat5_simple
83 )
84
85 set(CryptoMiniSat_INCLUDE_DIR "${DEPS_BASE}/include/")
86 set(CryptoMiniSat_LIBRARIES "${DEPS_BASE}/${CMAKE_INSTALL_LIBDIR}/${LIBFILENAME}.a")
87
88 add_library(CryptoMiniSat STATIC IMPORTED GLOBAL)
89 set_target_properties(
90 CryptoMiniSat PROPERTIES IMPORTED_LOCATION "${CryptoMiniSat_LIBRARIES}"
91 )
92 set_target_properties(
93 CryptoMiniSat PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
94 "${CryptoMiniSat_INCLUDE_DIR}"
95 )
96 endif()
97
98 set(CryptoMiniSat_FOUND TRUE)
99
100 mark_as_advanced(CryptoMiniSat_FOUND)
101 mark_as_advanced(CryptoMiniSat_FOUND_SYSTEM)
102 mark_as_advanced(CryptoMiniSat_INCLUDE_DIR)
103 mark_as_advanced(CryptoMiniSat_LIBRARIES)
104
105 if(CryptoMiniSat_FOUND_SYSTEM)
106 message(
107 STATUS
108 "Found CryptoMiniSat ${CryptoMiniSat_VERSION}: ${CryptoMiniSat_LIBRARIES}"
109 )
110 else()
111 message(
112 STATUS
113 "Building CryptoMiniSat ${CryptoMiniSat_VERSION}: ${CryptoMiniSat_LIBRARIES}"
114 )
115 add_dependencies(CryptoMiniSat CryptoMiniSat-EP)
116 endif()