-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
222 lines (182 loc) · 6.38 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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
cmake_minimum_required(VERSION 3.15.2)
project(xeus-fift)
set(BUILD_SHARED_LIBS NO CACHE BOOL "" FORCE)
set(BUILD_STATIC_LIBS YES CACHE BOOL "" FORCE)
# Configuration
# =============
include(GNUInstallDirs)
set(XFIFT_EXE xeus-fift)
set(XFUNC_EXE xeus-func)
# We generate the kernel.json file, given the installation prefix and the executable name
configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}/share/jupyter/kernels/fift/kernel.json.in"
"${CMAKE_CURRENT_SOURCE_DIR}/share/jupyter/kernels/fift/kernel.json"
)
configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}/share/jupyter/kernels/func/kernel.json.in"
"${CMAKE_CURRENT_SOURCE_DIR}/share/jupyter/kernels/func/kernel.json"
)
# Dependencies
# ============
set(BUILD_TESTS OFF CACHE BOOL "" FORCE)
add_subdirectory(${CMAKE_SOURCE_DIR}/third-party/libzmq EXCLUDE_FROM_ALL)
set(ZeroMQ_DIR ${CMAKE_BINARY_DIR}/third-party/libzmq)
set(cppzmq_REQUIRED_VERSION 4.3.0)
set(CPPZMQ_BUILD_TESTS OFF CACHE BOOL "" FORCE)
add_subdirectory(${CMAKE_SOURCE_DIR}/third-party/cppzmq EXCLUDE_FROM_ALL)
set(cppzmq_DIR ${CMAKE_BINARY_DIR}/third-party/cppzmq)
set(BUILD_TESTS OFF CACHE BOOL "" FORCE)
add_subdirectory(${CMAKE_SOURCE_DIR}/third-party/xtl EXCLUDE_FROM_ALL)
set(xtl_DIR ${CMAKE_BINARY_DIR}/third-party/xtl)
set(JSON_BuildTests OFF CACHE INTERNAL "" FORCE)
add_subdirectory(${CMAKE_SOURCE_DIR}/third-party/nlohmann_json EXCLUDE_FROM_ALL)
set(nlohmann_json_DIR ${CMAKE_BINARY_DIR}/third-party/nlohmann_json)
set(xeus_REQUIRED_VERSION 0.21.1)
set(BUILD_TESTING OFF CACHE BOOL "" FORCE)
add_subdirectory(${CMAKE_SOURCE_DIR}/third-party/xeus EXCLUDE_FROM_ALL)
set(TON_ONLY_TONLIB ON CACHE BOOL "" FORCE)
set(TON_USE_ROCKSDB OFF CACHE BOOL "" FORCE)
set(TON_USE_ABSEIL OFF CACHE BOOL "" FORCE)
set(TDDB_USE_ROCKSDB OFF CACHE BOOL "" FORCE)
add_subdirectory(${CMAKE_SOURCE_DIR}/third-party/ton EXCLUDE_FROM_ALL)
# Flags
# =====
include(CheckCXXCompilerFlag)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel")
CHECK_CXX_COMPILER_FLAG("-std=c++14" HAS_CPP14_FLAG)
if (HAS_CPP14_FLAG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
else()
message(FATAL_ERROR "Unsupported compiler -- xeus requires C++14 support!")
endif()
endif()
# Target and link xeus-fift
# =========================
set(XFIFT_SRC
"${CMAKE_SOURCE_DIR}/src/xfift/xfift.cpp"
"${CMAKE_SOURCE_DIR}/src/xresult.cpp"
"${CMAKE_SOURCE_DIR}/src/xutil.cpp"
)
add_executable(${XFIFT_EXE} src/main.cpp ${XFIFT_SRC})
include_directories(${XFIFT_EXE} PUBLIC ${CMAKE_SOURCE_DIR}/src)
include_directories(${XFIFT_EXE} SYSTEM PUBLIC
${CMAKE_SOURCE_DIR}/third-party
${CMAKE_SOURCE_DIR}/third-party/xeus/include
${CMAKE_SOURCE_DIR}/third-party/nlohmann_json/include
${CMAKE_SOURCE_DIR}/third-party/libzmq/include
${CMAKE_SOURCE_DIR}/third-party/xtl/include
${CMAKE_SOURCE_DIR}/third-party/cppzmq
)
target_link_libraries(${XFIFT_EXE} PUBLIC
libzmq-static
xeus_static
fift-lib
func-lib
stdc++fs
)
if (APPLE)
set_target_properties(${XFIFT_EXE} PROPERTIES
MACOSX_RPATH ON
)
else()
set_target_properties(${XFIFT_EXE} PROPERTIES
BUILD_WITH_INSTALL_RPATH 1
SKIP_BUILD_RPATH FALSE
)
endif()
set_target_properties(${XFIFT_EXE} PROPERTIES
INSTALL_RPATH_USE_LINK_PATH TRUE
)
# Target and link xeus-func
# =========================
set(XFUNC_SRC
"${CMAKE_SOURCE_DIR}/src/xfunc/xfunc.cpp"
"${CMAKE_SOURCE_DIR}/src/xfunc/symguard.cpp"
"${CMAKE_SOURCE_DIR}/src/xfunc/codegen.cpp"
"${CMAKE_SOURCE_DIR}/src/xfunc/preproc.cpp"
"${CMAKE_SOURCE_DIR}/src/xfift/xfift.cpp"
"${CMAKE_SOURCE_DIR}/src/xresult.cpp"
"${CMAKE_SOURCE_DIR}/src/xutil.cpp"
)
add_executable(${XFUNC_EXE} src/main.cpp ${XFUNC_SRC})
target_compile_definitions(${XFUNC_EXE} PUBLIC -DXFUNC_KERNEL)
target_include_directories(${XFUNC_EXE} SYSTEM PUBLIC
${CMAKE_SOURCE_DIR}/third-party
${CMAKE_SOURCE_DIR}/third-party/xeus/include
${CMAKE_SOURCE_DIR}/third-party/nlohmann_json/include
${CMAKE_SOURCE_DIR}/third-party/libzmq/include
${CMAKE_SOURCE_DIR}/third-party/xtl/include
${CMAKE_SOURCE_DIR}/third-party/cppzmq
)
target_link_libraries(${XFUNC_EXE} PUBLIC
libzmq-static
xeus_static
fift-lib
func-lib
stdc++fs
)
if (APPLE)
set_target_properties(${XFUNC_EXE} PROPERTIES
MACOSX_RPATH ON
)
else()
set_target_properties(${XFUNC_EXE} PROPERTIES
BUILD_WITH_INSTALL_RPATH 1
SKIP_BUILD_RPATH FALSE
)
endif()
set_target_properties(${XFUNC_EXE} PROPERTIES
INSTALL_RPATH_USE_LINK_PATH TRUE
)
# Testing
# =======
set(XFIFT_TEST_EXE "xeus-fift-test")
add_subdirectory(${CMAKE_SOURCE_DIR}/third-party/googletest EXCLUDE_FROM_ALL)
set(SRC_TESTS
"${CMAKE_SOURCE_DIR}/src/xfunc/xfunc.cpp"
"${CMAKE_SOURCE_DIR}/src/xfunc/symguard.cpp"
"${CMAKE_SOURCE_DIR}/src/xfunc/codegen.cpp"
"${CMAKE_SOURCE_DIR}/src/xfunc/preproc.cpp"
"${CMAKE_SOURCE_DIR}/src/xfift/xfift.cpp"
"${CMAKE_SOURCE_DIR}/src/xresult.cpp"
"${CMAKE_SOURCE_DIR}/src/xutil.cpp"
"${CMAKE_SOURCE_DIR}/test/test_xfift.cpp"
"${CMAKE_SOURCE_DIR}/test/test_xfunc.cpp"
"${CMAKE_SOURCE_DIR}/test/main.cpp"
)
add_executable(${XFIFT_TEST_EXE} ${SRC_TESTS})
target_include_directories(${XFIFT_TEST_EXE} PUBLIC
"${CMAKE_SOURCE_DIR}/test"
"${CMAKE_SOURCE_DIR}/src"
"${gtest_SOURCE_DIR}/include"
)
target_link_libraries(${XFIFT_TEST_EXE} PUBLIC
gtest
gtest_main
libzmq-static
xeus_static
fift-lib
func-lib
stdc++fs
)
add_test(NAME "test" COMMAND test)
# Installation
# ============
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY TRUE)
# Install my_kernel
install(TARGETS ${XFIFT_EXE} ${XFUNC_EXE}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
# Configuration and data directories for jupyter and my_kernel
set(XJUPYTER_DATA_DIR "share/jupyter" CACHE STRING "Jupyter data directory")
# Install Jupyter kernelspecs
set(MY_KERNELSPEC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/share/jupyter/kernels)
install(DIRECTORY ${MY_KERNELSPEC_DIR}
DESTINATION ${XJUPYTER_DATA_DIR}
PATTERN "*.in" EXCLUDE)
# Copy Fift libraries
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/third-party/ton/crypto/fift/lib/
DESTINATION /usr/lib/fift)
# Copy FunC libraries
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/third-party/ton/crypto/smartcont/
DESTINATION /usr/lib/func
FILES_MATCHING PATTERN "*.fc")