-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
150 lines (127 loc) · 3.7 KB
/
Copy pathCMakeLists.txt
File metadata and controls
150 lines (127 loc) · 3.7 KB
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
cmake_minimum_required(VERSION 3.15...3.27)
project(kompyle LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
if(APPLE)
set(RPATH_ORIGIN "@loader_path")
else()
set(RPATH_ORIGIN "$ORIGIN")
endif()
# -----------------------------------------------
# DEPENDENCIES
# -----------------------------------------------
find_package(Python 3.10
REQUIRED COMPONENTS Interpreter Development.Module
OPTIONAL_COMPONENTS Development.SABIModule)
find_package(Boost CONFIG REQUIRED COMPONENTS program_options)
find_package(nanobind CONFIG REQUIRED)
find_package(klay CONFIG REQUIRED)
find_package(cryptominisat5 MODULE REQUIRED)
find_package(arjun MODULE REQUIRED)
find_package(ganak MODULE REQUIRED)
find_package(sbva MODULE REQUIRED)
find_package(breakid MODULE REQUIRED)
find_package(approxmc MODULE REQUIRED)
find_package(md4 MODULE REQUIRED)
find_package(GMP MODULE REQUIRED)
find_package(cadical MODULE REQUIRED)
find_package(cadiback MODULE REQUIRED)
# -----------------------------------------------
# LIBRARY KOMPYLE
# -----------------------------------------------
set(dependencies
klay
cryptominisat5
arjun
ganak
sbva::sbva
breakid::breakid
approxmc::approxmc
cadical::cadical
cadiback::cadiback
md4::d4
)
add_library(kompyle SHARED
src/kcircuit.cc
src/d4/compile.cc
src/d4/gated_formula.cc
src/d4/internal.cc
src/d4/d4_stats.cc
src/ganak/circuit_field.cc
src/ganak/compile.cc
src/ganak/internal.cc
)
target_include_directories(kompyle
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE
${CMAKE_SOURCE_DIR}/src
)
target_link_libraries(kompyle
PUBLIC
klay
PRIVATE
cryptominisat5
arjun
ganak
sbva::sbva
breakid::breakid
approxmc::approxmc
cadical::cadical
cadiback::cadiback
md4::d4
GMP::gmp
Boost::program_options
)
set_target_properties(kompyle PROPERTIES
INSTALL_RPATH "${RPATH_ORIGIN}"
INSTALL_RPATH_USE_LINK_PATH TRUE
)
install(TARGETS kompyle LIBRARY DESTINATION kompyle)
# -----------------------------------------------
# PYTHON KOMPYLE EXTENSION
# -----------------------------------------------
nanobind_add_module(pkompyle
STABLE_ABI
NOMINSIZE
NB_STATIC
src/python/module.cc
src/python/circuit_bindings.cc
src/python/gated_formula_bindings.cc
src/python/compile_bindings.cc
src/python/stats_bindings.cc
)
target_include_directories(pkompyle
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
)
target_link_libraries(pkompyle
PRIVATE
kompyle
klay
GMP::gmp
)
set_target_properties(pkompyle PROPERTIES
INSTALL_RPATH "${RPATH_ORIGIN}"
INSTALL_RPATH_USE_LINK_PATH TRUE
)
install(TARGETS pkompyle LIBRARY DESTINATION kompyle)
# -----------------------------------------------
# PYTHON KOMPYLE EXTENSION STUBS
# -----------------------------------------------
# https://nanobind.readthedocs.io/en/latest/typing.html#cmake-interface
nanobind_add_stub(
pkompyle_stub
MODULE pkompyle
OUTPUT pkompyle.pyi
PYTHON_PATH $<TARGET_FILE_DIR:pkompyle>
DEPENDS pkompyle kompyle
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/pkompyle.pyi"
DESTINATION kompyle
)