Skip to content

Commit bc25dda

Browse files
committed
cmake: Add root CMakeLists.txt file
1 parent 5ecd14a commit bc25dda

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed

CMakeLists.txt

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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+
# Configurable options.
31+
# When adding a new option, end the <help_text> with a full stop for consistency.
32+
include(CMakeDependentOption)
33+
cmake_dependent_option(CXX20 "Enable compilation in C++20 mode." OFF "NOT MSVC" ON)
34+
35+
if(CXX20)
36+
set(CMAKE_CXX_STANDARD 20)
37+
else()
38+
set(CMAKE_CXX_STANDARD 17)
39+
endif()
40+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
41+
set(CMAKE_CXX_EXTENSIONS OFF)
42+
43+
set(configure_warnings)
44+
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.14)
45+
include(CheckPIESupported)
46+
check_pie_supported(OUTPUT_VARIABLE check_pie_output LANGUAGES CXX)
47+
if(NOT CMAKE_CXX_LINK_PIE_SUPPORTED)
48+
list(APPEND configure_warnings "PIE link options are not supported for executable targets: ${check_pie_output}.")
49+
endif()
50+
else()
51+
list(APPEND configure_warnings "No PIE options will be passed to a linker for executable targets.")
52+
endif()
53+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
54+
55+
message("\n")
56+
message("Configure summary")
57+
message("=================")
58+
get_directory_property(definitions COMPILE_DEFINITIONS)
59+
string(REPLACE ";" " " definitions "${definitions}")
60+
message("Preprocessor defined macros ........... ${definitions}")
61+
message("C compiler ............................ ${CMAKE_C_COMPILER}")
62+
message("CFLAGS ................................ ${CMAKE_C_FLAGS}")
63+
message("C++ compiler .......................... ${CMAKE_CXX_COMPILER}")
64+
message("CXXFLAGS .............................. ${CMAKE_CXX_FLAGS}")
65+
get_directory_property(common_compile_options COMPILE_OPTIONS)
66+
string(REPLACE ";" " " common_compile_options "${common_compile_options}")
67+
message("Common compile options ................ ${common_compile_options}")
68+
get_directory_property(common_link_options LINK_OPTIONS)
69+
string(REPLACE ";" " " common_link_options "${common_link_options}")
70+
message("Common link options ................... ${common_link_options}")
71+
if(DEFINED CMAKE_BUILD_TYPE)
72+
message("Build type:")
73+
message(" - CMAKE_BUILD_TYPE ................... ${CMAKE_BUILD_TYPE}")
74+
string(TOUPPER "${CMAKE_BUILD_TYPE}" build_type)
75+
message(" - CFLAGS ............................. ${CMAKE_C_FLAGS_${build_type}}")
76+
message(" - CXXFLAGS ........................... ${CMAKE_CXX_FLAGS_${build_type}}")
77+
message(" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_${build_type}}")
78+
message(" - LDFLAGS for shared libraries ....... ${CMAKE_SHARED_LINKER_FLAGS_${build_type}}")
79+
else()
80+
message("Available configurations .............. ${CMAKE_CONFIGURATION_TYPES}")
81+
message("Debug configuration:")
82+
message(" - CFLAGS ............................. ${CMAKE_C_FLAGS_DEBUG}")
83+
message(" - CXXFLAGS ........................... ${CMAKE_CXX_FLAGS_DEBUG}")
84+
message(" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
85+
message(" - LDFLAGS for shared libraries ....... ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
86+
message("Release configuration:")
87+
message(" - CFLAGS ............................. ${CMAKE_C_FLAGS_RELEASE}")
88+
message(" - CXXFLAGS ........................... ${CMAKE_CXX_FLAGS_RELEASE}")
89+
message(" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
90+
message(" - LDFLAGS for shared libraries ....... ${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
91+
endif()
92+
message("\n")
93+
if(configure_warnings)
94+
message(" ******\n")
95+
foreach(warning IN LISTS configure_warnings)
96+
message(WARNING "${warning}")
97+
endforeach()
98+
message(" ******\n")
99+
endif()

0 commit comments

Comments
 (0)