Skip to content
Bitcoin Roots

v30.3-roots.1 · Commit 1: [PATCH 01/68] build: adapt Roots platform support to Core 30.3

CMakeLists.txt

Before: CMakeLists.txt · After: CMakeLists.txt

File metadata
index 0e4c72c06551d88c8b43185905976b0178140d4a..69537baa706f5736d75e8a5c6c625fc019b8aaf3 100644

Download original patch · Release notes

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

+ Added− RemovedUnmarked lines are context.

Scroll the code area horizontally to read long lines. Before is on the left; after is on the right. Unified view fits narrow screens more easily.

CMakeLists.txt CHANGED
@@ -57,15 +57,15 @@ project(BitcoinCore
57
  LANGUAGES NONE
58
  )
59
 
 
 
 
 
60
  set(CLIENT_VERSION_STRING ${PROJECT_VERSION})
61
  if(CLIENT_VERSION_RC GREATER 0)
62
  string(APPEND CLIENT_VERSION_STRING "rc${CLIENT_VERSION_RC}")
63
  endif()
64
 
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
  #=============================
70
  # Language setup
71
  #=============================
@@ -97,6 +97,8 @@ include(CMakeDependentOption)
97
  option(BUILD_BITCOIN_BIN "Build bitcoin executable." ON)
98
  option(BUILD_DAEMON "Build bitcoind executable." ON)
99
  option(BUILD_GUI "Build bitcoin-qt executable." OFF)
 
 
100
  option(BUILD_CLI "Build bitcoin-cli executable." ON)
101
 
102
  option(BUILD_TESTS "Build test_bitcoin and other unit test executables." ON)
@@ -106,6 +108,56 @@ option(BUILD_UTIL "Build bitcoin-util executable." ${BUILD_TESTS})
106
  option(BUILD_UTIL_CHAINSTATE "Build experimental bitcoin-chainstate executable." OFF)
107
  option(BUILD_KERNEL_LIB "Build experimental bitcoinkernel library." ${BUILD_UTIL_CHAINSTATE})
108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  option(ENABLE_WALLET "Enable wallet." ON)
110
  if(ENABLE_WALLET)
111
  if(VCPKG_TARGET_TRIPLET)
@@ -125,6 +177,11 @@ option(REDUCE_EXPORTS "Attempt to reduce exported symbols in the resulting execu
125
  option(WERROR "Treat compiler warnings as errors." OFF)
126
  option(WITH_CCACHE "Attempt to use ccache for compiling." ON)
127
 
 
 
 
 
 
128
  option(WITH_ZMQ "Enable ZMQ notifications." OFF)
129
  if(WITH_ZMQ)
130
  find_package(ZeroMQ 4.0.0 MODULE REQUIRED)
@@ -137,6 +194,8 @@ endif()
137
 
138
  option(ENABLE_EXTERNAL_SIGNER "Enable external signer support." ON)
139
 
 
 
140
  cmake_dependent_option(WITH_QRENCODE "Enable QR code support." ON "BUILD_GUI" OFF)
141
  if(WITH_QRENCODE)
142
  find_package(QRencode MODULE REQUIRED)
@@ -145,6 +204,8 @@ endif()
145
 
146
  cmake_dependent_option(WITH_DBUS "Enable DBus support." ON "NOT CMAKE_SYSTEM_NAME MATCHES \"(Windows|Darwin)\" AND BUILD_GUI" OFF)
147
 
 
 
148
  cmake_dependent_option(ENABLE_IPC "Build multiprocess bitcoin-node and bitcoin-gui executables in addition to monolithic bitcoind and bitcoin-qt executables." ON "NOT WIN32" OFF)
149
  cmake_dependent_option(WITH_EXTERNAL_LIBMULTIPROCESS "Build with external libmultiprocess library instead of with local git subtree when ENABLE_IPC is enabled. This is not normally recommended, but can be useful for developing libmultiprocess itself." OFF "ENABLE_IPC" OFF)
150
  if(ENABLE_IPC AND WITH_EXTERNAL_LIBMULTIPROCESS)
@@ -164,12 +225,21 @@ if(BUILD_GUI)
164
  list(APPEND qt_components DBus)
165
  set(USE_DBUS TRUE)
166
  endif()
 
 
 
167
  if(BUILD_GUI_TESTS)
168
  list(APPEND qt_components Test)
169
  endif()
170
- find_package(Qt 6.2 MODULE REQUIRED
171
- COMPONENTS ${qt_components}
172
- )
 
 
 
 
 
 
173
  unset(qt_components)
174
  endif()
175
 
@@ -217,6 +287,7 @@ if(BUILD_FOR_FUZZING)
217
  set(BUILD_WALLET_TOOL OFF)
218
  set(BUILD_GUI OFF)
219
  set(ENABLE_EXTERNAL_SIGNER OFF)
 
220
  set(WITH_ZMQ OFF)
221
  set(BUILD_TESTS OFF)
222
  set(BUILD_GUI_TESTS OFF)
@@ -229,9 +300,20 @@ if(BUILD_FOR_FUZZING)
229
  )
