-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathCMakeLists.txt
241 lines (193 loc) · 7.77 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
cmake_minimum_required (VERSION 2.6)
project (BTCPOOL)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
#
# cmake -DCMAKE_BUILD_TYPE=Debug ..
# cmake -DCMAKE_BUILD_TYPE=Release ..
#
# default: Release
#
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
message("CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
IF(CMAKE_BUILD_TYPE MATCHES Debug)
message("Debug build.")
set(CMAKE_CXX_FLAGS "-g -O0 -Wall")
ELSEIF(CMAKE_BUILD_TYPE MATCHES Release)
message("Release build.")
set(CMAKE_CXX_FLAGS "-O2 -Wall")
ELSE()
message("Some other build type.")
ENDIF()
# add a macro that needed by codes copied from bitcoinABC
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_CONFIG_H")
set(CMAKE_CXX_COMPILER "g++")
set(CMAKE_C_COMPILER "gcc")
set(CMAKE_CXX_COMPILER_ARG1 "-std=c++0x ")
set(secp256k1_DIR "${CMAKE_SOURCE_DIR}/src/bitcoin/secp256k1")
set(secp256k1_LIBRARIES "${secp256k1_DIR}/.libs/libsecp256k1.a")
if (NOT EXISTS ${secp256k1_LIBRARIES})
message(STATUS "build secp256k1...")
execute_process(WORKING_DIRECTORY "${secp256k1_DIR}" COMMAND ./autogen.sh)
execute_process(WORKING_DIRECTORY "${secp256k1_DIR}" COMMAND ./configure --enable-module-recovery)
execute_process(WORKING_DIRECTORY "${secp256k1_DIR}" COMMAND make)
endif()
if (NOT EXISTS ${secp256k1_LIBRARIES})
message(FATAL_ERROR "build secp256k1 failed!")
endif()
find_package(OpenSSL)
if(NOT OPENSSL_FOUND)
message(FATAL_ERROR "OpenSSL not found!")
endif(NOT OPENSSL_FOUND)
find_package(LibConfig)
if(NOT LIBCONFIG_FOUND)
message(FATAL_ERROR "LibConfig not found!")
endif(NOT LIBCONFIG_FOUND)
find_package(Glog)
if(NOT GLOG_FOUND)
message(FATAL_ERROR "Glog not found!")
endif(NOT GLOG_FOUND)
find_package(libzmq)
if(NOT LIBZMQ_FOUND)
message(FATAL_ERROR "libzmq not found!")
endif(NOT LIBZMQ_FOUND)
find_package(CURL)
if(NOT CURL_FOUND)
message(FATAL_ERROR "libcurl not found!")
endif(NOT CURL_FOUND)
find_package(LibEvent)
if(NOT LibEvent_FOUND)
message(FATAL_ERROR "libevent2 not found!")
endif(NOT LibEvent_FOUND)
find_package(Boost 1.36.0 COMPONENTS thread filesystem system regex program_options)
if(NOT Boost_FOUND)
message(FATAL_ERROR "Boost not found!")
endif(NOT Boost_FOUND)
find_package(ZookeeperC)
if(NOT ZOOKEEPER_FOUND)
message(FATAL_ERROR "libzookeeper-mt not found!")
endif(NOT ZOOKEEPER_FOUND)
find_package(KafkaC)
if(NOT KAFKA_FOUND)
message(FATAL_ERROR "librdkafka not found!")
endif(NOT KAFKA_FOUND)
execute_process(COMMAND mysql_config --libs_r OUTPUT_VARIABLE MYSQL_LIB OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND mysql_config --include OUTPUT_VARIABLE MYSQL_INCLUDE OUTPUT_STRIP_TRAILING_WHITESPACE)
include_directories(src test src/bitcoin src/bitcoin/secp256k1/include ${OPENSSL_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} ${LIBZMQ_INCLUDE_DIR} ${GLOG_INCLUDE_DIRS} ${LIBEVENT_INCLUDE_DIR} ${MYSQL_INCLUDE})
set(THIRD_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY} ${OPENSSL_SSL_LIBRARY} ${Boost_LIBRARIES} ${LIBCONFIGPP_LIBRARY} ${LIBZMQ_LIBRARIES} ${GLOG_LIBRARIES} ${CURL_LIBRARIES} ${ZOOKEEPER_LIBRARIES} ${KAFKA_LIBRARIES} ${LIBEVENT_LIB} ${LIBEVENT_PTHREADS_LIB} ${secp256k1_LIBRARIES} pthread mysqlclient gmp)
file(GLOB LIB_SOURCES src/*.cc src/bitcoin/*.cpp src/bitcoin/consensus/*.cpp src/bitcoin/crypto/*.cpp src/bitcoin/primitives/*.cpp src/bitcoin/script/*.cpp src/bitcoin/support/*.cpp)
add_library(btcpool STATIC ${LIB_SOURCES})
file(GLOB_RECURSE TEST_SOURCES test/*.cc)
add_executable(unittest ${TEST_SOURCES})
target_link_libraries(unittest btcpool ${THIRD_LIBRARIES})
file(GLOB_RECURSE GBTMAKER_SOURCES src/gbtmaker/*.cc)
add_executable(gbtmaker ${GBTMAKER_SOURCES})
target_link_libraries(gbtmaker btcpool ${THIRD_LIBRARIES})
file(GLOB_RECURSE NMC_AUXBLOCK_MAKER_SOURCES src/nmcauxmaker/*.cc)
add_executable(nmcauxmaker ${NMC_AUXBLOCK_MAKER_SOURCES})
target_link_libraries(nmcauxmaker btcpool ${THIRD_LIBRARIES})
file(GLOB_RECURSE JOBMAKER_SOURCES src/jobmaker/*.cc)
add_executable(jobmaker ${JOBMAKER_SOURCES})
target_link_libraries(jobmaker btcpool ${THIRD_LIBRARIES})
file(GLOB_RECURSE SSERVER_SOURCES src/sserver/*.cc)
add_executable(sserver ${SSERVER_SOURCES})
target_link_libraries(sserver btcpool ${THIRD_LIBRARIES})
file(GLOB_RECURSE STATSHTTPD_SOURCES src/statshttpd/*.cc)
add_executable(statshttpd ${STATSHTTPD_SOURCES})
target_link_libraries(statshttpd btcpool ${THIRD_LIBRARIES})
file(GLOB_RECURSE SHARELOGGER_SOURCES src/sharelogger/*.cc)
add_executable(sharelogger ${SHARELOGGER_SOURCES})
target_link_libraries(sharelogger btcpool ${THIRD_LIBRARIES})
file(GLOB_RECURSE SLPARSER_SOURCES src/slparser/*.cc)
add_executable(slparser ${SLPARSER_SOURCES})
target_link_libraries(slparser btcpool ${THIRD_LIBRARIES})
file(GLOB_RECURSE BLKMAKER_SOURCES src/blkmaker/*.cc)
add_executable(blkmaker ${BLKMAKER_SOURCES})
target_link_libraries(blkmaker btcpool ${THIRD_LIBRARIES})
file(GLOB_RECURSE SIMULATOR_SOURCES src/simulator/*.cc)
add_executable(simulator ${SIMULATOR_SOURCES})
target_link_libraries(simulator btcpool ${THIRD_LIBRARIES})
file(GLOB_RECURSE POOLWATCHER_SOURCES src/poolwatcher/*.cc)
add_executable(poolwatcher ${POOLWATCHER_SOURCES})
target_link_libraries(poolwatcher btcpool ${THIRD_LIBRARIES})
###
# work with stratum switcher
###
option(POOL__WORK_WITH_STRATUM_SWITCHER
"Work with Stratum Switcher" OFF)
if(POOL__WORK_WITH_STRATUM_SWITCHER)
message("-- Work with Stratum Switcher (-DPOOL__WORK_WITH_STRATUM_SWITCHER=ON)")
add_definitions(-DWORK_WITH_STRATUM_SWITCHER)
set(POOL__DEB_PACKNAME_POSTFIX "-withswitcher")
else()
message("-- Work without Stratum Switcher (-DPOOL__WORK_WITH_STRATUM_SWITCHER=OFF)")
set(POOL__DEB_PACKNAME_POSTFIX "")
endif()
###
# `make install` support
###
# install prefix
if(NOT POOL__INSTALL_PREFIX)
set(POOL__INSTALL_PREFIX "/work/btcpool.bcc")
endif()
message("-- Package Install Prefix (-DPOOL__INSTALL_PREFIX=<path>): ${POOL__INSTALL_PREFIX}")
set(CMAKE_INSTALL_PREFIX ${POOL__INSTALL_PREFIX})
set(PACKAGE_TMP_DIR ${CMAKE_BINARY_DIR}/package_tmp)
# init folders & copy configure files
install(CODE "execute_process(WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND bash ${CMAKE_SOURCE_DIR}/install/init_package_folders.sh)")
# install targets , dirs & files
install(TARGETS
blkmaker
gbtmaker
jobmaker
nmcauxmaker
poolwatcher
sharelogger
simulator
slparser
sserver
statshttpd
unittest
DESTINATION
${POOL__INSTALL_PREFIX}/build)
install(FILES
INSTALL.md
LICENSE
README.md
DESTINATION
${POOL__INSTALL_PREFIX})
install(DIRECTORY
docs
install
docker
DESTINATION
${POOL__INSTALL_PREFIX})
install(DIRECTORY
${PACKAGE_TMP_DIR}/run_blkmaker
${PACKAGE_TMP_DIR}/run_gbtmaker
${PACKAGE_TMP_DIR}/run_jobmaker
${PACKAGE_TMP_DIR}/run_nmcauxmaker
${PACKAGE_TMP_DIR}/run_poolwatcher
${PACKAGE_TMP_DIR}/run_sharelogger
${PACKAGE_TMP_DIR}/run_simulator
${PACKAGE_TMP_DIR}/run_slparser
${PACKAGE_TMP_DIR}/run_sserver
${PACKAGE_TMP_DIR}/run_statshttpd
DESTINATION
${POOL__INSTALL_PREFIX}/build)
###
# Debian/Ubuntu software package
###
if(POOL__GENERATE_DEB_PACKAGE)
message("-- Generate Debian/Ubuntu software package (-DPOOL__GENERATE_DEB_PACKAGE=ON)")
set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGE_NAME "btcpool-bitcoincash${POOL__DEB_PACKNAME_POSTFIX}")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "YihaoPeng [email protected]")
# the dependencies
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "librdkafka1 (>= 0.9.1-1)")
else()
message("-- Don't generate Debian/Ubuntu software package (-DPOOL__GENERATE_DEB_PACKAGE=OFF)")
endif()
include(CPack)