summaryrefslogtreecommitdiff
path: root/cmake/FindCryptoMiniSat.cmake
blob: 92b351ef236176a3fbde100e05a795a190f435ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#####################
## FindCryptoMiniSat.cmake
## Top contributors (to current version):
##   Mathias Preiner
## This file is part of the CVC4 project.
## Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
## in the top-level source directory and their institutional affiliations.
## All rights reserved.  See the file COPYING in the top-level source
## directory for licensing information.
##
# Find CryptoMiniSat
# CryptoMiniSat_FOUND - system has CryptoMiniSat lib
# CryptoMiniSat_INCLUDE_DIR - the CryptoMiniSat include directory
# CryptoMiniSat_LIBRARIES - Libraries needed to use CryptoMiniSat

include(deps-helper)

find_package(cryptominisat5 ${CryptoMiniSat_FIND_VERSION} QUIET)

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}"
  )

endif()

if(NOT CryptoMiniSat_FOUND_SYSTEM)
  include(ExternalProject)

  set(CryptoMiniSat_VERSION "5.8.0")

  ExternalProject_Add(
    CryptoMiniSat-EP
    ${COMMON_EP_CONFIG}
    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