230
  endif()
231
 
 
 
 
 
 
 
232
  include(TryAppendCXXFlags)
233
  include(TryAppendLinkerFlag)
234
 
 
 
 
 
 
235
  # Redefine/adjust per-configuration flags.
236
  target_compile_definitions(core_interface_debug INTERFACE
237
  DEBUG
@@ -307,6 +389,13 @@ if(WIN32)
307
  # As a best effort, target Windows 8.
308
  try_append_linker_flag("-Wl,--major-subsystem-version,6" TARGET core_interface)
309
  try_append_linker_flag("-Wl,--minor-subsystem-version,2" TARGET core_interface)
 
 
 
 
 
 
 
310
  endif()
311
 
312
  # Workaround producing large object files, which cannot be handled by the assembler.
@@ -421,8 +510,12 @@ if(BUILD_DAEMON OR BUILD_GUI OR BUILD_CLI OR BUILD_TESTS OR BUILD_BENCH OR BUILD
421
  find_package(Libevent 2.1.8 MODULE REQUIRED)
422
  endif()
423
 
 
 
424
  include(cmake/introspection.cmake)
425
 
 
 
426
  include(cmake/ccache.cmake)
427
 
428
  add_library(warn_interface INTERFACE)
@@ -460,7 +553,7 @@ else()
460
  try_append_cxx_flags("-Woverloaded-virtual" TARGET warn_interface SKIP_LINK)
461
  try_append_cxx_flags("-Wsuggest-override" TARGET warn_interface SKIP_LINK)
462
  try_append_cxx_flags("-Wimplicit-fallthrough" TARGET warn_interface SKIP_LINK)
463
- try_append_cxx_flags("-Wunreachable-code" TARGET warn_interface SKIP_LINK)
464
  try_append_cxx_flags("-Wdocumentation" TARGET warn_interface SKIP_LINK)
465
  try_append_cxx_flags("-Wself-assign" TARGET warn_interface SKIP_LINK)
466
  try_append_cxx_flags("-Wbidi-chars=any" TARGET warn_interface SKIP_LINK)
@@ -581,6 +674,7 @@ if(WERROR)
581
  unset(werror_flag)
582
  endif()
583
 
 
584
  # Prefer Unix-style package components over frameworks on macOS.
585
  # This improves compatibility with Python version managers.
586
  set(Python3_FIND_FRAMEWORK LAST CACHE STRING "")
@@ -588,13 +682,28 @@ set(Python3_FIND_FRAMEWORK LAST CACHE STRING "")
588
  # improves compatibility with Python version managers that use shims.
589
  set(Python3_FIND_UNVERSIONED_NAMES FIRST CACHE STRING "")
590
  mark_as_advanced(Python3_FIND_FRAMEWORK Python3_FIND_UNVERSIONED_NAMES)
591
- find_package(Python3 3.10 COMPONENTS Interpreter)
 
 
 
 
592
  if(NOT TARGET Python3::Interpreter)
593
  list(APPEND configure_warnings
594
  "Minimum required Python not found."
595
  )
596
  endif()
597
 
 
 
 
 
 
 
 
 
 
 
 
598
  target_compile_definitions(core_interface INTERFACE ${DEPENDS_COMPILE_DEFINITIONS})
599
  target_compile_definitions(core_interface_relwithdebinfo INTERFACE ${DEPENDS_COMPILE_DEFINITIONS_RELWITHDEBINFO})
600
  target_compile_definitions(core_interface_debug INTERFACE ${DEPENDS_COMPILE_DEFINITIONS_DEBUG})
@@ -627,7 +736,6 @@ endif()
627
  if(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
628
  set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
629
  else()
630
- set(CMAKE_SKIP_BUILD_RPATH TRUE)
631
  set(CMAKE_SKIP_INSTALL_RPATH TRUE)
632
  endif()
633
  add_subdirectory(test)
@@ -653,7 +761,7 @@ else()
653
  set(bitcoin_daemon_status OFF)
654
  endif()
655
  message(" bitcoin-node (multiprocess) ......... ${bitcoin_daemon_status}")
656
- message(" bitcoin-qt (GUI) .................... ${BUILD_GUI}")
657
  if(BUILD_GUI AND ENABLE_IPC)
658
  set(bitcoin_gui_status ON)
659
  else()
@@ -669,6 +777,8 @@ message(" libbitcoinkernel (experimental) ..... ${BUILD_KERNEL_LIB}")
669
  message("Optional features:")
670
  message(" wallet support ...................... ${ENABLE_WALLET}")
671
  message(" external signer ..................... ${ENABLE_EXTERNAL_SIGNER}")
 
 
672
  message(" ZeroMQ .............................. ${WITH_ZMQ}")
673
  if(ENABLE_IPC)
674
  if (WITH_EXTERNAL_LIBMULTIPROCESS)
 
57
  LANGUAGES NONE
58
  )
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
+
64
  set(CLIENT_VERSION_STRING ${PROJECT_VERSION})
65
  if(CLIENT_VERSION_RC GREATER 0)
66
  string(APPEND CLIENT_VERSION_STRING "rc${CLIENT_VERSION_RC}")
67
  endif()
68
 
 
 
 
 
69
  #=============================
70
  # Language setup
71
  #=============================
 
97
  option(BUILD_BITCOIN_BIN "Build bitcoin executable." ON)
98
  option(BUILD_DAEMON "Build bitcoind executable." ON)
99
  option(BUILD_GUI "Build bitcoin-qt executable." OFF)
100
+ set(WITH_QT_VERSION "6" CACHE STRING "Choose 5 or 6.")
101
+ set_property(CACHE WITH_QT_VERSION PROPERTY STRINGS "5" "6")
102
  option(BUILD_CLI "Build bitcoin-cli executable." ON)
103
 
104
  option(BUILD_TESTS "Build test_bitcoin and other unit test executables." ON)
 
108
  option(BUILD_UTIL_CHAINSTATE "Build experimental bitcoin-chainstate executable." OFF)
109
  option(BUILD_KERNEL_LIB "Build experimental bitcoinkernel library." ${BUILD_UTIL_CHAINSTATE})
110
 
111
+ option(WITH_SYSTEM_LEVELDB "Build with system LevelDB instead of embedded fork." OFF)
112
+ mark_as_advanced(WITH_SYSTEM_LEVELDB)
113
+ if(WITH_SYSTEM_LEVELDB)
114
+ find_package(LevelDB MODULE REQUIRED)
115
+ else()
116
+ set(EMBEDDED_LEVELDB TRUE)
117
+ endif() # WITH_SYSTEM_LEVELDB
118
+
119
+ option(WITH_SYSTEM_LIBSECP256K1 "Build with system libsecp256k1 instead of embedded copy." OFF)
120
+ mark_as_advanced(WITH_SYSTEM_LIBSECP256K1)
121
+ if(WITH_SYSTEM_LIBSECP256K1)
122
+ find_package(PkgConfig REQUIRED)
123
+ pkg_check_modules(libsecp256k1 REQUIRED IMPORTED_TARGET libsecp256k1)
124
+ add_library(secp256k1 ALIAS PkgConfig::libsecp256k1)
125
+
126
+ 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 AND libsecp256k1_HAS_SECP256K1_MUSIG_PUBKEY_AGG))
127
+ include(CheckSymbolExists)
128
+ include(CMakePushCheckState)
129
+ cmake_push_check_state(RESET)
130
+ string(APPEND CMAKE_REQUIRED_FLAGS " ${libsecp256k1_CFLAGS_OTHER}")
131
+ list(APPEND CMAKE_REQUIRED_INCLUDES ${libsecp256k1_INCLUDE_DIRS})
132
+ list(APPEND CMAKE_REQUIRED_LINK_OPTIONS ${libsecp256k1_LDFLAGS})
133
+ list(APPEND CMAKE_REQUIRED_LIBRARIES ${libsecp256k1_LIBRARIES})
134
+ unset(missing_modules)
135
+ macro(check_secp256k1_module module symbol)
136
+ string(TOUPPER "${symbol}" VAR)
137
+ set(VAR "libsecp256k1_HAS_${VAR}")
138
+ unset(${VAR})
139
+ check_symbol_exists("${symbol}" "secp256k1_${module}.h" ${VAR})
140
+ if(NOT ${VAR})
141
+ list(APPEND missing_modules "${module}")
142
+ endif()
143
+ endmacro()
144
+ message(CHECK_START "Checking for required libsecp256k1 modules")
145
+ list(APPEND CMAKE_MESSAGE_INDENT " ")
146
+ check_secp256k1_module(ellswift secp256k1_ellswift_create)
147
+ check_secp256k1_module(extrakeys secp256k1_xonly_pubkey_parse)
148
+ check_secp256k1_module(recovery secp256k1_ecdsa_recover)
149
+ check_secp256k1_module(schnorrsig secp256k1_schnorrsig_verify)
150
+ check_secp256k1_module(musig secp256k1_musig_pubkey_agg)
151
+ list(POP_BACK CMAKE_MESSAGE_INDENT)
152
+ if(missing_modules)
153
+ list(JOIN missing_modules ", " missing_modules)
154
+ message(FATAL_ERROR "System-installed libsecp256k1 lacks these required modules: ${missing_modules}.")
155
+ endif()
156
+ message(CHECK_PASS "all were found")
157
+ cmake_pop_check_state()
158
+ endif()
159
+ endif() # WITH_SYSTEM_LIBSECP256K1
160
+
161
  option(ENABLE_WALLET "Enable wallet." ON)
