Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebased cmake-staging branch (post PR#13) #14

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
440f63c
cmake: Add root `CMakeLists.txt` file
hebasto Mar 31, 2023
a9b2f8e
cmake: Add `config/bitcoin-config.h` support
hebasto Feb 15, 2023
0e657cc
cmake: Add `cmake/introspection.cmake` file
hebasto Mar 31, 2023
b7e1d20
cmake: Check system headers
hebasto Feb 21, 2023
4299b74
cmake: Check system symbols
hebasto Feb 23, 2023
3226c35
cmake: Check compiler features
hebasto Feb 23, 2023
b2eb7cb
cmake: Build `crc32c` static library
hebasto Feb 23, 2023
5548833
cmake: Build `leveldb` static library
hebasto Feb 23, 2023
b495951
cmake: Add essential platform-specific definitions and options
hebasto Feb 28, 2023
2a281d7
cmake: Add `CheckStdFilesystem` module
hebasto Feb 28, 2023
af60b9d
cmake: Build `minisketch` static library
hebasto Feb 28, 2023
d75bc81
cmake: Build `secp256k1` static library
hebasto Mar 31, 2023
037d577
cmake: Build `univalue` static library
hebasto Feb 28, 2023
c105fb6
cmake: Build `bitcoin_crypto` library
hebasto Feb 28, 2023
492a439
cmake: Build `bitcoin_util` static library
hebasto Apr 19, 2023
4cc0a78
cmake: Build `bitcoin_consensus` library
hebasto Feb 28, 2023
68578e5
cmake: Build `bitcoind` executable
hebasto Apr 21, 2023
00955dd
build: Generate `share/toolchain.cmake` in depends
hebasto Mar 24, 2023
c3f1fcb
cmake: Add cross-compiling support
hebasto Mar 12, 2023
79a4a09
cmake: Add `TristateOption` module
hebasto Apr 13, 2023
9263298
cmake: Add `ccache` support
hebasto Apr 13, 2023
0379928
cmake: Add `libnatpmp` optional package support
hebasto Apr 6, 2023
8abe0bf
cmake: Add `libminiupnpc` optional package support
hebasto Apr 6, 2023
e352ac6
cmake: Add `libzmq` optional package support
hebasto Apr 13, 2023
d439a1b
cmake: Add `systemtap-sdt` optional package support
hebasto Aug 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
206 changes: 206 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
# Copyright (c) 2023 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

# IMPORTANT: Changes which affect binary results may not be quietly gated
# by CMake version.
#
# Debian 10 Buster, https://wiki.debian.org/LTS, EOL 2024:
# - CMake 3.13.4, https://packages.debian.org/buster/cmake
#
# Ubuntu 22.04 Jammy, https://wiki.ubuntu.com/Releases, EOL 2032:
# - CMake 3.22.1, https://packages.ubuntu.com/jammy/cmake
#
# Visual Studio 17 2022, https://visualstudio.microsoft.com:
# - CMake 3.24
#
# All policies known to the running version of CMake and introduced
# in the 3.24 version or earlier will be set to use NEW behavior.
# All policies introduced in later versions will be unset.
# See: https://cmake.org/cmake/help/latest/manual/cmake-policies.7.html
cmake_minimum_required(VERSION 3.13...3.24)

project("Bitcoin Core"
VERSION 24.99.0
DESCRIPTION "Bitcoin client software"
HOMEPAGE_URL "https://bitcoincore.org/"
LANGUAGES CXX ASM
)

set(CLIENT_VERSION_IS_RELEASE "false")
set(COPYRIGHT_YEAR "2023")
set(COPYRIGHT_HOLDERS "The %s developers")
set(COPYRIGHT_HOLDERS_FINAL "The ${PROJECT_NAME} developers")
set(PACKAGE_BUGREPORT "https://github.com/bitcoin/bitcoin/issues")

list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/module)

# Configurable options.
# When adding a new option, end the <help_text> with a full stop for consistency.
include(CMakeDependentOption)
option(BUILD_DAEMON "Build bitcoind executable." ON)
option(ASM "Use assembly routines." ON)
cmake_dependent_option(CXX20 "Enable compilation in C++20 mode." OFF "NOT MSVC" ON)
option(THREADLOCAL "Enable features that depend on the C++ thread_local keyword (currently just thread names in debug logs)." ON)

# TODO: These tri-state options will be removed and most features
# will become opt-in by default before merging into master.
include(TristateOption)
tristate_option(CCACHE "Use ccache for compiling." "if ccache is found." AUTO)
tristate_option(WITH_NATPMP "Enable NAT-PMP." "if libnatpmp is found." AUTO)
tristate_option(WITH_MINIUPNPC "Enable UPnP." "if libminiupnpc is found." AUTO)
tristate_option(WITH_ZMQ "Enable ZMQ notifications." "if libzmq is found." AUTO)
tristate_option(WITH_USDT
"Enable tracepoints for Userspace, Statically Defined Tracing."
"if sys/sdt.h is found."
AUTO
)

if(CXX20)
set(CMAKE_CXX_STANDARD 20)
else()
set(CMAKE_CXX_STANDARD 17)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

set(configure_warnings)

if(WIN32)
#[=[
This build system supports two ways to build binaries for Windows.

1. Building on Windows using MSVC.
Implementation notes:
- /DWIN32 and /D_WINDOWS definitions are included into the CMAKE_CXX_FLAGS_INIT
and CMAKE_CXX_FLAGS_INIT variables by default.
- A run-time library is selected using the CMAKE_MSVC_RUNTIME_LIBRARY variable.
- MSVC-specific options, for example, /Zc:__cplusplus, are additionally required.

