7
7
# CMake support is experimental. Use with caution and report any bugs.
8
8
9
9
cmake_minimum_required (VERSION 3.18 )
10
+ set (CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH} " "${CMAKE_CURRENT_SOURCE_DIR} /build-aux/cmake" )
11
+
12
+
13
+ # Hunter Package Manager
14
+ # ======================
15
+
16
+ # Windows doesn't yet have a package manager that can be used for managing
17
+ # dependencies, so we use Hunter on it.
18
+ option (HUNTER_ENABLED "Enable Hunter package manager" OFF )
19
+ include (HunterGate )
20
+ HunterGate (
21
+ URL "https://github.com/cpp-pm/hunter/archive/refs/tags/v0.25.3.tar.gz"
22
+ SHA1 "0dfbc2cb5c4cf7e83533733bdfd2125ff96680cb"
23
+ FILEPATH "${CMAKE_CURRENT_SOURCE_DIR} /build-aux/cmake/Hunter/config.cmake"
24
+ )
25
+
26
+
27
+ # Project configuration
28
+ # =====================
10
29
11
30
project ("Gridcoin"
12
- VERSION 5.4.7 .0
31
+ VERSION 5.4.8 .0
13
32
DESCRIPTION "POS-based cryptocurrency that rewards BOINC computation"
14
33
HOMEPAGE_URL "https://gridcoin.us"
15
- LANGUAGES ASM C CXX
34
+ LANGUAGES C CXX
16
35
)
17
36
18
37
set (CLIENT_VERSION_IS_RELEASE "true" )
@@ -24,33 +43,38 @@ set(COPYRIGHT_HOLDERS_FINAL "The Gridcoin developers")
24
43
# =======================
25
44
26
45
set (CMAKE_CXX_STANDARD 17 )
46
+ set (CMAKE_CXX_STANDARD_REQUIRED ON )
27
47
28
48
set (CMAKE_C_VISIBILITY_PRESET hidden )
29
49
set (CMAKE_CXX_VISIBILITY_PRESET hidden )
30
50
31
- set (CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded )
32
-
33
51
set (CMAKE_INCLUDE_CURRENT_DIR ON )
34
52
35
- # Remove '-DNDEBUG' from flags because we need asserts
36
- string (REPLACE "NDEBUG" "_NDEBUG" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} " )
37
- string (REPLACE "NDEBUG" "_NDEBUG" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} " )
38
-
53
+ if (MSVC )
54
+ if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
55
+ message (FATAL_ERROR "It's not yet possible to build Gridcoin with MSVC" )
56
+ endif ()
57
+ add_compile_options (/U NDEBUG )
58
+ else ()
59
+ add_compile_options (-UNDEBUG )
60
+ endif ()
39
61
40
- # Load modules from the source tree
41
- # =================================
42
62
43
- set (CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH} " "${CMAKE_CURRENT_SOURCE_DIR} /build-aux/cmake" )
63
+ # Load CMake modules
64
+ # ==================
44
65
45
66
include (CheckCXXSymbolExists )
46
67
include (CheckFunctionExists )
47
68
include (CheckIncludeFile )
48
69
include (CheckPIESupported )
70
+ include (CheckSymbolExists )
71
+
49
72
include (CheckSSE )
50
73
include (CheckStrerrorR )
51
- include (CheckSymbolExists )
74
+ include (HunterGate )
52
75
include (VersionFromGit )
53
76
77
+
54
78
# Define options
55
79
# ==============
56
80
@@ -60,6 +84,8 @@ option(ENABLE_GUI "Enable Qt-based GUI" OFF)
60
84
option (ENABLE_DOCS "Build Doxygen documentation" OFF )
61
85
option (ENABLE_TESTS "Build tests" OFF )
62
86
option (LUPDATE "Update translation files" OFF )
87
+ option (STATIC_LIBS "Prefer static variants of system libraries" ${WIN32} )
88
+ option (STATIC_RUNTIME "Link runtime statically" ${WIN32} )
63
89
64
90
# CPU-dependent options
65
91
option (ENABLE_SSE41 "Build code that uses SSE4.1 intrinsics" ${HAS_SSE41} )
@@ -74,30 +100,51 @@ option(ENABLE_QRENCODE "Enable generation of QR Codes for receiving payments" O
74
100
option (ENABLE_UPNP "Enable UPnP port mapping support" OFF )
75
101
option (DEFAULT_UPNP "Turn UPnP on startup" OFF )
76
102
option (USE_DBUS "Enable DBus support" OFF )
103
+
104
+ # Bundled packages
77
105
option (SYSTEM_BDB "Find system installation of Berkeley DB CXX 5.3" OFF )
78
106
option (SYSTEM_LEVELDB "Find system installation of leveldb" OFF )
79
107
option (SYSTEM_SECP256K1 "Find system installation of libsecp256k1 with pkg-config" OFF )
80
108
option (SYSTEM_UNIVALUE "Find system installation of Univalue with pkg-config" OFF )
81
109
option (SYSTEM_XXD "Find system xxd binary" OFF )
82
110
111
+ # Hunter packages
112
+ option (BUNDLED_BOOST "Use the bundled version of Boost" ${HUNTER_ENABLED} )
113
+ option (BUNDLED_CURL "Use the bundled version of cURL" ${HUNTER_ENABLED} )
114
+ option (BUNDLED_LIBZIP "Use the bundled version of libzip" ${HUNTER_ENABLED} )
115
+ option (BUNDLED_OPENSSL "Use the bundled version of OpenSSL" ${HUNTER_ENABLED} )
116
+ option (BUNDLED_QT "Use the bundled version of Qt" ${HUNTER_ENABLED} )
83
117
84
- # Find dependencies
85
- # =================
118
+
119
+ # Handle dependencies
120
+ # ===================
121
+
122
+ set (QT5_MINIMUM_VERSION 5.9.5 )
123
+ set (QT5_COMPONENTS Concurrent Core Gui LinguistTools Network Widgets )
124
+ set (QT5_HUNTER_COMPONENTS qtbase qttools )
125
+ if (USE_DBUS )
126
+ list (APPEND QT5_COMPONENTS DBus )
127
+ endif ()
128
+ if (ENABLE_TESTS )
129
+ list (APPEND QT5_COMPONENTS Test )
130
+ endif ()
86
131
87
132
set (BOOST_MINIMUM_VERSION 1.63.0 )
88
- set (QT5_MINIMUM_VERSION 5.15.0 )
133
+ set (BOOST_COMPONENTS filesystem iostreams thread )
134
+ set (BOOST_HUNTER_COMPONENTS ${BOOST_COMPONENTS} )
135
+ if (ENABLE_TESTS )
136
+ list (APPEND BOOST_COMPONENTS unit_test_framework )
137
+ list (APPEND BOOST_HUNTER_COMPONENTS test )
138
+ endif ()
89
139
90
140
find_package (Atomics REQUIRED )
91
- find_package (Boost ${BOOST_MINIMUM_VERSION} COMPONENTS filesystem iostreams thread REQUIRED )
92
- find_package (CURL COMPONENTS HTTP HTTPS SSL REQUIRED )
93
- find_package (OpenSSL REQUIRED )
94
141
find_package (Threads REQUIRED )
95
- find_package (libzip REQUIRED )
96
142
97
143
if (SYSTEM_BDB )
98
144
find_package (BerkeleyDB 5.3...<5.4 COMPONENTS CXX REQUIRED )
99
145
else ()
100
- find_program (MAKE_EXE NAMES gmake nmake make )
146
+ find_program (SH_EXE NAMES sh bash REQUIRED )
147
+ find_program (MAKE_EXE NAMES gmake nmake make REQUIRED )
101
148
endif ()
102
149
103
150
if (SYSTEM_LEVELDB )
@@ -114,35 +161,59 @@ if(SYSTEM_UNIVALUE)
114
161
pkg_check_modules (UNIVALUE REQUIRED IMPORTED_TARGET libunivalue )
115
162
endif ()
116
163
117
- if (ENABLE_GUI )
118
- find_package (Qt5 ${QT5_MINIMUM_VERSION} REQUIRED COMPONENTS
119
- Concurrent
120
- Core
121
- Gui
122
- LinguistTools
123
- Network
124
- Widgets
125
- )
126
-
127
- if (USE_DBUS )
128
- find_package (Qt5 ${QT5_MINIMUM_VERSION} COMPONENTS DBus REQUIRED )
129
- endif ()
164
+ if (BUNDLED_BOOST )
165
+ hunter_add_package (Boost COMPONENTS ${BOOST_HUNTER_COMPONENTS} )
166
+ endif ()
167
+ find_package (Boost ${BOOST_MINIMUM_VERSION} COMPONENTS ${BOOST_COMPONENTS} CONFIG REQUIRED )
168
+
169
+ if (BUNDLED_OPENSSL )
170
+ hunter_add_package (OpenSSL )
171
+ endif ()
172
+ find_package (OpenSSL REQUIRED )
173
+
174
+ if (BUNDLED_CURL )
175
+ hunter_add_package (CURL )
176
+ find_package (CURL CONFIG REQUIRED )
177
+ else ()
178
+ find_package (CURL REQUIRED )
179
+ endif ()
180
+
181
+ if (BUNDLED_LIBZIP )
182
+ hunter_add_package (libzip )
183
+ endif ()
184
+ find_package (libzip CONFIG REQUIRED )
185
+
186
+ if (USE_ASM )
187
+ enable_language (ASM )
188
+ endif ()
130
189
131
- if (ENABLE_TESTS )
132
- find_package (Qt5 ${QT5_MINIMUM_VERSION} COMPONENTS Test REQUIRED )
190
+ if (ENABLE_GUI )
191
+ if (BUNDLED_QT )
192
+ hunter_add_package (Qt COMPONENTS ${QT5_HUNTER_COMPONENTS} )
133
193
endif ()
194
+ find_package (Qt5 ${QT5_MINIMUM_VERSION} COMPONENTS ${QT5_COMPONENTS} REQUIRED )
134
195
135
196
if (ENABLE_QRENCODE )
136
197
pkg_check_modules (QRENCODE REQUIRED IMPORTED_TARGET libqrencode )
137
198
endif ()
199
+
200
+ # Compatibility macros
201
+ if (Qt5Core_VERSION VERSION_LESS 5.15.0 )
202
+ macro (qt_create_translation )
203
+ qt5_create_translation (${ARGN} )
204
+ endmacro ()
205
+
206
+ macro (qt_add_translation )
207
+ qt5_add_translation (${ARGN} )
208
+ endmacro ()
209
+ endif ()
138
210
endif ()
139
211
140
212
if (ENABLE_UPNP )
141
213
pkg_check_modules (MINIUPNPC REQUIRED IMPORTED_TARGET miniupnpc>=1.9 )
142
214
endif ()
143
215
144
216
if (ENABLE_TESTS )
145
- find_package (Boost ${BOOST_MINIMUM_VERSION} COMPONENTS unit_test_framework REQUIRED )
146
217
enable_testing ()
147
218
148
219
if (SYSTEM_XXD )
@@ -175,12 +246,25 @@ endif()
175
246
set (CMAKE_POSITION_INDEPENDENT_CODE ${ENABLE_PIE} )
176
247
177
248
# Set compiler flags
178
- if (APPLE )
249
+ if (APPLE )
179
250
add_compile_options (-Wno-error=deprecated-declarations )
180
251
add_compile_options (-Wno-error=thread-safety-analysis )
181
252
add_compile_options (-Wno-error=thread-safety-reference )
182
253
endif ()
183
254
255
+ if (STATIC_LIBS )
256
+ set (CMAKE_LINK_SEARCH_START_STATIC ON )
257
+ set (CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_STATIC_LIBRARY_SUFFIX} " )
258
+ endif ()
259
+
260
+ if (STATIC_RUNTIME )
261
+ if (CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|Clang)\$ " )
262
+ list (APPEND RUNTIME_LIBS -static-libgcc -static-libstdc++ )
263
+ elseif (MSVC )
264
+ set (CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>" )
265
+ endif ()
266
+ endif ()
267
+
184
268
# Set endianness
185
269
if (CMAKE_CXX_BYTE_ORDER EQUAL BIG_ENDIAN )
186
270
set (WORDS_BIGENDIAN 1 )
0 commit comments