|
|
|
# Copyright (c) 2023-present The Bitcoin Core developers
|
|
|
|
# Distributed under the MIT software license, see the accompanying
|
|
|
|
# file COPYING or https://opensource.org/license/mit/.
|
|
|
|
|
|
|
|
# Ubuntu 22.04 LTS Jammy Jellyfish, https://wiki.ubuntu.com/Releases, EOSS in June 2027:
|
|
|
|
# - CMake 3.22.1, https://packages.ubuntu.com/jammy/cmake
|
|
|
|
#
|
|
|
|
# Centos Stream 9, 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.")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
#=============================
|
|
|
|
# Project / Package metadata
|
|
|
|
#=============================
|
|
|
|
set(PACKAGE_NAME "Bitcoin Core")
|
|
|
|
set(CLIENT_VERSION_MAJOR 27)
|
|
|
|
set(CLIENT_VERSION_MINOR 99)
|
|
|
|
set(CLIENT_VERSION_BUILD 0)
|
|
|
|
set(CLIENT_VERSION_RC 0)
|
|
|
|
set(CLIENT_VERSION_IS_RELEASE "false")
|
|
|
|
set(COPYRIGHT_YEAR "2024")
|
|
|
|
|
|
|
|
project(BitcoinCore
|
|
|
|
VERSION ${CLIENT_VERSION_MAJOR}.${CLIENT_VERSION_MINOR}.${CLIENT_VERSION_BUILD}
|
|
|
|
DESCRIPTION "Bitcoin client software"
|
|
|
|
HOMEPAGE_URL "https://bitcoincore.org/"
|
|
|
|
LANGUAGES NONE
|
|
|
|
)
|
|
|
|
|
|
|
|
set(PACKAGE_VERSION ${PROJECT_VERSION})
|
|
|
|
if(CLIENT_VERSION_RC GREATER 0)
|
|
|
|
string(APPEND PACKAGE_VERSION "rc${CLIENT_VERSION_RC}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(COPYRIGHT_HOLDERS "The %s developers")
|
|
|
|
set(COPYRIGHT_HOLDERS_FINAL "The ${PACKAGE_NAME} developers")
|
|
|
|
set(PACKAGE_BUGREPORT "https://github.com/bitcoin/bitcoin/issues")
|
|
|
|
|
|
|
|
#=============================
|
|
|
|
# Language setup
|
|
|
|
#=============================
|
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT CMAKE_HOST_APPLE)
|
|
|
|
# We do not use the install_name_tool when cross-compiling for macOS.
|
|
|
|
# So disable this tool check in further enable_language() commands.
|
|
|
|
set(CMAKE_PLATFORM_HAS_INSTALLNAME FALSE)
|
|
|
|
endif()
|
|
|
|
enable_language(CXX)
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
|
|
|
|
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/module)
|
|
|
|
|
|
|
|
set(configure_warnings)
|
|
|
|
|
|
|
|
include(CheckPIESupported)
|
|
|
|
check_pie_supported(OUTPUT_VARIABLE check_pie_output LANGUAGES CXX)
|
|
|
|
if(CMAKE_CXX_LINK_PIE_SUPPORTED)
|
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
|
|
elseif(NOT WIN32)
|
|
|
|
# The warning is superfluous for Windows.
|
|
|
|
message(WARNING "PIE is not supported at link time: ${check_pie_output}")
|
|
|
|
list(APPEND configure_warnings "Position independent code disabled.")
|
|
|
|
endif()
|
|
|
|
unset(check_pie_output)
|
|
|
|
|
|
|
|
# The core_interface library aims to encapsulate common build flags.
|
|
|
|
# It is a usage requirement for all targets except for secp256k1, which
|
|
|
|
# gets its flags by other means.
|
|
|
|
add_library(core_interface INTERFACE)
|
|
|
|
add_library(core_interface_relwithdebinfo INTERFACE)
|
|
|
|
add_library(core_interface_debug INTERFACE)
|
|
|
|
target_link_libraries(core_interface INTERFACE
|
|
|
|
$<$<CONFIG:RelWithDebInfo>:core_interface_relwithdebinfo>
|
|
|
|
$<$<CONFIG:Debug>:core_interface_debug>
|
|
|
|
)
|
|
|
|
|
|
|
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
target_link_libraries(core_base_interface INTERFACE
|
|
|
|
Threads::Threads
|
|
|
|
)
|
|
|
|
|
|
|
|
include(cmake/introspection.cmake)
|
|
|
|
|
|
|
|
# TODO: The `CMAKE_SKIP_BUILD_RPATH` variable setting can be deleted
|
|
|
|
# in the future after reordering Guix script commands to
|
|
|
|
# perform binary checks after the installation step.
|
|
|
|
# Relevant discussions:
|
|
|
|
# - https://github.com/hebasto/bitcoin/pull/236#issuecomment-2183120953
|
|
|
|
# - https://github.com/bitcoin/bitcoin/pull/30312#issuecomment-2191235833
|
|
|
|
set(CMAKE_SKIP_BUILD_RPATH TRUE)
|
|
|
|
set(CMAKE_SKIP_INSTALL_RPATH TRUE)
|
|
|
|
add_subdirectory(src)
|
|
|
|
|
|
|
|
message("\n")
|
|
|
|
message("Configure summary")
|
|
|
|
message("=================")
|
|
|
|
message("C++ compiler .......................... ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}, ${CMAKE_CXX_COMPILER}")
|
|
|
|
include(FlagsSummary)
|
|
|
|
flags_summary()
|
|
|
|
message("\n")
|
|
|
|
if(configure_warnings)
|
|
|
|
message(" ******\n")
|
|
|
|
foreach(warning IN LISTS configure_warnings)
|
|
|
|
message(WARNING "${warning}")
|
|
|
|
endforeach()
|
|
|
|
message(" ******\n")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# We want all build properties to be encapsulated properly.
|
|
|
|
include(WarnAboutGlobalProperties)
|