2. Cross-compiling using MinGW.
Implementation notes:
- WIN32 and _WINDOWS definitions must be provided explicitly.
- A run-time library must be specified explicitly using _MT definition.
]=]

add_compile_definitions(_WIN32_WINNT=0x0601 _WIN32_IE=0x0501 WIN32_LEAN_AND_MEAN NOMINMAX)

if(MSVC)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
add_compile_options(/utf-8 /Zc:__cplusplus)
endif()

if(MINGW)
add_compile_definitions(WIN32 _WINDOWS _MT)
# We require Windows 7 (NT 6.1) or later.
add_link_options(-Wl,--major-subsystem-version,6 -Wl,--minor-subsystem-version,1)
endif()
endif()

if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
add_compile_definitions(MAC_OSX)
endif()

if(CMAKE_CROSSCOMPILING AND DEPENDS_ALLOW_HOST_PACKAGES)
list(APPEND CMAKE_FIND_ROOT_PATH "${CMAKE_SYSTEM_PREFIX_PATH}")
endif()

include(AddThreadsIfNeeded)
add_threads_if_needed()

include(AddBoostIfNeeded)
add_boost_if_needed()

include(CheckSourceCompilesAndLinks)

include(AddLibeventIfNeeded)
add_libevent_if_needed()

include(cmake/introspection.cmake)

include(cmake/crc32c.cmake)
include(cmake/leveldb.cmake)
include(cmake/minisketch.cmake)
include(cmake/secp256k1.cmake)

include(CheckStdFilesystem)
check_std_filesystem()

include(cmake/optional.cmake)

if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.14)
include(CheckPIESupported)
check_pie_supported(OUTPUT_VARIABLE check_pie_output LANGUAGES CXX)
if(CMAKE_CXX_LINK_PIE_SUPPORTED)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
else()
check_cxx_source_links_with_flags(-fPIE "int main(){}" COMPILER_SUPPORTS_PIE)
if(COMPILER_SUPPORTS_PIE)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
endif()

add_subdirectory(src)

message("\n")
message("Configure summary")
message("=================")
message("Executables:")
message(" bitcoind ............................ ${BUILD_DAEMON}")
message("Optional packages:")
message(" NAT-PMP ............................. ${WITH_NATPMP}")
message(" UPnP ................................ ${WITH_MINIUPNPC}")
message(" ZeroMQ .............................. ${WITH_ZMQ}")
message(" USDT tracing ........................ ${WITH_USDT}")
message("")
if(CMAKE_CROSSCOMPILING)
set(cross_status "TRUE, for ${CMAKE_SYSTEM_NAME}, ${CMAKE_SYSTEM_PROCESSOR}")
else()
set(cross_status "FALSE")
endif()
message("Cross compiling ....................... ${cross_status}")
get_directory_property(definitions COMPILE_DEFINITIONS)
string(REPLACE ";" " " definitions "${definitions}")
message("Preprocessor defined macros ........... ${definitions}")
message("C compiler ............................ ${CMAKE_C_COMPILER}")
message("CFLAGS ................................ ${CMAKE_C_FLAGS}")
message("C++ compiler .......................... ${CMAKE_CXX_COMPILER}")
message("CXXFLAGS .............................. ${CMAKE_CXX_FLAGS}")
get_directory_property(common_compile_options COMPILE_OPTIONS)
string(REPLACE ";" " " common_compile_options "${common_compile_options}")
message("Common compile options ................ ${common_compile_options}")
get_directory_property(common_link_options LINK_OPTIONS)
string(REPLACE ";" " " common_link_options "${common_link_options}")
message("Common link options ................... ${common_link_options}")
if(DEFINED CMAKE_BUILD_TYPE)
message("Build type:")
message(" - CMAKE_BUILD_TYPE ................... ${CMAKE_BUILD_TYPE}")
string(TOUPPER "${CMAKE_BUILD_TYPE}" build_type)
message(" - CFLAGS ............................. ${CMAKE_C_FLAGS_${build_type}}")
message(" - CXXFLAGS ........................... ${CMAKE_CXX_FLAGS_${build_type}}")
message(" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_${build_type}}")
message(" - LDFLAGS for shared libraries ....... ${CMAKE_SHARED_LINKER_FLAGS_${build_type}}")
else()
message("Available configurations .............. ${CMAKE_CONFIGURATION_TYPES}")
message("Debug configuration:")
message(" - CFLAGS ............................. ${CMAKE_C_FLAGS_DEBUG}")
message(" - CXXFLAGS ........................... ${CMAKE_CXX_FLAGS_DEBUG}")
message(" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
message(" - LDFLAGS for shared libraries ....... ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
message("Release configuration:")
message(" - CFLAGS ............................. ${CMAKE_C_FLAGS_RELEASE}")
message(" - CXXFLAGS ........................... ${CMAKE_CXX_FLAGS_RELEASE}")
message(" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
message(" - LDFLAGS for shared libraries ....... ${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
endif()
message("Use assembly routines ................. ${ASM}")
message("Use ccache for compiling .............. ${CCACHE}")
message("\n")
if(configure_warnings)
message(" ******\n")
foreach(warning IN LISTS configure_warnings)
message(WARNING "${warning}")
endforeach()
message(" ******\n")
endif()
Loading