|
| 1 | +# Copyright (c) 2023 The Bitcoin Core developers |
| 2 | +# Distributed under the MIT software license, see the accompanying |
| 3 | +# file COPYING or http://www.opensource.org/licenses/mit-license.php. |
| 4 | + |
| 5 | +# IMPORTANT: Changes which affect binary results may not be quietly gated |
| 6 | +# by CMake version. |
| 7 | +# |
| 8 | +# Debian 10 Buster, https://wiki.debian.org/LTS, EOL 2024: |
| 9 | +# - CMake 3.13.4, https://packages.debian.org/buster/cmake |
| 10 | +# |
| 11 | +# Ubuntu 22.04 Jammy, https://wiki.ubuntu.com/Releases, EOL 2032: |
| 12 | +# - CMake 3.22.1, https://packages.ubuntu.com/jammy/cmake |
| 13 | +# |
| 14 | +# Visual Studio 17 2022, https://visualstudio.microsoft.com: |
| 15 | +# - CMake 3.24 |
| 16 | +# |
| 17 | +# All policies known to the running version of CMake and introduced |
| 18 | +# in the 3.24 version or earlier will be set to use NEW behavior. |
| 19 | +# All policies introduced in later versions will be unset. |
| 20 | +# See: https://cmake.org/cmake/help/latest/manual/cmake-policies.7.html |
| 21 | +cmake_minimum_required(VERSION 3.13...3.24) |
| 22 | + |
| 23 | +project("Bitcoin Core" |
| 24 | + VERSION 24.99.0 |
| 25 | + DESCRIPTION "Bitcoin client software" |
| 26 | + HOMEPAGE_URL "https://bitcoincore.org/" |
| 27 | + LANGUAGES CXX C ASM |
| 28 | +) |
| 29 | + |
| 30 | +set(CLIENT_VERSION_IS_RELEASE "false") |
| 31 | +set(COPYRIGHT_YEAR "2023") |
| 32 | +set(COPYRIGHT_HOLDERS "The %s developers") |
| 33 | +set(COPYRIGHT_HOLDERS_FINAL "The ${PROJECT_NAME} developers") |
| 34 | +set(PACKAGE_BUGREPORT "https://github.com/bitcoin/bitcoin/issues") |
| 35 | + |
| 36 | +# Configurable options. |
| 37 | +# When adding a new option, end the <help_text> with a full stop for consistency. |
| 38 | +include(CMakeDependentOption) |
| 39 | +cmake_dependent_option(CXX20 "Enable compilation in C++20 mode." OFF "NOT MSVC" ON) |
| 40 | + |
| 41 | +if(CXX20) |
| 42 | + set(CMAKE_CXX_STANDARD 20) |
| 43 | +else() |
| 44 | + set(CMAKE_CXX_STANDARD 17) |
| 45 | +endif() |
| 46 | +set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 47 | +set(CMAKE_CXX_EXTENSIONS OFF) |
| 48 | + |
| 49 | +set(configure_warnings) |
| 50 | +if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.14) |
| 51 | + include(CheckPIESupported) |
| 52 | + check_pie_supported(OUTPUT_VARIABLE check_pie_output LANGUAGES CXX) |
| 53 | + if(NOT CMAKE_CXX_LINK_PIE_SUPPORTED) |
| 54 | + list(APPEND configure_warnings "PIE link options are not supported for executable targets: ${check_pie_output}.") |
| 55 | + endif() |
| 56 | +else() |
| 57 | + list(APPEND configure_warnings "No PIE options will be passed to a linker for executable targets.") |
| 58 | +endif() |
| 59 | +set(CMAKE_POSITION_INDEPENDENT_CODE ON) |
| 60 | + |
| 61 | +add_subdirectory(src) |
| 62 | + |
| 63 | +message("\n") |
| 64 | +message("Configure summary") |
| 65 | +message("=================") |
| 66 | +get_directory_property(definitions COMPILE_DEFINITIONS) |
| 67 | +string(REPLACE ";" " " definitions "${definitions}") |
| 68 | +message("Preprocessor defined macros ........... ${definitions}") |
| 69 | +message("C compiler ............................ ${CMAKE_C_COMPILER}") |
| 70 | +message("CFLAGS ................................ ${CMAKE_C_FLAGS}") |
| 71 | +message("C++ compiler .......................... ${CMAKE_CXX_COMPILER}") |
| 72 | +message("CXXFLAGS .............................. ${CMAKE_CXX_FLAGS}") |
| 73 | +get_directory_property(common_compile_options COMPILE_OPTIONS) |
| 74 | +string(REPLACE ";" " " common_compile_options "${common_compile_options}") |
| 75 | +message("Common compile options ................ ${common_compile_options}") |
| 76 | +get_directory_property(common_link_options LINK_OPTIONS) |
| 77 | +string(REPLACE ";" " " common_link_options "${common_link_options}") |
| 78 | +message("Common link options ................... ${common_link_options}") |
| 79 | +if(DEFINED CMAKE_BUILD_TYPE) |
| 80 | + message("Build type:") |
| 81 | + message(" - CMAKE_BUILD_TYPE ................... ${CMAKE_BUILD_TYPE}") |
| 82 | + string(TOUPPER "${CMAKE_BUILD_TYPE}" build_type) |
| 83 | + message(" - CFLAGS ............................. ${CMAKE_C_FLAGS_${build_type}}") |
| 84 | + message(" - CXXFLAGS ........................... ${CMAKE_CXX_FLAGS_${build_type}}") |
| 85 | + message(" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_${build_type}}") |
| 86 | + message(" - LDFLAGS for shared libraries ....... ${CMAKE_SHARED_LINKER_FLAGS_${build_type}}") |
| 87 | +else() |
| 88 | + message("Available configurations .............. ${CMAKE_CONFIGURATION_TYPES}") |
| 89 | + message("Debug configuration:") |
| 90 | + message(" - CFLAGS ............................. ${CMAKE_C_FLAGS_DEBUG}") |
| 91 | + message(" - CXXFLAGS ........................... ${CMAKE_CXX_FLAGS_DEBUG}") |
| 92 | + message(" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_DEBUG}") |
| 93 | + message(" - LDFLAGS for shared libraries ....... ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}") |
| 94 | + message("Release configuration:") |
| 95 | + message(" - CFLAGS ............................. ${CMAKE_C_FLAGS_RELEASE}") |
| 96 | + message(" - CXXFLAGS ........................... ${CMAKE_CXX_FLAGS_RELEASE}") |
| 97 | + message(" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_RELEASE}") |
| 98 | + message(" - LDFLAGS for shared libraries ....... ${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") |
| 99 | +endif() |
| 100 | +message("\n") |
| 101 | +if(configure_warnings) |
| 102 | + message(" ******\n") |
| 103 | + foreach(warning IN LISTS configure_warnings) |
| 104 | + message(WARNING "${warning}") |
| 105 | + endforeach() |
| 106 | + message(" ******\n") |
| 107 | +endif() |
0 commit comments