forked from jmzkChain/jmzk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
207 lines (172 loc) · 6.27 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
cmake_minimum_required(VERSION 3.5)
# Defines everiToken library target.
project(EVT)
option(ENABLE_MONGODB_SUPPORT "Build with mongodb support, this enables both mongo_db_plugin and history_plugin" OFF)
option(ENABLE_POSTGRES_SUPPORT "Build with postgres support, this enables postgres_plugin" OFF)
option(ENABLE_BREAKPAD_SUPPORT "Build with breakpad support, this enables minidump when crash" OFF)
option(ENABLE_BIND_LIBRARIES "Build bind libraries" OFF)
option(ENABLE_BENCHMARKS "Build benchmarks" OFF)
option(ENABLE_COVERAGE_TESTING "Build EVT for code coverage analysis" OFF)
option(ENABLE_TESTING "Enable testing targets" ON)
option(ENABLE_COLOR_OUTPUT "Enable diagnostics color output from compiler" ON)
option(ENABLE_MAINNET_BUILD "Build EVT for Mainnet" OFF)
option(ENABLE_BUILD_LTO "Enable LTO when build" OFF)
option(ENABLE_FULL_STATIC_BUILD "Enable full static build" OFF)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/libraries/fc/CMakeModules")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
include(GNUInstallDirs)
include(VersionMacros)
include(SetupTargetMacros)
include(InstallDirectoryPermissions)
set(BLOCKCHAIN_NAME "EVT")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS ON)
set(CXX_STANDARD_REQUIRED ON)
set(VERSION_MAJOR 3)
set(VERSION_MINOR 2)
set(VERSION_PATCH 0)
set(CLI_CLIENT_EXECUTABLE_NAME evtc)
set(GUI_CLIENT_EXECUTABLE_NAME evt)
set(CUSTOM_URL_SCHEME "gcs")
set(INSTALLER_APP_ID "0E523427-37A8-4368-8D5E-AC17FC845110")
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY true)
# http://stackoverflow.com/a/18369825
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0)
message(FATAL_ERROR "GCC version must be at least 8.0!")
endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0)
message(FATAL_ERROR "Clang version must be at least 7.0!")
endif()
endif()
if(WIN32)
message(FATAL_ERROR "EVT IS NOT SUPPORT BUILDING ON WIN32")
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS "ON")
set(CXX_FLAGS
-Wall
-Wextra
-Werror
-Wno-unused-parameter
)
string(REPLACE ";" " " CMAKE_CXX_FLAGS "${CXX_FLAGS}")
set(CXX_FLAGS_RELEASE
-O3
-DNDEBUG
)
string(REPLACE ";" " " CMAKE_CXX_FLAGS_RELEASE "${CXX_FLAGS_RELEASE}")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-uninitialized -ftemplate-backtrace-limit=0")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-maybe-uninitialized -fno-builtin-memcmp -no-pie")
if(ENABLE_FULL_STATIC_BUILD)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc")
endif()
endif()
if(USE_PCH)
include(cotire)
endif()
# add defaults for openssl
if("${OPENSSL_ROOT_DIR}" STREQUAL "")
if(NOT "$ENV{OPENSSL_ROOT_DIR}" STREQUAL "")
set(OPENSSL_ROOT_DIR $ENV{OPENSSL_ROOT_DIR})
set(OPENSSL_INCLUDE_DIR ${OPENSSL_ROOT_DIR}/include)
elseif (APPLE)
set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl")
set(OPENSSL_INCLUDE_DIR "/usr/local/opt/openssl/include")
elseif(UNIX AND NOT APPLE)
set(OPENSSL_ROOT_DIR "/usr/include/openssl")
set(OPENSSL_INCLUDE_DIR "/usr/include/openssl/include")
else()
message(FATAL_ERROR "openssl not found and don't know where to look, please specify OPENSSL_ROOT_DIR")
endif()
endif()
if("${OPENSSL_LIBRARIES}" STREQUAL "")
if(NOT "$ENV{OPENSSL_LIBRARIES}" STREQUAL "")
set(OPENSSL_LIBRARIES $ENV{OPENSSL_LIBRARIES})
elseif (APPLE)
set(OPENSSL_LIBRARIES "/usr/local/opt/openssl/lib")
elseif(UNIX AND NOT APPLE)
set(OPENSSL_LIBRARIES "/usr/include/openssl")
else()
message(FATAL_ERROR "openssl libs not found and don't know where to look, please specify OPENSSL_LIBRARIES")
endif()
endif()
if(UNIX)
if(APPLE)
set(whole_archive_flag "-force_load")
set(no_whole_archive_flag "")
else()
set(whole_archive_flag "--whole-archive")
set(no_whole_archive_flag "--no-whole-archive")
endif()
else()
set(whole_archive_flag "--whole-archive")
set(no_whole_archive_flag "--no-whole-archive")
endif()
if(ENABLE_FULL_STATIC_BUILD)
set(Boost_USE_STATIC_LIBS ON CACHE STRING "ON or OFF")
else()
set(Boost_USE_STATIC_LIBS OFF CACHE STRING "ON or OFF")
endif()
FIND_PACKAGE(Boost 1.69 REQUIRED COMPONENTS
thread
date_time
filesystem
system
program_options
serialization
chrono
unit_test_framework
context
locale
iostreams
timer)
if(ENABLE_COLOR_OUTPUT)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")
endif()
endif()
# based on http://www.delorie.com/gnu/docs/gdb/gdb_70.html
# uncomment this line to tell GDB about macros (slows compile times)
# set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -gdwarf-2 -g3" )
if(ENABLE_COVERAGE_TESTING)
SET(CMAKE_CXX_FLAGS "--coverage ${CMAKE_CXX_FLAGS}")
find_program( LCOV_PATH lcov )
find_program( GENHTML_PATH NAMES genhtml)
endif()
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0")
endif()
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" OR ENABLE_BREAKPAD_SUPPORT)
message(STATUS "Build EVT with symbols")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
endif()
if(ENABLE_BUILD_LTO)
message(STATUS "Build EVT with link-time optimization")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-linker-plugin -flto -ffat-lto-objects")
endif()
include_directories(libraries/rocksdb/include)
if("${EVT_ROOT_KEY}" STREQUAL "")
set(EVT_ROOT_KEY "EVT6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV")
endif()
message( STATUS "Using '${EVT_ROOT_KEY}' as public key for evt account" )
if(ENABLE_TESTING)
enable_testing()
endif()
add_subdirectory(libraries)
add_subdirectory(plugins)
add_subdirectory(programs)
if(ENABLE_BIND_LIBRARIES)
add_subdirectory(bind)
endif()
if(ENABLE_BENCHMARKS)
add_subdirectory(benchmarks)
endif()
if(ENABLE_TESTING)
add_subdirectory(unittests)
endif()
include(installer)