Skip to content
Bitcoin Roots

v29.4-roots.2 · Commit 1: [PATCH 01/21] build: port platform and dependency support

CMakeLists.txt

Before: CMakeLists.txt · After: CMakeLists.txt

File metadata
index 46980b32db8962c39ada7536d60d65ae814128e7..84f22c14968dd6fd6afb14d4ae05a7628b4fe844 100644

Download original patch · Release notes

Diff rows 1–276 of 276. Line numbers refer to the original before/after files.

+ Added− RemovedUnmarked lines are context.

Scroll the code area horizontally to read long lines. The two line-number columns refer to before and after.

CMakeLists.txt CHANGED
@@ -57,15 +57,15 @@ project(BitcoinCore
57
57
  LANGUAGES NONE
58
58
  )
59
59
 
60
+ set(COPYRIGHT_HOLDERS "The %s developers")
61
+ set(COPYRIGHT_HOLDERS_FINAL "The ${CLIENT_NAME} developers")
62
+ set(CLIENT_BUGREPORT "https://github.com/bitcoin/bitcoin/issues")
63
+
60
64
  set(CLIENT_VERSION_STRING ${PROJECT_VERSION})
61
65
  if(CLIENT_VERSION_RC GREATER 0)
62
66
  string(APPEND CLIENT_VERSION_STRING "rc${CLIENT_VERSION_RC}")
63
67
  endif()
64
68
 
65
- set(COPYRIGHT_HOLDERS "The %s developers")
66
- set(COPYRIGHT_HOLDERS_FINAL "The ${CLIENT_NAME} developers")
67
- set(CLIENT_BUGREPORT "https://github.com/bitcoin/bitcoin/issues")
68
-
69
69
  #=============================
70
70
  # Language setup
71
71
  #=============================
@@ -96,6 +96,8 @@ include(CMakeDependentOption)
96
96
  # When adding a new option, end the <help_text> with a full stop for consistency.
97
97
  option(BUILD_DAEMON "Build bitcoind executable." ON)
98
98
  option(BUILD_GUI "Build bitcoin-qt executable." OFF)
99
+ set(WITH_QT_VERSION "5" CACHE STRING "Choose 5 or 6.")
100
+ set_property(CACHE WITH_QT_VERSION PROPERTY STRINGS "5" "6")
99
101
  option(BUILD_CLI "Build bitcoin-cli executable." ON)
100
102
 
101
103
  option(BUILD_TESTS "Build test_bitcoin executable." ON)
@@ -105,6 +107,55 @@ option(BUILD_UTIL "Build bitcoin-util executable." ${BUILD_TESTS})
105
107
  option(BUILD_UTIL_CHAINSTATE "Build experimental bitcoin-chainstate executable." OFF)
106
108
  option(BUILD_KERNEL_LIB "Build experimental bitcoinkernel library." ${BUILD_UTIL_CHAINSTATE})
107
109
 
