-
Notifications
You must be signed in to change notification settings - Fork 13
/
CMakeLists.txt
484 lines (422 loc) · 18.2 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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
# Pre-setup
cmake_minimum_required(VERSION 3.19.0)
include(cmake/cable/bootstrap.cmake)
include(CableBuildInfo)
include(CableBuildType)
include(GNUInstallDirs)
cable_set_build_type(DEFAULT Debug CONFIGURATION_TYPES Debug;Release;RelWithDebInfo)
# Map current configuration to configurations of imported targets.
set(CMAKE_MAP_IMPORTED_CONFIG_Debug Debug)
set(CMAKE_MAP_IMPORTED_CONFIG_RelWithDebInfo Debug)
# Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake 3.24+
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
cmake_policy(SET CMP0135 NEW)
endif()
# Project data
project(orbitersdk VERSION 0.2.0 DESCRIPTION "Sparq subnet")
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_EXTENSIONS OFF)
SET(DEBUG ON CACHE BOOL "Debug mode")
if(DEBUG)
set(CMAKE_CXX_FLAGS "-O0 -g -fsanitize=address -fno-inline -fno-eliminate-unused-debug-types -fstack-protector -Werror=unused-variable") # Provides faster compile time.
elseif(SONARQUBE_ANALYSIS)
set(CMAKE_CXX_FLAGS "-O0 -g --coverage")
else()
set(CMAKE_CXX_FLAGS "-O2 -Werror=unused-variable")
endif()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") # Always look for static libraries - "ZLIB_USE_STATIC_LIBS" was added in 3.24
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # For clang-tidy
# Set project version inside the code
configure_file(
${CMAKE_SOURCE_DIR}/src/utils/options.h.in
${CMAKE_SOURCE_DIR}/src/utils/options.h
@ONLY
)
# External project data
set(BUILD_TESTS ON CACHE BOOL "Build helper unit testing program")
set(BUILD_DISCOVERY ON CACHE BOOL "Build helper discovery node program")
set(BUILD_AVALANCHEGO OFF CACHE BOOL "Build with AvalancheGo wrapping")
set(BUILD_TOOLS OFF CACHE BOOL "Build tools related to subnet")
set(USE_LINT OFF CACHE BOOL "Run linter on compile (clang-tidy)")
if(USE_LINT)
set(CMAKE_CXX_CLANG_TIDY "clang-tidy;-header-filter=.;-checks=-*,abseil-*,boost-*,bugprone-*,cert-*,clang-analyzer-*,concurrency-*,cppcoreguidelines-*,hicpp-*,misc-*,modernize-*,performance-*,portability-*,readability-*")
endif()
# Echo CMake vars during config
message(STATUS "C++ standard: ${CMAKE_CXX_STANDARD}")
message(STATUS "C++ standard is required: ${CMAKE_CXX_STANDARD_REQUIRED}")
message(STATUS "C++ extensions: ${CMAKE_CXX_EXTENSIONS}")
message(STATUS "C++ flags: ${CMAKE_CXX_FLAGS}")
message(STATUS "Using PIC: ${CMAKE_POSITION_INDEPENDENT_CODE}")
message(STATUS "Find libs with suffix: ${CMAKE_FIND_LIBRARY_SUFFIXES}")
message("Building tests: ${BUILD_TESTS}")
message("Building Discovery Node: ${BUILD_DISCOVERY}")
message("Building AvalancheGo support: ${BUILD_AVALANCHEGO}")
message("Building tools: ${BUILD_TOOLS}")
message("Using lint: ${USE_LINT}")
cable_add_buildinfo_library(PROJECT_NAME orbitersdk)
# System package configs (built-in)
set(Boost_USE_STATIC_LIBS ON)
set(OPENSSL_USE_STATIC_LIBS ON)
set(Protobuf_USE_STATIC_LIBS ON)
# Find system packages (built-in)
find_package(Threads)
find_package(Boost 1.74.0 REQUIRED COMPONENTS chrono filesystem program_options system thread nowide)
find_package(OpenSSL 1.1.1 REQUIRED)
find_package(ZLIB REQUIRED)
# Find system packages (custom)
find_package(CryptoPP 8.2.0 REQUIRED)
find_package(Scrypt REQUIRED)
# Add external modules
include(cmake/ProjectBoostCertify.cmake) # Boost Certify
include(cmake/ProjectEthash.cmake) # Ethash
include(cmake/ProjectSecp256k1.cmake) # Bitcoin core fast implementation
include(cmake/ProjectSpeedb.cmake) # Speedb (Level/RocksDB drop-in replacement)
# Add catch2 as a library
add_library(catch2
${CMAKE_SOURCE_DIR}/src/libs/catch2/catch_amalgamated.hpp
${CMAKE_SOURCE_DIR}/src/libs/catch2/catch_amalgamated.cpp
)
target_include_directories(catch2 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/catch2)
# Check compiler variable sizes
include(cmake/CheckSizes.cmake)
# Add AvalancheGo wrapper dependencies if compiling it
if(BUILD_AVALANCHEGO)
find_package(Absl REQUIRED) # Built-in is hardcoded to SHARED, this one to STATIC
find_package(Cares REQUIRED)
find_package(Protobuf 3.12 REQUIRED)
find_package(GRPC REQUIRED)
endif()
# Include directories for headers and libs
include_directories(
"${CMAKE_SOURCE_DIR}"
"${CMAKE_SOURCE_DIR}/src"
"${CMAKE_SOURCE_DIR}/src/libs"
"${CMAKE_SOURCE_DIR}/build"
"${CMAKE_SOURCE_DIR}/build/deps/include"
)
link_directories(
"${CMAKE_SOURCE_DIR}"
"${CMAKE_SOURCE_DIR}/src"
"${CMAKE_SOURCE_DIR}/src/libs"
"${CMAKE_SOURCE_DIR}/build"
"${CMAKE_SOURCE_DIR}/build/deps/lib"
)
# Organize, compile and link orbitersdk libs
add_subdirectory(src/contract)
add_subdirectory(src/core)
add_subdirectory(src/net)
add_subdirectory(src/utils)
add_subdirectory(tests)
# Generate gRPC files if building with support for AvalancheGo.
# Headers/sources are always cleaned at configure so they can be regenerated at build
if(BUILD_AVALANCHEGO)
file(REMOVE
"${CMAKE_SOURCE_DIR}/proto/vm.grpc.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/aliasreader.grpc.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/appsender.grpc.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/keystore.grpc.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/messenger.grpc.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/sharedmemory.grpc.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/rpcdb.grpc.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/vm.grpc.pb.h"
"${CMAKE_SOURCE_DIR}/proto/aliasreader.grpc.pb.h"
"${CMAKE_SOURCE_DIR}/proto/appsender.grpc.pb.h"
"${CMAKE_SOURCE_DIR}/proto/keystore.grpc.pb.h"
"${CMAKE_SOURCE_DIR}/proto/messenger.grpc.pb.h"
"${CMAKE_SOURCE_DIR}/proto/sharedmemory.grpc.pb.h"
"${CMAKE_SOURCE_DIR}/proto/rpcdb.grpc.pb.h"
"${CMAKE_SOURCE_DIR}/proto/vm.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/aliasreader.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/appsender.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/keystore.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/messenger.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/sharedmemory.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/rpcdb.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/vm.pb.h"
"${CMAKE_SOURCE_DIR}/proto/aliasreader.pb.h"
"${CMAKE_SOURCE_DIR}/proto/appsender.pb.h"
"${CMAKE_SOURCE_DIR}/proto/keystore.pb.h"
"${CMAKE_SOURCE_DIR}/proto/messenger.pb.h"
"${CMAKE_SOURCE_DIR}/proto/sharedmemory.pb.h"
"${CMAKE_SOURCE_DIR}/proto/rpcdb.pb.h"
)
add_custom_command(
OUTPUT "${CMAKE_SOURCE_DIR}/proto/aliasreader.grpc.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/aliasreader.grpc.pb.h"
COMMAND "protoc"
ARGS --grpc_out="${CMAKE_SOURCE_DIR}/proto"
--plugin=protoc-gen-grpc="${GRPC_CPP_PLUGIN}"
--proto_path="${CMAKE_SOURCE_DIR}/proto"
"${CMAKE_SOURCE_DIR}/proto/aliasreader.proto"
)
add_custom_command(
OUTPUT "${CMAKE_SOURCE_DIR}/proto/appsender.grpc.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/appsender.grpc.pb.h"
COMMAND "protoc"
ARGS --grpc_out="${CMAKE_SOURCE_DIR}/proto"
--plugin=protoc-gen-grpc="${GRPC_CPP_PLUGIN}"
--proto_path="${CMAKE_SOURCE_DIR}/proto"
"${CMAKE_SOURCE_DIR}/proto/appsender.proto"
)
add_custom_command(
OUTPUT "${CMAKE_SOURCE_DIR}/proto/keystore.grpc.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/keystore.grpc.pb.h"
COMMAND "protoc"
ARGS --grpc_out="${CMAKE_SOURCE_DIR}/proto"
--plugin=protoc-gen-grpc="${GRPC_CPP_PLUGIN}"
--proto_path="${CMAKE_SOURCE_DIR}/proto"
"${CMAKE_SOURCE_DIR}/proto/keystore.proto"
)
add_custom_command(
OUTPUT "${CMAKE_SOURCE_DIR}/proto/messenger.grpc.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/messenger.grpc.pb.h"
COMMAND "protoc"
ARGS --grpc_out="${CMAKE_SOURCE_DIR}/proto"
--plugin=protoc-gen-grpc="${GRPC_CPP_PLUGIN}"
--proto_path="${CMAKE_SOURCE_DIR}/proto"
"${CMAKE_SOURCE_DIR}/proto/messenger.proto"
)
add_custom_command(
OUTPUT "${CMAKE_SOURCE_DIR}/proto/metrics.grpc.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/metrics.grpc.pb.h"
COMMAND "protoc"
ARGS --grpc_out="${CMAKE_SOURCE_DIR}/proto"
--plugin=protoc-gen-grpc="${GRPC_CPP_PLUGIN}"
--proto_path="${CMAKE_SOURCE_DIR}/proto"
"${CMAKE_SOURCE_DIR}/proto/metrics.proto"
)
add_custom_command(
OUTPUT "${CMAKE_SOURCE_DIR}/proto/sharedmemory.grpc.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/sharedmemory.grpc.pb.h"
COMMAND "protoc"
ARGS --grpc_out="${CMAKE_SOURCE_DIR}/proto"
--plugin=protoc-gen-grpc="${GRPC_CPP_PLUGIN}"
--proto_path="${CMAKE_SOURCE_DIR}/proto"
"${CMAKE_SOURCE_DIR}/proto/sharedmemory.proto"
)
add_custom_command(
OUTPUT "${CMAKE_SOURCE_DIR}/proto/rpcdb.grpc.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/rpcdb.grpc.pb.h"
COMMAND "protoc"
ARGS --grpc_out="${CMAKE_SOURCE_DIR}/proto"
--plugin=protoc-gen-grpc="${GRPC_CPP_PLUGIN}"
--proto_path="${CMAKE_SOURCE_DIR}/proto"
"${CMAKE_SOURCE_DIR}/proto/rpcdb.proto"
)
add_custom_command(
OUTPUT "${CMAKE_SOURCE_DIR}/proto/vm.grpc.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/vm.grpc.pb.h"
COMMAND "protoc"
ARGS --grpc_out="${CMAKE_SOURCE_DIR}/proto"
--plugin=protoc-gen-grpc="${GRPC_CPP_PLUGIN}"
--proto_path="${CMAKE_SOURCE_DIR}/proto"
--experimental_allow_proto3_optional
"${CMAKE_SOURCE_DIR}/proto/vm.proto"
)
# Protobuf PROTOBUF_GENERATE_CPP does NOT work with --experimental_allow_proto3_optional
# requiring us to go over protobuf files with add_custom_command
add_custom_command(
OUTPUT "${CMAKE_SOURCE_DIR}/proto/aliasreader.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/aliasreader.pb.h"
COMMAND "protoc"
ARGS --cpp_out="${CMAKE_SOURCE_DIR}/proto"
--proto_path="${CMAKE_SOURCE_DIR}/proto"
"${CMAKE_SOURCE_DIR}/proto/aliasreader.proto"
)
add_custom_command(
OUTPUT "${CMAKE_SOURCE_DIR}/proto/appsender.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/appsender.pb.h"
COMMAND "protoc"
ARGS --cpp_out="${CMAKE_SOURCE_DIR}/proto"
--proto_path="${CMAKE_SOURCE_DIR}/proto"
"${CMAKE_SOURCE_DIR}/proto/appsender.proto"
)
add_custom_command(
OUTPUT "${CMAKE_SOURCE_DIR}/proto/keystore.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/keystore.pb.h"
COMMAND "protoc"
ARGS --cpp_out="${CMAKE_SOURCE_DIR}/proto"
--proto_path="${CMAKE_SOURCE_DIR}/proto"
"${CMAKE_SOURCE_DIR}/proto/keystore.proto"
)
add_custom_command(
OUTPUT "${CMAKE_SOURCE_DIR}/proto/messenger.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/messenger.pb.h"
COMMAND "protoc"
ARGS --cpp_out="${CMAKE_SOURCE_DIR}/proto"
--proto_path="${CMAKE_SOURCE_DIR}/proto"
"${CMAKE_SOURCE_DIR}/proto/messenger.proto"
)
add_custom_command(
OUTPUT "${CMAKE_SOURCE_DIR}/proto/metrics.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/metrics.pb.h"
COMMAND "protoc"
ARGS --cpp_out="${CMAKE_SOURCE_DIR}/proto"
--proto_path="${CMAKE_SOURCE_DIR}/proto"
"${CMAKE_SOURCE_DIR}/proto/metrics.proto"
)
add_custom_command(
OUTPUT "${CMAKE_SOURCE_DIR}/proto/sharedmemory.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/sharedmemory.pb.h"
COMMAND "protoc"
ARGS --cpp_out="${CMAKE_SOURCE_DIR}/proto"
--proto_path="${CMAKE_SOURCE_DIR}/proto"
"${CMAKE_SOURCE_DIR}/proto/sharedmemory.proto"
)
add_custom_command(
OUTPUT "${CMAKE_SOURCE_DIR}/proto/rpcdb.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/rpcdb.pb.h"
COMMAND "protoc"
ARGS --cpp_out="${CMAKE_SOURCE_DIR}/proto"
--proto_path="${CMAKE_SOURCE_DIR}/proto"
"${CMAKE_SOURCE_DIR}/proto/rpcdb.proto"
)
add_custom_command(
OUTPUT "${CMAKE_SOURCE_DIR}/proto/metrics.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/metrics.pb.h"
COMMAND "protoc"
ARGS --cpp_out="${CMAKE_SOURCE_DIR}/proto"
--proto_path="${CMAKE_SOURCE_DIR}/proto"
"${CMAKE_SOURCE_DIR}/proto/metrics.proto"
)
add_custom_command(
OUTPUT "${CMAKE_SOURCE_DIR}/proto/vm.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/vm.pb.h"
COMMAND "protoc"
ARGS --cpp_out="${CMAKE_SOURCE_DIR}/proto"
--proto_path="${CMAKE_SOURCE_DIR}/proto"
--experimental_allow_proto3_optional
"${CMAKE_SOURCE_DIR}/proto/vm.proto"
)
add_library(ProtoFiles
"${CMAKE_SOURCE_DIR}/proto/vm.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/aliasreader.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/appsender.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/keystore.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/messenger.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/sharedmemory.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/rpcdb.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/metrics.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/vm.pb.h"
"${CMAKE_SOURCE_DIR}/proto/aliasreader.pb.h"
"${CMAKE_SOURCE_DIR}/proto/appsender.pb.h"
"${CMAKE_SOURCE_DIR}/proto/keystore.pb.h"
"${CMAKE_SOURCE_DIR}/proto/messenger.pb.h"
"${CMAKE_SOURCE_DIR}/proto/sharedmemory.pb.h"
"${CMAKE_SOURCE_DIR}/proto/rpcdb.pb.h"
"${CMAKE_SOURCE_DIR}/proto/metrics.pb.h"
)
# You HAVE to set the file names
add_library (gen-grpc
"${CMAKE_SOURCE_DIR}/proto/vm.grpc.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/aliasreader.grpc.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/appsender.grpc.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/keystore.grpc.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/messenger.grpc.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/sharedmemory.grpc.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/rpcdb.grpc.pb.cc"
"${CMAKE_SOURCE_DIR}/proto/vm.grpc.pb.h"
"${CMAKE_SOURCE_DIR}/proto/aliasreader.grpc.pb.h"
"${CMAKE_SOURCE_DIR}/proto/appsender.grpc.pb.h"
"${CMAKE_SOURCE_DIR}/proto/keystore.grpc.pb.h"
"${CMAKE_SOURCE_DIR}/proto/messenger.grpc.pb.h"
"${CMAKE_SOURCE_DIR}/proto/sharedmemory.grpc.pb.h"
"${CMAKE_SOURCE_DIR}/proto/rpcdb.grpc.pb.h"
${ProtoFiles}
)
target_link_libraries(gen-grpc PUBLIC ${Protobuf_LIBRARIES} ${GRPC_LIBRARIES} ${CARES_LIBRARY} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} absl::flags)
add_library(orbitersdk_lib STATIC
${UTILS_HEADERS}
${UTILS_SOURCES}
${CONTRACT_HEADERS}
${CONTRACT_SOURCES}
${CORE_HEADERS}
${CORE_SOURCES}
${NET_HEADERS}
${NET_SOURCES}
)
add_dependencies(orbitersdk_lib gen-grpc ProtoFiles)
target_include_directories(orbitersdk_lib PUBLIC ${CMAKE_SOURCE_DIR}/include ${OPENSSL_INCLUDE_DIR})
target_link_libraries(orbitersdk_lib PRIVATE
${CRYPTOPP_LIBRARIES} ${SCRYPT_LIBRARY} Secp256k1 Ethash ${ETHASH_BYPRODUCTS} ${Protobuf_LIBRARIES}
${GRPC_LIBRARIES} ${CARES_LIBRARY} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} absl::flags
Speedb ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES}
)
set_target_properties(orbitersdk_lib PROPERTIES COMPILE_FLAGS "-DAVALANCHEGO_COMPATIBLE=1")
# Compile and link the executable
add_executable(orbitersdkd "${CMAKE_SOURCE_DIR}/src/main.cpp")
add_dependencies(orbitersdkd orbitersdk_lib gen-grpc ProtoFiles)
target_include_directories(orbitersdkd PRIVATE orbitersdk_lib ${OPENSSL_INCLUDE_DIR})
target_link_libraries(orbitersdkd
orbitersdk_lib
${Protobuf_LIBRARIES} ${GRPC_LIBRARIES} ${CARES_LIBRARY} Speedb
${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES}
absl::flags Secp256k1 Ethash ${ETHASH_BYPRODUCTS}
)
# Compile and link the ABI generator executable
add_executable(contractabigenerator "${CMAKE_SOURCE_DIR}/src/main-contract-abi.cpp")
add_dependencies(contractabigenerator orbitersdk_lib)
target_include_directories(contractabigenerator PRIVATE orbitersdk_lib ${OPENSSL_INCLUDE_DIR})
target_link_libraries(contractabigenerator
orbitersdk_lib Speedb ${SNAPPY_LIBRARY} ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} Secp256k1 Ethash ${ETHASH_BYPRODUCTS}
)
# TODO: Implement tests for AvalancheGo compilation.
else()
add_library(orbitersdk_lib STATIC
${UTILS_HEADERS}
${UTILS_SOURCES}
${CONTRACT_HEADERS}
${CONTRACT_SOURCES}
${CORE_HEADERS}
${CORE_SOURCES}
${NET_HEADERS}
${NET_SOURCES}
)
target_include_directories(orbitersdk_lib PRIVATE ${CMAKE_SOURCE_DIR}/include ${OPENSSL_INCLUDE_DIR})
target_link_libraries(orbitersdk_lib PRIVATE
${CRYPTOPP_LIBRARIES} ${SCRYPT_LIBRARY} Secp256k1 Ethash ${ETHASH_BYPRODUCTS}
Speedb ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES}
)
set_target_properties(orbitersdk_lib PROPERTIES COMPILE_FLAGS "-DAVALANCHEGO_COMPATIBLE=0")
# Compile and link the executable
add_executable(orbitersdkd "${CMAKE_SOURCE_DIR}/src/main.cpp")
add_dependencies(orbitersdkd orbitersdk_lib)
target_include_directories(orbitersdkd PRIVATE orbitersdk_lib ${OPENSSL_INCLUDE_DIR})
target_link_libraries(orbitersdkd
orbitersdk_lib Speedb ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} Secp256k1 Ethash ${ETHASH_BYPRODUCTS}
)
# Compile and link the ABI generator executable
add_executable(contractabigenerator "${CMAKE_SOURCE_DIR}/src/main-contract-abi.cpp")
add_dependencies(contractabigenerator orbitersdk_lib)
target_include_directories(contractabigenerator PRIVATE orbitersdk_lib ${OPENSSL_INCLUDE_DIR})
target_link_libraries(contractabigenerator
orbitersdk_lib Speedb ${SNAPPY_LIBRARY} ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} Secp256k1 Ethash ${ETHASH_BYPRODUCTS}
)
# Compile and link the ABI generator executable
add_executable(networkdeployer "${CMAKE_SOURCE_DIR}/src/networkdeployer.cpp")
add_dependencies(networkdeployer orbitersdk_lib)
target_include_directories(networkdeployer PRIVATE orbitersdk_lib ${OPENSSL_INCLUDE_DIR})
target_link_libraries(networkdeployer
orbitersdk_lib Speedb ${SNAPPY_LIBRARY} ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} Secp256k1 Ethash ${ETHASH_BYPRODUCTS}
)
endif()
# Compile and link the test executable if set to build it
if (BUILD_TESTS)
add_executable(orbitersdkd-tests ${TESTS_HEADERS} ${TESTS_SOURCES})
add_dependencies(orbitersdkd-tests orbitersdk_lib)
target_include_directories(orbitersdkd-tests PRIVATE orbitersdk_lib ${OPENSSL_INCLUDE_DIR})
target_link_libraries(orbitersdkd-tests
orbitersdk_lib Speedb ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} Secp256k1 catch2 Ethash ${ETHASH_BYPRODUCTS}
)
endif()
# Compile and link the Discovery Node test executable if set to build it
if (BUILD_DISCOVERY)
add_executable(orbitersdkd-discovery "${CMAKE_SOURCE_DIR}/src/main-discovery.cpp")
add_dependencies(orbitersdkd-discovery orbitersdk_lib)
target_include_directories(orbitersdkd-discovery PRIVATE orbitersdk_lib ${OPENSSL_INCLUDE_DIR})
target_link_libraries(orbitersdkd-discovery
orbitersdk_lib Speedb ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} Secp256k1 Ethash ${ETHASH_BYPRODUCTS}
)
endif()