forked from CQCL/tket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
202 lines (172 loc) · 6.64 KB
/
CMakeLists.txt
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# Copyright 2019-2024 Cambridge Quantum Computing
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.23)
project(pytket CXX)
add_definitions(-DPYBIND11_DETAILED_ERROR_MESSAGES)
find_package(Boost CONFIG REQUIRED)
find_package(Eigen3 CONFIG REQUIRED)
find_package(gmp CONFIG)
if (NOT gmp_FOUND)
find_package(PkgConfig REQUIRED)
pkg_search_module(gmp REQUIRED IMPORTED_TARGET gmp)
endif()
find_package(pybind11 CONFIG REQUIRED)
find_package(pybind11_json CONFIG REQUIRED)
find_package(SymEngine CONFIG REQUIRED)
find_package(tkassert CONFIG REQUIRED)
find_package(tkassert CONFIG REQUIRED)
find_package(tket CONFIG REQUIRED)
find_package(tklog CONFIG REQUIRED)
find_package(tkrng CONFIG REQUIRED)
find_package(tktokenswap CONFIG REQUIRED)
find_package(tkwsm CONFIG REQUIRED)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_EXTENSIONS OFF)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_BINARY_DIR}")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(Boost_NO_BOOST_CMAKE ON)
if (WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /WX")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -Wunreachable-code -Wunused")
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "(Apple)?Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
# remove -Wno-deprecated-declarations once https://github.com/boostorg/boost/issues/688 is resolved
endif()
if (UNIX)
# Allow binder libraries to load other shared libraries from same directory.
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH "\${ORIGIN}")
endif()
if (NOT TARGET pybind11_json::pybind11_json)
add_library(pybind11_json::pybind11_json ALIAS pybind11_json)
endif()
if (NOT TARGET gmp::gmp)
add_library(gmp::gmp ALIAS PkgConfig::gmp)
endif()
if (NOT TARGET symengine::symengine)
add_library(symengine::symengine ALIAS symengine)
endif()
list(APPEND lib_deps
Eigen3::Eigen
gmp::gmp
pybind11::headers
pybind11_json::pybind11_json
symengine::symengine
tkassert::tkassert
tket::tket
tklog::tklog
)
if (WIN32)
list(APPEND lib_deps bcrypt) # For boost::uuid
endif()
if (APPLE)
list(APPEND lib_deps "-flat_namespace")
endif()
set(HEADER_FILES
binders/include/add_gate.hpp
binders/include/binder_json.hpp
binders/include/binder_utils.hpp
binders/include/circuit_registers.hpp
binders/include/deleted_hash.hpp
binders/include/py_operators.hpp
binders/include/typecast.hpp
binders/include/unit_downcast.hpp
binders/include/UnitRegister.hpp
)
pybind11_add_module(circuit
binders/circuit/boxes.cpp
binders/circuit/Circuit/add_classical_op.cpp
binders/circuit/Circuit/add_op.cpp
binders/circuit/Circuit/main.cpp
binders/circuit/classical.cpp
binders/circuit/clexpr.cpp
binders/circuit/main.cpp
${HEADER_FILES})
target_include_directories(circuit PRIVATE binders/include)
target_link_libraries(circuit PRIVATE ${lib_deps})
pybind11_add_module(circuit_library binders/circuit_library.cpp ${HEADER_FILES})
target_include_directories(circuit_library PRIVATE binders/include)
target_link_libraries(circuit_library PRIVATE ${lib_deps})
pybind11_add_module(unit_id binders/unitid.cpp ${HEADER_FILES})
target_include_directories(unit_id PRIVATE binders/include)
target_link_libraries(unit_id PRIVATE ${lib_deps})
pybind11_add_module(mapping binders/mapping.cpp ${HEADER_FILES})
target_include_directories(mapping PRIVATE binders/include)
target_link_libraries(mapping PRIVATE ${lib_deps})
pybind11_add_module(transform binders/transform.cpp ${HEADER_FILES})
target_include_directories(transform PRIVATE binders/include)
target_link_libraries(transform PRIVATE ${lib_deps})
pybind11_add_module(predicates binders/predicates.cpp ${HEADER_FILES})
target_include_directories(predicates PRIVATE binders/include)
target_link_libraries(predicates PRIVATE ${lib_deps})
pybind11_add_module(passes binders/passes.cpp ${HEADER_FILES})
target_include_directories(passes PRIVATE binders/include)
target_link_libraries(passes PRIVATE ${lib_deps})
pybind11_add_module(architecture binders/architecture.cpp ${HEADER_FILES})
target_include_directories(architecture PRIVATE binders/include)
target_link_libraries(architecture PRIVATE ${lib_deps})
pybind11_add_module(placement binders/placement.cpp ${HEADER_FILES})
target_include_directories(placement PRIVATE binders/include)
target_link_libraries(placement PRIVATE ${lib_deps})
pybind11_add_module(partition binders/partition.cpp ${HEADER_FILES})
target_include_directories(partition PRIVATE binders/include)
target_link_libraries(partition PRIVATE ${lib_deps})
pybind11_add_module(pauli binders/pauli.cpp ${HEADER_FILES})
target_include_directories(pauli PRIVATE binders/include)
target_link_libraries(pauli PRIVATE ${lib_deps})
pybind11_add_module(logging binders/logging.cpp ${HEADER_FILES})
target_include_directories(logging PRIVATE binders/include)
target_link_libraries(logging PRIVATE ${lib_deps})
pybind11_add_module(utils_serialization binders/utils_serialization.cpp ${HEADER_FILES})
target_include_directories(utils_serialization PRIVATE binders/include)
target_link_libraries(utils_serialization PRIVATE ${lib_deps})
pybind11_add_module(tailoring binders/tailoring.cpp ${HEADER_FILES})
target_include_directories(tailoring PRIVATE binders/include)
target_link_libraries(tailoring PRIVATE ${lib_deps})
pybind11_add_module(tableau binders/tableau.cpp ${HEADER_FILES})
target_include_directories(tableau PRIVATE binders/include)
target_link_libraries(tableau PRIVATE ${lib_deps})
pybind11_add_module(zx
binders/zx/diagram.cpp
binders/zx/rewrite.cpp
${HEADER_FILES})
target_include_directories(zx PRIVATE binders/include)
target_link_libraries(zx PRIVATE ${lib_deps})
install(TARGETS
architecture
circuit
circuit_library
logging
mapping
partition
passes
pauli
placement
predicates
tableau
tailoring
transform
unit_id
utils_serialization
zx
LIBRARY DESTINATION lib)