forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 38
/
CMakeLists.txt
261 lines (197 loc) · 8.02 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
cmake_minimum_required(VERSION 3.9)
project(SuperBitcoin)
execute_process(COMMAND sh -x ${PROJECT_SOURCE_DIR}/src/test/data/testshell.sh )
execute_process(COMMAND sh -x ${PROJECT_SOURCE_DIR}/share/genbuild.sh ${PROJECT_SOURCE_DIR}/src/sbtccore/build.h ${PROJECT_SOURCE_DIR} )
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_ROOT}/Modules")
INCLUDE( VersionMacros )
INCLUDE( SetupTargetMacros )
INCLUDE( SbtcOptions)
SET( CMAKE_CXX_STANDARD 14 )
SET(VERSION_MAJOR 2)
SET(VERSION_MINOR 0)
SET(VERSION_PATCH 1)
configure_project()
SET( CLI_CLIENT_EXECUTABLE_NAME sbtc-cli )
SET( CLI_SEVER_EXECUTABLE_NAME sbtcd )
# http://stackoverflow.com/a/18369825
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.2.0)
MESSAGE(FATAL_ERROR "GCC version must be at least 7.2.0!")
endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.3)
MESSAGE(FATAL_ERROR "Clang version must be at least 3.3!")
endif()
endif()
#SET (ENABLE_INSTALLER 1)
#SET (USE_PCH 1)
if (USE_PCH)
include (cotire)
endif(USE_PCH)
SET(BOOST_COMPONENTS)
LIST(APPEND BOOST_COMPONENTS thread
date_time
system
filesystem
program_options
signals
serialization
chrono
unit_test_framework
context
locale)
#SET( Boost_USE_STATIC_LIBS ON CACHE STRING "ON or OFF" )
SET( Boost_USE_STATIC_LIBS ON)
FIND_PACKAGE(Boost 1.54 REQUIRED COMPONENTS ${BOOST_COMPONENTS})
# For Boost 1.53 on windows, coroutine was not in BOOST_LIBRARYDIR and do not need it to build, but if boost versin >= 1.54, find coroutine otherwise will cause link errors
IF(NOT "${Boost_VERSION}" MATCHES "1.53(.*)")
SET(BOOST_LIBRARIES_TEMP ${Boost_LIBRARIES})
FIND_PACKAGE(Boost 1.54 REQUIRED COMPONENTS coroutine)
LIST(APPEND BOOST_COMPONENTS coroutine)
SET(Boost_LIBRARIES ${BOOST_LIBRARIES_TEMP} ${Boost_LIBRARIES})
ENDIF()
if(Boost_FOUND)
SET(HAVE_BOOST 1)
endif()
if(Boost_CHRONO_FOUND)
SET(HAVE_BOOST_CHRONO 1)
SET(HAVE_WORKING_BOOST_SLEEP_FOR 1)
endif()
if(Boost_FILESYSTEM_FOUND)
SET(HAVE_BOOST_FILESYSTEM 1)
endif()
if(Boost_PROGRAM_OPTIONS_FOUND)
SET(HAVE_BOOST_PROGRAM_OPTIONS 1)
endif()
if(Boost_SYSTEM_FOUND)
SET(HAVE_BOOST_SYSTEM 1)
endif()
if(Boost_THREAD_FOUND)
SET(HAVE_BOOST_THREAD 1)
endif()
FIND_PACKAGE(libdb_cxx REQUIRED)
IF (LIBDB_CXX_INCLUDE_DIR AND LIBDB_CXX_LIBRARIES)
MESSAGE(STATUS "Found libdb libraries")
INCLUDE_DIRECTORIES(${LIBDB_CXX_INCLUDE_DIR})
MESSAGE(${LIBDB_CXX_LIBRARIES})
# target_link_libraries(main ${LIBDB_CXX_LIBRARIES})
ENDIF (LIBDB_CXX_INCLUDE_DIR AND LIBDB_CXX_LIBRARIES)
find_library(READLINE_LIBRARIES NAMES readline)
find_path(READLINE_INCLUDE_DIR readline/readline.h)
MESSAGE( STATUS "Configuring on Linux" )
SET( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wall" )
SET( rt_library rt )
SET( pthread_library pthread)
if ( NOT DEFINED crypto_library )
# I'm not sure why this is here, I guess someone has openssl and can't detect it with FIND_PACKAGE()?
# if you have a normal install, you can define crypto_library to the empty string to avoid a build error
SET( crypto_library crypto)
endif ()
if (ENABLE_STATIC_FLAG)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc")
endif ()
if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" )
if( CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 4.0.0 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.0.0 )
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-partial-specialization" )
endif()
endif()
if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" )
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-builtin-memcmp" )
endif()
if( "${CMAKE_GENERATOR}" STREQUAL "Ninja" )
if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" )
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics" )
endif()
endif()
#ADD_DEFINITIONS(-DCHEAT_IDE)
FIND_PACKAGE(LevelDB REQUIRED)
MESSAGE( STATUS ${LevelDB_INCLUDE_DIR})
INCLUDE_DIRECTORIES(src)
INCLUDE_DIRECTORIES(src/base)
INCLUDE_DIRECTORIES(src/chaincontrol)
INCLUDE_DIRECTORIES(src/config)
INCLUDE_DIRECTORIES(src/contract)
INCLUDE_DIRECTORIES(src/contract-api)
INCLUDE_DIRECTORIES(src/interface)
INCLUDE_DIRECTORIES(src/framework)
INCLUDE_DIRECTORIES(src/mempool)
INCLUDE_DIRECTORIES(src/miner)
INCLUDE_DIRECTORIES(src/p2p)
INCLUDE_DIRECTORIES(src/rpc)
INCLUDE_DIRECTORIES(src/sbtc-cli)
INCLUDE_DIRECTORIES(src/sbtc-tx)
INCLUDE_DIRECTORIES(src/sbtcd)
INCLUDE_DIRECTORIES(src/sbtccore)
INCLUDE_DIRECTORIES(src/sbtccore/block)
INCLUDE_DIRECTORIES(src/sbtccore/transaction)
INCLUDE_DIRECTORIES(src/sbtccore/transaction/script)
INCLUDE_DIRECTORIES(src/test)
INCLUDE_DIRECTORIES(src/univalue/include)
INCLUDE_DIRECTORIES(src/utils)
INCLUDE_DIRECTORIES(src/utils/crypto)
INCLUDE_DIRECTORIES(src/utils/net)
INCLUDE_DIRECTORIES(src/wallet)
INCLUDE_DIRECTORIES(src/zmq)
INCLUDE_DIRECTORIES ("${PROJECT_SOURCE_DIR}/src/secp256k1/contrib" )
INCLUDE_DIRECTORIES ("${PROJECT_SOURCE_DIR}/src/secp256k1/include" )
INCLUDE_DIRECTORIES ("${PROJECT_SOURCE_DIR}/src" )
INCLUDE_DIRECTORIES (${CMAKE_ROOT}/Modules)
INCLUDE(CheckIncludeFiles)
CHECK_INCLUDE_FILES(byteswap.h HAVE_BYTESWAP_H)
CHECK_INCLUDE_FILES(endian.h HAVE_ENDIAN_H)
CHECK_INCLUDE_FILES(dlfcn.h HAVE_DLFCN_H)
CHECK_INCLUDE_FILES(inttypes.h HAVE_INTTYPES_H)
CHECK_INCLUDE_FILES(memory.h HAVE_MEMORY_H)
CHECK_INCLUDE_FILES(miniupnpc/miniupnpc.h HAVE_MINIUPNPC_MINIUPNPC_H)
CHECK_INCLUDE_FILES(miniupnpc/miniwget.h HAVE_MINIUPNPC_MINIWGET_H)
CHECK_INCLUDE_FILES(miniupnpc/upnpcommands.h HAVE_MINIUPNPC_UPNPCOMMANDS_H)
CHECK_INCLUDE_FILES(miniupnpc/upnperrors.h HAVE_MINIUPNPC_UPNPERRORS_H)
CHECK_INCLUDE_FILES(thread.h HAVE_PTHREAD)
CHECK_INCLUDE_FILES(pthread.h HAVE_PTHREAD_PRIO_INHERIT)
CHECK_INCLUDE_FILES(stdint.h HAVE_STDINT_H)
CHECK_INCLUDE_FILES(stdio.h HAVE_STDIO_H)
CHECK_INCLUDE_FILES(stdlib.h HAVE_STDLIB_H)
CHECK_INCLUDE_FILES(strings.h HAVE_STRINGS_H)
CHECK_INCLUDE_FILES(string.h HAVE_STRING_H)
CHECK_INCLUDE_FILES(sys/prctl.h HAVE_SYS_PRCTL_H)
CHECK_INCLUDE_FILES(sys/select.h HAVE_SYS_SELECT_H)
CHECK_INCLUDE_FILES(sys/stat.h HAVE_SYS_STAT_H)
CHECK_INCLUDE_FILES(sys/types.h HAVE_SYS_TYPES_H)
CHECK_INCLUDE_FILES(unistd.h HAVE_UNISTD_H)
INCLUDE(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" HAVE_CXX11)
INCLUDE(CheckFunctionExists)
CHECK_FUNCTION_EXISTS(daemon HAVE_DECL_DAEMON)
CHECK_FUNCTION_EXISTS(strerror_r HAVE_DECL_STRERROR_R)
CHECK_FUNCTION_EXISTS(strnlen HAVE_DECL_STRNLEN)
CHECK_FUNCTION_EXISTS(getentropy HAVE_GETENTROPY)
CHECK_FUNCTION_EXISTS(malloc_info HAVE_MALLOC_INFO)
CHECK_FUNCTION_EXISTS(mallopt HAVE_MALLOPT_ARENA_MAX)
CHECK_FUNCTION_EXISTS(strerror_r HAVE_STRERROR_R)
CHECK_FUNCTION_EXISTS(getrandom HAVE_SYS_GETRANDOM)
INCLUDE(CheckSymbolExists)
CHECK_SYMBOL_EXISTS(bswap_16 "byteswap.h" HAVE_DECL_BSWAP_16)
CHECK_SYMBOL_EXISTS(bswap_32 "byteswap.h" HAVE_DECL_BSWAP_32)
CHECK_SYMBOL_EXISTS(bswap_64 "byteswap.h" HAVE_DECL_BSWAP_64)
CHECK_SYMBOL_EXISTS(be16toh "endian.h" HAVE_DECL_BE16TOH)
CHECK_SYMBOL_EXISTS(be32toh "endian.h" HAVE_DECL_BE32TOH)
CHECK_SYMBOL_EXISTS(be64toh "endian.h" HAVE_DECL_BE64TOH)
CHECK_SYMBOL_EXISTS(htobe16 "endian.h" HAVE_DECL_HTOBE16)
CHECK_SYMBOL_EXISTS(htobe32 "endian.h" HAVE_DECL_HTOBE32)
CHECK_SYMBOL_EXISTS(htobe64 "endian.h" HAVE_DECL_HTOBE64)
CHECK_SYMBOL_EXISTS(htole16 "endian.h" HAVE_DECL_HTOLE16)
CHECK_SYMBOL_EXISTS(htole32 "endian.h" HAVE_DECL_HTOLE32)
CHECK_SYMBOL_EXISTS(htole64 "endian.h" HAVE_DECL_HTOLE64)
CHECK_SYMBOL_EXISTS(le16toh "endian.h" HAVE_DECL_LE16TOH)
CHECK_SYMBOL_EXISTS(le32toh "endian.h" HAVE_DECL_LE32TOH)
CHECK_SYMBOL_EXISTS(le64toh "endian.h" HAVE_DECL_LE64TOH)
CHECK_SYMBOL_EXISTS(MSG_DONTWAIT "x86_64-linux-gnu/bits/socket.h" HAVE_MSG_DONTWAIT)
CHECK_SYMBOL_EXISTS(MSG_NOSIGNAL "x86_64-linux-gnu/bits/socket.h" HAVE_MSG_NOSIGNAL)
SET(HAVE_MSG_DONTWAIT 1)
SET(HAVE_MSG_NOSIGNAL 1)
configure_file (
"${PROJECT_SOURCE_DIR}/src/config/sbtc-config.h.in"
"${PROJECT_SOURCE_DIR}/src/config/sbtc-config.h"
)
add_subdirectory( src )