110
+ option(WITH_SYSTEM_LEVELDB "Build with system LevelDB instead of embedded fork." OFF)
111
+ mark_as_advanced(WITH_SYSTEM_LEVELDB)
112
+ if(WITH_SYSTEM_LEVELDB)
113
+ find_package(LevelDB MODULE REQUIRED)
114
+ else()
115
+ set(EMBEDDED_LEVELDB TRUE)
116
+ endif() # WITH_SYSTEM_LEVELDB
117
+
118
+ option(WITH_SYSTEM_LIBSECP256K1 "Build with system libsecp256k1 instead of embedded copy." OFF)
119
+ mark_as_advanced(WITH_SYSTEM_LIBSECP256K1)
120
+ if(WITH_SYSTEM_LIBSECP256K1)
121
+ find_package(PkgConfig REQUIRED)
122
+ pkg_check_modules(libsecp256k1 REQUIRED IMPORTED_TARGET libsecp256k1)
123
+ add_library(secp256k1 ALIAS PkgConfig::libsecp256k1)
124
+
125
+ if(NOT (libsecp256k1_HAS_SECP256K1_ELLSWIFT_CREATE AND libsecp256k1_HAS_SECP256K1_XONLY_PUBKEY_PARSE AND libsecp256k1_HAS_SECP256K1_ECDSA_RECOVER AND libsecp256k1_HAS_SECP256K1_SCHNORRSIG_VERIFY))
126
+ include(CheckSymbolExists)
127
+ include(CMakePushCheckState)
128
+ cmake_push_check_state(RESET)
129
+ string(APPEND CMAKE_REQUIRED_FLAGS " ${libsecp256k1_CFLAGS_OTHER}")
130
+ list(APPEND CMAKE_REQUIRED_INCLUDES ${libsecp256k1_INCLUDE_DIRS})
131
+ list(APPEND CMAKE_REQUIRED_LINK_OPTIONS ${libsecp256k1_LDFLAGS})
132
+ list(APPEND CMAKE_REQUIRED_LIBRARIES ${libsecp256k1_LIBRARIES})
133
+ unset(missing_modules)
134
+ macro(check_secp256k1_module module symbol)
135
+ string(TOUPPER "${symbol}" VAR)
136
+ set(VAR "libsecp256k1_HAS_${VAR}")
137
+ unset(${VAR})
138
+ check_symbol_exists("${symbol}" "secp256k1_${module}.h" ${VAR})
139
+ if(NOT ${VAR})
140
+ list(APPEND missing_modules "${module}")
141
+ endif()
142
+ endmacro()
143
+ message(CHECK_START "Checking for required libsecp256k1 modules")
144
+ list(APPEND CMAKE_MESSAGE_INDENT " ")
145
+ check_secp256k1_module(ellswift secp256k1_ellswift_create)
146
+ check_secp256k1_module(extrakeys secp256k1_xonly_pubkey_parse)
147
+ check_secp256k1_module(recovery secp256k1_ecdsa_recover)
148
+ check_secp256k1_module(schnorrsig secp256k1_schnorrsig_verify)
149
+ list(POP_BACK CMAKE_MESSAGE_INDENT)
150
+ if(missing_modules)
151
+ list(JOIN missing_modules ", " missing_modules)
152
+ message(FATAL_ERROR "System-installed libsecp256k1 lacks these required modules: ${missing_modules}.")
153
+ endif()
154
+ message(CHECK_PASS "all were found")
155
+ cmake_pop_check_state()
156
+ endif()
157
+ endif() # WITH_SYSTEM_LIBSECP256K1
158
+
108
159
  option(ENABLE_WALLET "Enable wallet." ON)
109
160
  option(WITH_SQLITE "Enable SQLite wallet support." ${ENABLE_WALLET})
110
161
  if(WITH_SQLITE)
@@ -130,7 +181,7 @@ if(WITH_BDB)
130
181
  "BDB (legacy) wallets opened by this build will not be portable!"
131
182
  )
132
183
  if(WARN_INCOMPATIBLE_BDB)
133
- message(WARNING "If this is intended, pass \"-DWARN_INCOMPATIBLE_BDB=OFF\".\n"
184
+ message(FATAL_ERROR "If this is intended, pass \"-DWARN_INCOMPATIBLE_BDB=OFF\".\n"
134
185
  "Passing \"-DWITH_BDB=OFF\" will suppress this warning."
135
186
  )
136
187
  endif()
@@ -143,6 +194,11 @@ option(REDUCE_EXPORTS "Attempt to reduce exported symbols in the resulting execu
143
194
  option(WERROR "Treat compiler warnings as errors." OFF)
144
195
  option(WITH_CCACHE "Attempt to use ccache for compiling." ON)
145
196
 
197
+ option(WITH_MINIUPNPC "Enable UPnP." OFF)
198
+ if(WITH_MINIUPNPC)
199
+ find_package(MiniUPnPc MODULE REQUIRED)
200
+ endif()
201
+
146
202
  option(WITH_ZMQ "Enable ZMQ notifications." OFF)
147
203
  if(WITH_ZMQ)
148
204
  find_package(ZeroMQ 4.0.0 MODULE REQUIRED)
@@ -153,7 +209,9 @@ if(WITH_USDT)
153
209
  find_package(USDT MODULE REQUIRED)
154
210
  endif()
155
211
 
156
- cmake_dependent_option(ENABLE_EXTERNAL_SIGNER "Enable external signer support." ON "NOT WIN32" OFF)
212
+ option(ENABLE_EXTERNAL_SIGNER "Enable external signer support." ON)
213
+
214
+ option(ENABLE_TOR_SUBPROCESS "Enable support for executing a dedicated Tor node." ON)
157
215
 
158
216
  cmake_dependent_option(WITH_QRENCODE "Enable QR code support." ON "BUILD_GUI" OFF)
159
217
  if(WITH_QRENCODE)
@@ -163,7 +221,9 @@ endif()
163
221
 
164
222
  cmake_dependent_option(WITH_DBUS "Enable DBus support." ON "NOT CMAKE_SYSTEM_NAME MATCHES \"(Windows|Darwin)\" AND BUILD_GUI" OFF)
165
223
 
166
- option(WITH_MULTIPROCESS "Build multiprocess bitcoin-node and bitcoin-gui executables in addition to monolithic bitcoind and bitcoin-qt executables. Requires libmultiprocess library. Experimental." OFF)
224
+ cmake_dependent_option(WITH_TASKBAR_PROGRESS "Enable GUI taskbar progress." ON "CMAKE_SYSTEM_NAME STREQUAL \"Windows\" AND BUILD_GUI" OFF)
225
+
226
+ set(WITH_MULTIPROCESS OFF)
167
227
  if(WITH_MULTIPROCESS)
168
228
  find_package(Libmultiprocess REQUIRED COMPONENTS Lib)
169
229
  find_package(LibmultiprocessNative REQUIRED COMPONENTS Bin
@@ -181,12 +241,21 @@ if(BUILD_GUI)
181
241
  list(APPEND qt_components DBus)
182
242
  set(USE_DBUS TRUE)
183
243
  endif()
244
+ if(WITH_TASKBAR_PROGRESS)
245
+ set(BITCOIN_QT_WIN_TASKBAR TRUE)
246
+ endif()
184
247
  if(BUILD_GUI_TESTS)
185
248
  list(APPEND qt_components Test)
186
249
  endif()
250
+ if("${WITH_QT_VERSION}" STREQUAL "6")
251
+ find_package(Qt 6.2 MODULE REQUIRED
252
+ COMPONENTS ${qt_components}
253
+ )
254
+ else() # ! Qt 6
187
255
  find_package(Qt 5.11.3 MODULE REQUIRED
188
256
  COMPONENTS ${qt_components}
189
257
  )
258
+ endif() # Qt 6
190
259
  unset(qt_components)
191
260
  endif()
192
261
 
@@ -233,6 +302,7 @@ if(BUILD_FOR_FUZZING)
233
302
  set(BUILD_WALLET_TOOL OFF)
234
303
  set(BUILD_GUI OFF)
235
304
  set(ENABLE_EXTERNAL_SIGNER OFF)
305
+ set(WITH_MINIUPNPC OFF)
236
306
  set(WITH_ZMQ OFF)
237
307
  set(BUILD_TESTS OFF)
238
308
  set(BUILD_GUI_TESTS OFF)
@@ -244,9 +314,20 @@ if(BUILD_FOR_FUZZING)
244
314
  )
245
315
  endif()
246
316
 
317
+ # The external_lib_interface interface library aims to encapsulate build flags, which
318
+ # are specific to non-internal libraries.
319
+ # It is intended to be a usage requirement for non-internal library
320
+ # targets.
321
+ add_library(external_lib_interface INTERFACE)
322
+
247
323
  include(TryAppendCXXFlags)
248
324
  include(TryAppendLinkerFlag)
249
325
 
326
+ # Sanitizers require leaving undefined symbols in the library
327
+ if(NOT SANITIZERS)
328
+ try_append_linker_flag("-Wl,--no-undefined" TARGET external_lib_interface)
329
+ endif()
330
+
250
331
  # Redefine/adjust per-configuration flags.
251
332
  target_compile_definitions(core_interface_debug INTERFACE
252
333
  DEBUG
@@ -318,6 +399,13 @@ if(WIN32)
318
399
  # As a best effort, target Windows 8.
319
400
  try_append_linker_flag("-Wl,--major-subsystem-version,6" TARGET core_interface)
320
401
  try_append_linker_flag("-Wl,--minor-subsystem-version,2" TARGET core_interface)
402
+
403
+ find_library(MINGWTHRD_LIBRARY mingwthrd)
404
+ if (MINGWTHRD_LIBRARY)
405
+ target_link_libraries(core_interface INTERFACE
406
+ ${MINGWTHRD_LIBRARY}
407
+ )
408
+ endif()
321
409
  endif()
322
410
 
323
411
  # Workaround producing large object files, which cannot be handled by the assembler.
@@ -413,8 +501,12 @@ if(BUILD_DAEMON OR BUILD_GUI OR BUILD_CLI OR BUILD_TESTS OR BUILD_BENCH OR BUILD
413
501
  find_package(Libevent 2.1.8 MODULE REQUIRED)
414
502
  endif()
415
503
 
504
+ include(cmake/iopriority.cmake)
505
+
416
506
  include(cmake/introspection.cmake)
417
507
 
508
+ include(cmake/mempressure.cmake)
509
+
418
510
  include(cmake/ccache.cmake)
419
511
 
420
512
  add_library(warn_interface INTERFACE)
@@ -451,7 +543,7 @@ else()
451
543
  try_append_cxx_flags("-Woverloaded-virtual" TARGET warn_interface SKIP_LINK)
452
544
  try_append_cxx_flags("-Wsuggest-override" TARGET warn_interface SKIP_LINK)
453
545
  try_append_cxx_flags("-Wimplicit-fallthrough" TARGET warn_interface SKIP_LINK)
454
- try_append_cxx_flags("-Wunreachable-code" TARGET warn_interface SKIP_LINK)
546
+ try_append_cxx_flags("-Wunreachable-code-loop-increment" TARGET warn_interface SKIP_LINK)
455
547
  try_append_cxx_flags("-Wdocumentation" TARGET warn_interface SKIP_LINK)
456
548
  try_append_cxx_flags("-Wself-assign" TARGET warn_interface SKIP_LINK)
457
549
  try_append_cxx_flags("-Wbidi-chars=any" TARGET warn_interface SKIP_LINK)
@@ -570,6 +662,7 @@ if(WERROR)
570
662
  unset(werror_flag)
571
663
  endif()
572
664
 
665
+
573
666
  # Prefer Unix-style package components over frameworks on macOS.
574
667
  # This improves compatibility with Python version managers.
575
668
  set(Python3_FIND_FRAMEWORK LAST CACHE STRING "")
@@ -577,7 +670,11 @@ set(Python3_FIND_FRAMEWORK LAST CACHE STRING "")
577
670
  # improves compatibility with Python version managers that use shims.
578
671
  set(Python3_FIND_UNVERSIONED_NAMES FIRST CACHE STRING "")
579
672
  mark_as_advanced(Python3_FIND_FRAMEWORK Python3_FIND_UNVERSIONED_NAMES)
673
+ if(BUILD_GUI)
674
+ find_package(Python3 3.10 REQUIRED COMPONENTS Interpreter)
675
+ else()
580
676
  find_package(Python3 3.10 COMPONENTS Interpreter)
677
+ endif()
581
678
  if(Python3_EXECUTABLE)
582
679
  set(PYTHON_COMMAND ${Python3_EXECUTABLE})
583
680
  else()
@@ -586,6 +683,17 @@ else()
586
683
  )
587
684
  endif()
588
685
 
686
+ if(BUILD_GUI)
687
+ find_program(RSVG_CONVERT rsvg-convert REQUIRED)
688
+ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
689
+ find_program(IMAGEMAGICK_CONVERT NAMES magick convert)
690
+ find_program(PNG2ICNS png2icns REQUIRED)
691
+ else()
692
+ find_program(IMAGEMAGICK_CONVERT NAMES magick convert REQUIRED)
693
+ find_program(PNG2ICNS png2icns)
694
+ endif()
695
+ endif()
696
+
589
697
  target_compile_definitions(core_interface INTERFACE ${DEPENDS_COMPILE_DEFINITIONS})
590
698
  target_compile_definitions(core_interface_relwithdebinfo INTERFACE ${DEPENDS_COMPILE_DEFINITIONS_RELWITHDEBINFO})
591
699
  target_compile_definitions(core_interface_debug INTERFACE ${DEPENDS_COMPILE_DEFINITIONS_DEBUG})
@@ -618,7 +726,6 @@ endif()
618
726
  if(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
619
727
  set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
620
728
  else()
621
- set(CMAKE_SKIP_BUILD_RPATH TRUE)
622
729
  set(CMAKE_SKIP_INSTALL_RPATH TRUE)
623
730
  endif()
624
731
  add_subdirectory(test)
@@ -644,14 +751,21 @@ if(BUILD_DAEMON AND WITH_MULTIPROCESS)
644
751
  else()
645
752
  set(bitcoin_daemon_status OFF)
646
753
  endif()
647
- message(" bitcoin-node (multiprocess) ......... ${bitcoin_daemon_status}")
648
- message(" bitcoin-qt (GUI) .................... ${BUILD_GUI}")
754
+ if(BUILD_GUI)
755
+ if("${WITH_QT_VERSION}" STREQUAL "6")
756
+ set(bitcoin_qt_status "ON (Qt 6)")
757
+ else()
758
+ set(bitcoin_qt_status "ON (Qt 5)")
759
+ endif()
760
+ else()
761
+ set(bitcoin_qt_status "OFF")
762
+ endif()
763
+ message(" bitcoin-qt (GUI) .................... ${bitcoin_qt_status}")
649
764
  if(BUILD_GUI AND WITH_MULTIPROCESS)
650
765
  set(bitcoin_gui_status ON)
651
766
  else()
652
767
  set(bitcoin_gui_status OFF)
653
768
  endif()
654
- message(" bitcoin-gui (GUI, multiprocess) ..... ${bitcoin_gui_status}")
655
769
  message(" bitcoin-cli ......................... ${BUILD_CLI}")
656
770
  message(" bitcoin-tx .......................... ${BUILD_TX}")
657
771
  message(" bitcoin-util ........................ ${BUILD_UTIL}")
@@ -665,6 +779,8 @@ if(ENABLE_WALLET)
665
779
  message(" - legacy wallets (Berkeley DB) ..... ${WITH_BDB}")
666
780
  endif()
667
781
  message(" external signer ..................... ${ENABLE_EXTERNAL_SIGNER}")
782
+ message(" tor subprocess ...................... ${ENABLE_TOR_SUBPROCESS}")
783
+ message(" port mapping using UPnP ............. ${WITH_MINIUPNPC}")
668
784
  message(" ZeroMQ .............................. ${WITH_ZMQ}")
669
785
  message(" USDT tracing ........................ ${WITH_USDT}")
670
786
  message(" QR code (GUI) ....................... ${WITH_QRENCODE}")