diff options
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 60 |
1 files changed, 27 insertions, 33 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ef80ffc6f..edc4710637 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,12 +8,6 @@ # Centos Stream 9, https://www.centos.org/cl-vs-cs/#end-of-life, EOL in May 2027: # - CMake 3.26.5, https://mirror.stream.centos.org/9-stream/AppStream/x86_64/os/Packages/ cmake_minimum_required(VERSION 3.22) -if(POLICY CMP0141) - # MSVC debug information format flags are selected by an abstraction. - # We want to use the CMAKE_MSVC_DEBUG_INFORMATION_FORMAT variable - # to select the MSVC debug information format. - cmake_policy(SET CMP0141 NEW) -endif() if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) message(FATAL_ERROR "In-source builds are not allowed.") @@ -103,14 +97,12 @@ if(WITH_SQLITE) find_package(SQLite3 3.7.17 REQUIRED) endif() set(USE_SQLITE ON) - set(ENABLE_WALLET ON) endif() option(WITH_BDB "Enable Berkeley DB (BDB) wallet support." OFF) cmake_dependent_option(WARN_INCOMPATIBLE_BDB "Warn when using a Berkeley DB (BDB) version other than 4.8." ON "WITH_BDB" OFF) if(WITH_BDB) find_package(BerkeleyDB 4.8 MODULE REQUIRED) set(USE_BDB ON) - set(ENABLE_WALLET ON) if(NOT BerkeleyDB_VERSION VERSION_EQUAL 4.8) message(WARNING "Found Berkeley DB (BDB) other than 4.8.\n" "BDB (legacy) wallets opened by this build will not be portable!" @@ -129,11 +121,6 @@ option(REDUCE_EXPORTS "Attempt to reduce exported symbols in the resulting execu option(WERROR "Treat compiler warnings as errors." OFF) option(WITH_CCACHE "Attempt to use ccache for compiling." ON) -option(WITH_NATPMP "Enable NAT-PMP." OFF) -if(WITH_NATPMP) - find_package(NATPMP MODULE REQUIRED) -endif() - option(WITH_MINIUPNPC "Enable UPnP." OFF) if(WITH_MINIUPNPC) find_package(MiniUPnPc MODULE REQUIRED) @@ -145,7 +132,9 @@ if(WITH_ZMQ) find_package(ZeroMQ CONFIG REQUIRED) else() # The ZeroMQ project has provided config files since v4.2.2. - # TODO: Switch to find_package(ZeroMQ) at some point in the future. + # However, mainstream distributions do not yet provide CMake + # config files for ZeroMQ packages. If they do in the future, + # find_package(ZeroMQ) may be used instead. find_package(PkgConfig REQUIRED) pkg_check_modules(libzmq REQUIRED IMPORTED_TARGET libzmq>=4) endif() @@ -188,7 +177,7 @@ if(BUILD_GUI) if(BUILD_GUI_TESTS) list(APPEND qt_components Test) endif() - find_package(Qt5 5.11.3 MODULE REQUIRED + find_package(Qt 5.11.3 MODULE REQUIRED COMPONENTS ${qt_components} ) unset(qt_components) @@ -196,7 +185,7 @@ endif() option(BUILD_BENCH "Build bench_bitcoin executable." OFF) option(BUILD_FUZZ_BINARY "Build fuzz binary." OFF) -cmake_dependent_option(BUILD_FOR_FUZZING "Build for fuzzing. Enabling this will disable all other targets and override BUILD_FUZZ_BINARY." OFF "NOT MSVC" OFF) +option(BUILD_FOR_FUZZING "Build for fuzzing. Enabling this will disable all other targets and override BUILD_FUZZ_BINARY." OFF) option(INSTALL_MAN "Install man pages." ON) @@ -245,7 +234,6 @@ if(BUILD_FOR_FUZZING) set(BUILD_WALLET_TOOL OFF) set(BUILD_GUI OFF) set(ENABLE_EXTERNAL_SIGNER OFF) - set(WITH_NATPMP OFF) set(WITH_MINIUPNPC OFF) set(WITH_ZMQ OFF) set(BUILD_TESTS OFF) @@ -255,6 +243,7 @@ if(BUILD_FOR_FUZZING) target_compile_definitions(core_interface INTERFACE ABORT_ON_FAILED_ASSUME + FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION ) endif() @@ -458,10 +447,10 @@ else() ) endif() -configure_file(cmake/script/Coverage.cmake Coverage.cmake COPYONLY) -configure_file(cmake/script/CoverageFuzz.cmake CoverageFuzz.cmake COPYONLY) -configure_file(cmake/script/CoverageInclude.cmake.in CoverageInclude.cmake @ONLY) -configure_file(contrib/filter-lcov.py filter-lcov.py COPYONLY) +configure_file(cmake/script/Coverage.cmake Coverage.cmake USE_SOURCE_PERMISSIONS COPYONLY) +configure_file(cmake/script/CoverageFuzz.cmake CoverageFuzz.cmake USE_SOURCE_PERMISSIONS COPYONLY) +configure_file(cmake/script/CoverageInclude.cmake.in CoverageInclude.cmake USE_SOURCE_PERMISSIONS @ONLY) +configure_file(contrib/filter-lcov.py filter-lcov.py USE_SOURCE_PERMISSIONS COPYONLY) # Don't allow extended (non-ASCII) symbols in identifiers. This is easier for code review. try_append_cxx_flags("-fno-extended-identifiers" TARGET core_interface SKIP_LINK) @@ -480,18 +469,21 @@ if(ENABLE_HARDENING) try_append_linker_flag("/HIGHENTROPYVA" TARGET hardening_interface) try_append_linker_flag("/NXCOMPAT" TARGET hardening_interface) else() + + # _FORTIFY_SOURCE requires that there is some level of optimization, + # otherwise it does nothing and just creates a compiler warning. try_append_cxx_flags("-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3" RESULT_VAR cxx_supports_fortify_source + SOURCE "int main() { + # if !defined __OPTIMIZE__ || __OPTIMIZE__ <= 0 + #error + #endif + }" ) if(cxx_supports_fortify_source) - # When the build configuration is Debug, all optimizations are disabled. - # However, _FORTIFY_SOURCE requires that there is some level of optimization, - # otherwise it does nothing and just creates a compiler warning. - # Since _FORTIFY_SOURCE is a no-op without optimizations, do not enable it - # when the build configuration is Debug. target_compile_options(hardening_interface INTERFACE - $<$<NOT:$<CONFIG:Debug>>:-U_FORTIFY_SOURCE> - $<$<NOT:$<CONFIG:Debug>>:-D_FORTIFY_SOURCE=3> + -U_FORTIFY_SOURCE + -D_FORTIFY_SOURCE=3 ) endif() unset(cxx_supports_fortify_source) @@ -509,7 +501,11 @@ if(ENABLE_HARDENING) endif() if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64") - try_append_cxx_flags("-mbranch-protection=bti" TARGET hardening_interface SKIP_LINK) + if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + try_append_cxx_flags("-mbranch-protection=bti" TARGET hardening_interface SKIP_LINK) + else() + try_append_cxx_flags("-mbranch-protection=standard" TARGET hardening_interface SKIP_LINK) + endif() endif() try_append_linker_flag("-Wl,--enable-reloc-section" TARGET hardening_interface) @@ -544,7 +540,7 @@ if(WERROR) unset(werror_flag) endif() -find_package(Python3 3.9 COMPONENTS Interpreter) +find_package(Python3 3.10 COMPONENTS Interpreter) if(Python3_EXECUTABLE) set(PYTHON_COMMAND ${Python3_EXECUTABLE}) else() @@ -619,9 +615,7 @@ if(ENABLE_WALLET) message(" - legacy wallets (Berkeley DB) ..... ${WITH_BDB}") endif() message(" external signer ..................... ${ENABLE_EXTERNAL_SIGNER}") -message(" port mapping:") -message(" - using NAT-PMP .................... ${WITH_NATPMP}") -message(" - using UPnP ....................... ${WITH_MINIUPNPC}") +message(" port mapping using UPnP ............. ${WITH_MINIUPNPC}") message(" ZeroMQ .............................. ${WITH_ZMQ}") message(" USDT tracing ........................ ${WITH_USDT}") message(" QR code (GUI) ....................... ${WITH_QRENCODE}") |