162
  if(ENABLE_WALLET)
163
  if(VCPKG_TARGET_TRIPLET)
 
177
  option(WERROR "Treat compiler warnings as errors." OFF)
178
  option(WITH_CCACHE "Attempt to use ccache for compiling." ON)
179
 
180
+ option(WITH_MINIUPNPC "Enable UPnP." OFF)
181
+ if(WITH_MINIUPNPC)
182
+ find_package(MiniUPnPc MODULE REQUIRED)
183
+ endif()
184
+
185
  option(WITH_ZMQ "Enable ZMQ notifications." OFF)
186
  if(WITH_ZMQ)
187
  find_package(ZeroMQ 4.0.0 MODULE REQUIRED)
 
194
 
195
  option(ENABLE_EXTERNAL_SIGNER "Enable external signer support." ON)
196
 
197
+ option(ENABLE_TOR_SUBPROCESS "Enable support for executing a dedicated Tor node." ON)
198
+
199
  cmake_dependent_option(WITH_QRENCODE "Enable QR code support." ON "BUILD_GUI" OFF)
200
  if(WITH_QRENCODE)
201
  find_package(QRencode MODULE REQUIRED)
 
204
 
205
  cmake_dependent_option(WITH_DBUS "Enable DBus support." ON "NOT CMAKE_SYSTEM_NAME MATCHES \"(Windows|Darwin)\" AND BUILD_GUI" OFF)
