summaryrefslogtreecommitdiff
path: root/cmake/FindKissat.cmake
blob: 08b214961454133d474bf481804d1f7cb4b1e4e2 (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
###############################################################################
# Top contributors (to current version):
#   Gereon Kremer, Aina Niemetz
#
# This file is part of the cvc5 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 Kissat
# Kissat_FOUND - found Kissat lib
# Kissat_INCLUDE_DIR - the Kissat include directory
# Kissat_LIBRARIES - Libraries needed to use Kissat
##

include(deps-helper)

find_path(Kissat_INCLUDE_DIR NAMES kissat/kissat.h)
find_library(Kissat_LIBRARIES NAMES kissat)

set(Kissat_FOUND_SYSTEM FALSE)
if(Kissat_INCLUDE_DIR AND Kissat_LIBRARIES)
  set(Kissat_FOUND_SYSTEM TRUE)

  # Unfortunately it is not part of the headers
  find_library(Kissat_BINARY NAMES kissat)
  if(Kissat_BINARY)
    execute_process(
      COMMAND ${Kissat_BINARY} --version OUTPUT_VARIALE Kissat_VERSION
    )
  else()
    set(Kissat_VERSION "")
  endif()

  check_system_version("Kissat")
endif()

if(NOT Kissat_FOUND_SYSTEM)
  check_ep_downloaded("Kissat-EP")
  if(NOT Kissat-EP_DOWNLOADED)
    check_auto_download("Kissat" "--no-kissat")
  endif()

  include(ExternalProject)

  fail_if_include_missing("sys/resource.h" "Kissat")

  # TODO(mpreiner): use the version from github?
  set(Kissat_VERSION "sc2020-039805f2")

  ExternalProject_Add(
    Kissat-EP
    ${COMMON_EP_CONFIG}
    BUILD_IN_SOURCE ON
    URL http://fmv.jku.at/kissat/kissat-${Kissat_VERSION}.tar.xz
    URL_HASH SHA1=5125efa17d383c7e7c1e6d803e3422b17cebcedb
    CONFIGURE_COMMAND <SOURCE_DIR>/configure -fPIC --quiet
                      CC=${CMAKE_C_COMPILER}
    INSTALL_COMMAND ${CMAKE_COMMAND} -E copy <SOURCE_DIR>/build/libkissat.a
                    <INSTALL_DIR>/lib/libkissat.a
    COMMAND ${CMAKE_COMMAND} -E copy <SOURCE_DIR>/src/kissat.h
            <INSTALL_DIR>/include/kissat/kissat.h
  )

  set(Kissat_INCLUDE_DIR "${DEPS_BASE}/include/")
  set(Kissat_LIBRARIES "${DEPS_BASE}/lib/libkissat.a")
endif()

set(Kissat_FOUND TRUE)

add_library(Kissat STATIC IMPORTED GLOBAL)
set_target_properties(Kissat PROPERTIES IMPORTED_LOCATION "${Kissat_LIBRARIES}")
set_target_properties(
  Kissat PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${Kissat_INCLUDE_DIR}"
)

mark_as_advanced(Kissat_FOUND)
mark_as_advanced(Kissat_FOUND_SYSTEM)
mark_as_advanced(Kissat_INCLUDE_DIR)
mark_as_advanced(Kissat_LIBRARIES)

if(Kissat_FOUND_SYSTEM)
  message(STATUS "Found Kissat ${Kissat_VERSION}: ${Kissat_LIBRARIES}")
else()
  message(STATUS "Building Kissat ${Kissat_VERSION}: ${Kissat_LIBRARIES}")
  add_dependencies(Kissat Kissat-EP)
endif()
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback