forked from skalenetwork/skaled
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
267 lines (204 loc) · 8.86 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
# skale: Skale C++ client, tools and libraries.
# Licensed under the GNU General Public License, Version 3. See the LICENSE file.
#
cmake_minimum_required(VERSION 3.5.1)
option( SKALE_SKIP_INSTALLING_DIRECTIVES "Do not use CMAKE install() directives " ON )
############################################################################################################
############################################################################################################
############################################################################################################
set( DEPS_SOURCES_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/deps" )
set( DEPS_INSTALL_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/libconsensus/libBLS/deps/deps_inst/x86_or_x64" )
include_directories( "${DEPS_INSTALL_ROOT}/include" "${DEPS_INSTALL_ROOT}/include/cryptopp" ${CMAKE_BINARY_DIR}/deps/include libconsensus)
link_directories( "${DEPS_INSTALL_ROOT}/lib" )
set( CMAKE_PREFIX_PATH "${DEPS_INSTALL_ROOT}" )
list( APPEND CMAKE_MODULE_PATH ${DEPS_INSTALL_ROOT}/lib/cmake )
link_directories( ${CMAKE_BINARY_DIR}/deps/lib ) # HACK for not-found -lff in testeth
if( NOT CMAKE_BUILD_TYPE MATCHES "Debug" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -rdynamic" )
set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rdynamic" )
set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -rdynamic" )
endif()
option( SKALED_PROFILING "Build for profiling" OFF )
if( SKALED_PROFILING )
set( CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -pg" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg" )
set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg" )
set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg" )
endif()
if( CMAKE_BUILD_TYPE STREQUAL "Release" )
set( CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -O3" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3" )
elseif( CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo" )
set( CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -O3" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3" )
elseif( CMAKE_BUILD_TYPE STREQUAL "MinSizeRel" )
set( CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -Os" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Os" )
elseif( CMAKE_BUILD_TYPE STREQUAL "Debug" )
set( CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -O0" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0" )
else()
message( INFO "---- CMAKE_BUILD_TYPE = ${DEPS_INSTALL_ROOT} is not supported explicitly" )
endif()
############################################################################################################
############################################################################################################
############################################################################################################
if( NOT EXISTS ${CMAKE_SOURCE_DIR}/evmc/.git OR NOT EXISTS ${CMAKE_SOURCE_DIR}/cmake/cable/.git )
message( FATAL_ERROR "Git submodules not initialized, execute:\n git submodule update --init" )
endif()
include( cmake/cable/bootstrap.cmake )
include( CableBuildInfo )
include( CableBuildType )
include( CableToolchains )
include( GNUInstallDirs )
if( UNIX )
# Build deps with PIC to allow building shared libraries.
set( toolchain cxx17-pic )
else()
set( toolchain cxx17 )
endif()
cable_configure_toolchain( DEFAULT ${toolchain} )
set( ETH_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}/cmake" CACHE PATH "The path to the cmake directory" )
list( APPEND CMAKE_MODULE_PATH ${ETH_CMAKE_DIR} )
# Map current configuration to configurations of imported targets.
set( CMAKE_MAP_IMPORTED_CONFIG_DEBUG Release )
set( CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO Release )
set( HUNTER_CONFIGURATION_TYPES Release )
set( HUNTER_JOBS_NUMBER 4 )
find_program( CCACHE_FOUND ccache )
if( CCACHE_FOUND )
set_property( GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache )
set_property( GLOBAL PROPERTY RULE_LAUNCH_LINK ccache )
endif(CCACHE_FOUND)
# In CI builds upload the binaries if the GITHUB_USER_PASSWORD was decrypted
# (only for branches and internal PRs).
if( "$ENV{CI}" AND NOT "$ENV{GITHUB_USER_PASSWORD}" STREQUAL "" )
set( run_upload YES )
else()
set( run_upload NO )
endif()
option( HUNTER_RUN_UPLOAD "Upload binaries to the cache server" ${run_upload} )
include( HunterGate )
#HunterGate( URL "https://github.com/ruslo/hunter/archive/v0.23.76.tar.gz" SHA1 "c7b60993e841850e2c449afd454f5d5aa4ec04e4" LOCAL )
HunterGate( URL "https://github.com/ruslo/hunter/archive/v0.23.214.tar.gz" SHA1 "e14bc153a7f16d6a5eeec845fb0283c8fad8c358" LOCAL ) #leveldb 1.22
set( CMAKE_CXX_STANDARD 17 )
cable_set_build_type( DEFAULT RelWithDebInfo CONFIGURATION_TYPES Debug;Release;RelWithDebInfo )
project( skale )
file( READ VERSION PROJECT_VERSION )
string( STRIP ${PROJECT_VERSION} PROJECT_VERSION )
if( NOT EXISTS ${CMAKE_SOURCE_DIR}/evmjit/.git )
message( FATAL_ERROR "Git submodules not initialized, execute:\n git submodule update --init" )
endif()
cable_add_buildinfo_library( PROJECT_NAME skale )
set( CMAKE_SKIP_INSTALL_ALL_DEPENDENCY ON )
include( EthCcache )
include( EthOptions )
include( EthCompilerSettings )
include( EthExecutableHelper )
include( EthDependencies )
include( EthUtils )
set( CLANG_FORMAT_EXCLUDE_PATTERNS
${CMAKE_BINARY_DIR}
${DEPS_SOURCES_ROOT}
"${CMAKE_CURRENT_SOURCE_DIR}/evmc/"
"${CMAKE_CURRENT_SOURCE_DIR}/evmjit/"
"${CMAKE_CURRENT_SOURCE_DIR}/libconsensus/"
)
include( FindClangFormat )
#find_package( ClangFormat )
set( Boost_USE_STATIC_LIBS ON )
set( Boost_USE_MULTITHREADED ON )
hunter_add_package( Boost COMPONENTS program_options filesystem system thread context fiber log chrono test)
find_package( Boost CONFIG REQUIRED program_options filesystem system thread context fiber log chrono)
set( SKALE_HAVE_BOOST_FROM_HUNTER true )
option( BUILD_LEVELDB "Build leveldb from leveldb directory" OFF )
if( BUILD_LEVELDB )
add_subdirectory( leveldb )
else()
hunter_add_package( leveldb )
find_package( leveldb CONFIG REQUIRED )
endif()
#hunter_add_package( jsoncpp )
#find_package( jsoncpp PATHS "${DEPS_INSTALL_ROOT}/libs/cmake" ) #( jsoncpp CONFIG REQUIRED )
hunter_add_package( Snappy )
find_package( Snappy CONFIG REQUIRED )
set( LIB_NAME_cryptopp "cryptopp" )
#set( MHD_DIR "${DEPS_INSTALL_ROOT}" )
#find_package( MHD PATHS "${DEPS_INSTALL_ROOT}/libs/cmake" )
#find_library( MHD microhttpd )
hunter_add_package( libscrypt )
find_package( libscrypt CONFIG REQUIRED )
hunter_add_package( ethash )
find_package( ethash CONFIG REQUIRED )
include( ProjectSecp256k1 )
find_package( Threads )
if( MINIUPNPC )
find_package( Miniupnpc 1.8.2013 REQUIRED )
endif()
set( UTILS_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/utils" )
configure_project()
if( TESTS )
# Import binaryen library for testeth.
# TODO: remove this once testeth uses binaryen as a CLI tool.
include( ProjectBinaryen )
endif()
if (HISTORIC_STATE)
add_definitions(-DHISTORIC_STATE=1)
endif (HISTORIC_STATE)
add_subdirectory( evmc )
#Global include path for all libs:
include_directories( "${CMAKE_SOURCE_DIR}" )
set( SKUTILS_INCLUDE_DIRS
"${CMAKE_SOURCE_DIR}/libskutils/include"
"${CMAKE_SOURCE_DIR}/libconsensus/thirdparty"
"${CMAKE_SOURCE_DIR}/libconsensus/cppzmq"
"${CMAKE_SOURCE_DIR}/libconsensus/libzmq/include"
)
include_directories( ${SKUTILS_INCLUDE_DIRS} )
add_subdirectory( libskutils )
option( SKALE_INTERPRETER_SHARED "Build skale-interpreter as a shared library" OFF )
add_subdirectory( libskale-interpreter )
add_subdirectory( libdevcore )
add_subdirectory( libdevcrypto )
add_subdirectory( libp2p )
add_subdirectory( libhistoric )
add_subdirectory( libskale )
add_subdirectory( libethcore )
add_subdirectory( libevm )
add_subdirectory( libethereum )
add_subdirectory( libethashseal )
add_subdirectory( libweb3jsonrpc )
if( EVMJIT )
add_subdirectory( evmjit )
endif()
add_subdirectory( skaled )
add_subdirectory( skaled_ssl_test )
if( TOOLS )
add_subdirectory( skale-key )
add_subdirectory( skale-vm )
endif()
if( TESTS )
enable_testing()
add_subdirectory( test )
add_subdirectory( storage_benchmark )
endif()
set( CPACK_GENERATOR TGZ )
set( CPACK_PACKAGE_FILE_NAME ${PROJECT_NAME} )
set( CPACK_PACKAGE_CHECKSUM SHA256 )
set( CPACK_INCLUDE_TOPLEVEL_DIRECTORY FALSE )
include( CPack )
if ( CONSENSUS )
set( SKALED_LATEST_STANDARD ON CACHE BOOL "Use latest standards" ) # depricated option. TODO: remove from consensus
set( BUILD_TESTS OFF CACHE BOOL "Build tests" ) # do not build libbls tests
add_subdirectory( libconsensus EXCLUDE_FROM_ALL)
else()
add_subdirectory( libconsensus/libBLS )
set( BUILD_TESTS OFF CACHE BOOL "Build tests" ) # do not build libbls tests
endif()
add_subdirectory( libbatched-io )
set( SANITIZE "" CACHE STRING "contents of -fsanitize option")
if ( SANITIZE )
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=${SANITIZE}" )
SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=${SANITIZE}" )
SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=${SANITIZE}" )
endif()