206
 
207
+ cmake_dependent_option(WITH_TASKBAR_PROGRESS "Enable GUI taskbar progress." ON "CMAKE_SYSTEM_NAME STREQUAL \"Windows\" AND BUILD_GUI" OFF)
208
+
209
  cmake_dependent_option(ENABLE_IPC "Build multiprocess bitcoin-node and bitcoin-gui executables in addition to monolithic bitcoind and bitcoin-qt executables." ON "NOT WIN32" OFF)
210
  cmake_dependent_option(WITH_EXTERNAL_LIBMULTIPROCESS "Build with external libmultiprocess library instead of with local git subtree when ENABLE_IPC is enabled. This is not normally recommended, but can be useful for developing libmultiprocess itself." OFF "ENABLE_IPC" OFF)
211
  if(ENABLE_IPC AND WITH_EXTERNAL_LIBMULTIPROCESS)
 
225
  list(APPEND qt_components DBus)
226
  set(USE_DBUS TRUE)
227
  endif()
228
+ if(WITH_TASKBAR_PROGRESS)
229
+ set(BITCOIN_QT_WIN_TASKBAR TRUE)
230
+ endif()
231
  if(BUILD_GUI_TESTS)
232
  list(APPEND qt_components Test)
233
  endif()
234
+ if("${WITH_QT_VERSION}" STREQUAL "6")
235
+ find_package(Qt 6.2 MODULE REQUIRED
236
+ COMPONENTS ${qt_components}
237
+ )
238
+ else() # ! Qt 6
239
+ find_package(Qt 5.11.3 MODULE REQUIRED
240
+ COMPONENTS ${qt_components}
241
+ )
242
+ endif() # Qt 6
243
  unset(qt_components)
244
  endif()
245
 
 
287
  set(BUILD_WALLET_TOOL OFF)
288
  set(BUILD_GUI OFF)
289
  set(ENABLE_EXTERNAL_SIGNER OFF)
290
+ set(WITH_MINIUPNPC OFF)
291
  set(WITH_ZMQ OFF)
292
  set(BUILD_TESTS OFF)
293
  set(BUILD_GUI_TESTS OFF)
 
300
  )
301
  endif()
302
 
303
+ # The external_lib_interface interface library aims to encapsulate build flags, which
304
+ # are specific to non-internal libraries.
305
+ # It is intended to be a usage requirement for non-internal library
306
+ # targets.
307
+ add_library(external_lib_interface INTERFACE)
308
+
309
  include(TryAppendCXXFlags)
310
  include(TryAppendLinkerFlag)
311
 
312
+ # Sanitizers require leaving undefined symbols in the library
313
+ if(NOT SANITIZERS)
314
+ try_append_linker_flag("-Wl,--no-undefined" TARGET external_lib_interface)
315
+ endif()
316
+
317
  # Redefine/adjust per-configuration flags.
318
  target_compile_definitions(core_interface_debug INTERFACE
319
  DEBUG
 
389
  # As a best effort, target Windows 8.
390
  try_append_linker_flag("-Wl,--major-subsystem-version,6" TARGET core_interface)
391
  try_append_linker_flag("-Wl,--minor-subsystem-version,2" TARGET core_interface)
392
+
393
+ find_library(MINGWTHRD_LIBRARY mingwthrd)
394
+ if (MINGWTHRD_LIBRARY)
395
+ target_link_libraries(core_interface INTERFACE
396
+ ${MINGWTHRD_LIBRARY}
397
+ )
398
+ endif()
399
  endif()
400
 
401
  # Workaround producing large object files, which cannot be handled by the assembler.
 
510
  find_package(Libevent 2.1.8 MODULE REQUIRED)
511
  endif()
512
 
513
+ include(cmake/iopriority.cmake)
514
+
515
  include(cmake/introspection.cmake)
516
 
517
+ include(cmake/mempressure.cmake)
518
+
519
  include(cmake/ccache.cmake)
520
 
521
  add_library(warn_interface INTERFACE)
 
553
  try_append_cxx_flags("-Woverloaded-virtual" TARGET warn_interface SKIP_LINK)
554
  try_append_cxx_flags("-Wsuggest-override" TARGET warn_interface SKIP_LINK)
555
  try_append_cxx_flags("-Wimplicit-fallthrough" TARGET warn_interface SKIP_LINK)
556
+ try_append_cxx_flags("-Wunreachable-code-loop-increment" TARGET warn_interface SKIP_LINK)
557
  try_append_cxx_flags("-Wdocumentation" TARGET warn_interface SKIP_LINK)
558
  try_append_cxx_flags("-Wself-assign" TARGET warn_interface SKIP_LINK)
559
  try_append_cxx_flags("-Wbidi-chars=any" TARGET warn_interface SKIP_LINK)
 
674
  unset(werror_flag)
675
  endif()
676
 
677
+
678
  # Prefer Unix-style package components over frameworks on macOS.
679
  # This improves compatibility with Python version managers.
680
  set(Python3_FIND_FRAMEWORK LAST CACHE STRING "")
 
682
  # improves compatibility with Python version managers that use shims.
683
  set(Python3_FIND_UNVERSIONED_NAMES FIRST CACHE STRING "")
684
  mark_as_advanced(Python3_FIND_FRAMEWORK Python3_FIND_UNVERSIONED_NAMES)
685
+ if(BUILD_GUI)
686
+ find_package(Python3 3.10 REQUIRED COMPONENTS Interpreter)
687
+ else()
688
+ find_package(Python3 3.10 COMPONENTS Interpreter)
689
+ endif()
690
  if(NOT TARGET Python3::Interpreter)
691
  list(APPEND configure_warnings
692
  "Minimum required Python not found."
693
  )
694
  endif()
695
 
696
+ if(BUILD_GUI)
697
+ find_program(RSVG_CONVERT rsvg-convert REQUIRED)
698
+ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
699
+ find_program(IMAGEMAGICK_CONVERT NAMES magick convert)
700
+ find_program(PNG2ICNS png2icns REQUIRED)
701
+ else()
702
+ find_program(IMAGEMAGICK_CONVERT NAMES magick convert REQUIRED)
703
+ find_program(PNG2ICNS png2icns)
704
+ endif()
705
+ endif()
706
+
707
  target_compile_definitions(core_interface INTERFACE ${DEPENDS_COMPILE_DEFINITIONS})
708
  target_compile_definitions(core_interface_relwithdebinfo INTERFACE ${DEPENDS_COMPILE_DEFINITIONS_RELWITHDEBINFO})
709
  target_compile_definitions(core_interface_debug INTERFACE ${DEPENDS_COMPILE_DEFINITIONS_DEBUG})
 
736
  if(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
737
  set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
738
  else()
 
739
  set(CMAKE_SKIP_INSTALL_RPATH TRUE)
740
  endif()
741
  add_subdirectory(test)
 
761
  set(bitcoin_daemon_status OFF)
762
  endif()
763
  message(" bitcoin-node (multiprocess) ......... ${bitcoin_daemon_status}")
764
+ message(" bitcoin-qt (GUI) .................... ${BUILD_GUI} (Qt ${WITH_QT_VERSION})")
765
  if(BUILD_GUI AND ENABLE_IPC)
766
  set(bitcoin_gui_status ON)
767
  else()
 
777
  message("Optional features:")
778
  message(" wallet support ...................... ${ENABLE_WALLET}")
779
  message(" external signer ..................... ${ENABLE_EXTERNAL_SIGNER}")
780
+ message(" tor subprocess ...................... ${ENABLE_TOR_SUBPROCESS}")
781
+ message(" port mapping using UPnP ............. ${WITH_MINIUPNPC}")
782
  message(" ZeroMQ .............................. ${WITH_ZMQ}")
783
  if(ENABLE_IPC)
784
  if (WITH_EXTERNAL_LIBMULTIPROCESS)