Skip to content

Commit e8bbd04

Browse files
committed
Merge #123: cmake: Bump CMake minimum required version up to 3.22
a6a746e fixup! ci: Test CMake edge cases (Hennadii Stepanov) d267c2c [FIXUP] cmake: Drop deprecated TestBigEndian module (Hennadii Stepanov) b6cb4bb fixup! cmake: Check system symbols (Hennadii Stepanov) 4d67f35 fixup! cmake: Add `Maintenance` module (Hennadii Stepanov) ae5bd32 fixup! cmake: Add cross-compiling support (Hennadii Stepanov) 4b0d7f5 fixup! build: Generate `share/toolchain.cmake` in depends (Hennadii Stepanov) c7abb8f fixup! cmake: Add root `CMakeLists.txt` file (Hennadii Stepanov) Pull request description: Considering the time when the new CMake-based build system will be available for users and bitcoin#29091, it seems reasonable to drop support for CMake versions older than 3.22. For CMake version availability, please refer to https://repology.org/project/cmake/versions. If an OS has no supported CMake in its system/default package manager, the user is still able to download it from https://cmake.org/download// Please refer to commit messages for detailed explanations of code changes. ACKs for top commit: pablomartin4btc: tACK a6a746e vasild: ACK a6a746e Tree-SHA512: ad2e2a31fc65f9459d38b5f226281820fb6e4bb044ed70413157fa339303c511d4ea70a3a21352cc6a200cba057e394c1ba92f8a8f7faeec2955707e95461d9d
2 parents 2b2edb3 + a6a746e commit e8bbd04

File tree

10 files changed

+31
-100
lines changed

10 files changed

+31
-100
lines changed

.github/workflows/cmake.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,17 +170,17 @@ jobs:
170170
- name: Generate build system. Expected to FAIL
171171
if: ${{ matrix.conf.expected == 'fail' }}
172172
run: |
173-
! cmake -B build -DCMAKE_TOOLCHAIN_FILE=depends/x86_64-pc-linux-gnu/share/toolchain.cmake ${{ matrix.conf.build_options }}
173+
! cmake -B build --toolchain depends/x86_64-pc-linux-gnu/share/toolchain.cmake ${{ matrix.conf.build_options }}
174174
175175
- name: Generate build system. Expected to PASS
176176
if: ${{ matrix.conf.expected == 'pass' }}
177177
run: |
178-
cmake -B build -DCMAKE_TOOLCHAIN_FILE=depends/x86_64-pc-linux-gnu/share/toolchain.cmake
178+
cmake -B build --toolchain depends/x86_64-pc-linux-gnu/share/toolchain.cmake
179179
180180
181-
ubuntu-focal-native:
182-
name: 'Ubuntu 20.04, CMake 3.16, Boost ${{ matrix.conf.boost_version }}'
183-
runs-on: ubuntu-20.04
181+
ubuntu-jammy-native:
182+
name: 'Ubuntu 22.04, CMake 3.22, Boost ${{ matrix.conf.boost_version }}'
183+
runs-on: ubuntu-22.04
184184

185185
strategy:
186186
fail-fast: false
@@ -204,7 +204,7 @@ jobs:
204204
- name: Install packages
205205
run: |
206206
sudo apt-get update
207-
sudo apt-get install --no-install-recommends curl g++10 cmake ccache libevent-dev libsqlite3-dev libdb-dev libdb++-dev libminiupnpc-dev libnatpmp-dev libzmq3-dev systemtap-sdt-dev
207+
sudo apt-get install --no-install-recommends curl cmake ccache libevent-dev libsqlite3-dev libdb-dev libdb++-dev libminiupnpc-dev libnatpmp-dev libzmq3-dev systemtap-sdt-dev
208208
echo "CCACHE_DIR=${{ runner.temp }}/ccache" >> "$GITHUB_ENV"
209209
210210
- name: CMake version

CMakeLists.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
# Copyright (c) 2023 The Bitcoin Core developers
1+
# Copyright (c) 2023-present The Bitcoin Core developers
22
# Distributed under the MIT software license, see the accompanying
3-
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
3+
# file COPYING or https://opensource.org/license/mit/.
44

55
# IMPORTANT: Changes which affect binary results may not be quietly gated
66
# by CMake version.
77
#
8-
# Ubuntu 20.04 LTS Focal Fossa, https://wiki.ubuntu.com/Releases, EOSS in April 2025:
9-
# - CMake 3.16.3, https://packages.ubuntu.com/focal/cmake
8+
# Ubuntu 22.04 LTS Jammy Jellyfish, https://wiki.ubuntu.com/Releases, EOSS in June 2027:
9+
# - CMake 3.22.1, https://packages.ubuntu.com/jammy/cmake
1010
#
11-
# Centos Stream 8, EOL in May 2024:
12-
# - CMake 3.20.2, http://mirror.centos.org/centos/8-stream/AppStream/x86_64/os/Packages/
11+
# Centos Stream 9, EOL in May 2027:
12+
# - CMake 3.26.5, https://mirror.stream.centos.org/9-stream/AppStream/x86_64/os/Packages/
1313
#
1414
# All policies known to the running version of CMake and introduced
15-
# in the 3.28 version or earlier will be set to use NEW behavior.
15+
# in the 3.29 version or earlier will be set to use NEW behavior.
1616
# All policies introduced in later versions will be unset.
1717
# See: https://cmake.org/cmake/help/latest/manual/cmake-policies.7.html
18-
cmake_minimum_required(VERSION 3.16...3.28)
18+
cmake_minimum_required(VERSION 3.22...3.29)
1919

2020
set(PACKAGE_NAME "Bitcoin Core")
2121
set(CLIENT_VERSION_MAJOR 27)

cmake/bitcoin-config.h.in

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,6 @@
130130
/* Define to 1 if strerror_r returns char *. */
131131
#cmakedefine STRERROR_R_CHAR_P 1
132132

133-
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
134-
significant byte first (like Motorola and SPARC, unlike Intel). */
135-
#cmakedefine WORDS_BIGENDIAN 1
136-
137133
/* Define to 1 to enable wallet functions. */
138134
#cmakedefine ENABLE_WALLET 1
139135

cmake/crc32c.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ target_compile_definitions(crc32c
9090
HAVE_STRONG_GETAUXVAL=$<BOOL:${HAVE_STRONG_GETAUXVAL}>
9191
HAVE_SSE42=$<BOOL:${HAVE_SSE42}>
9292
HAVE_ARM64_CRC32C=$<BOOL:${HAVE_ARM64_CRC32C}>
93-
BYTE_ORDER_BIG_ENDIAN=${WORDS_BIGENDIAN}
93+
BYTE_ORDER_BIG_ENDIAN=$<STREQUAL:${CMAKE_CXX_BYTE_ORDER},BIG_ENDIAN>
9494
)
9595

9696
target_include_directories(crc32c

cmake/introspection.cmake

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
include(CheckCXXSourceCompiles)
66
include(CheckCXXSymbolExists)
77
include(CheckIncludeFileCXX)
8-
include(TestBigEndian)
9-
10-
test_big_endian(WORDS_BIGENDIAN)
118

129
# The following HAVE_{HEADER}_H variables go to the bitcoin-config.h header.
1310
check_include_file_cxx(sys/prctl.h HAVE_SYS_PRCTL_H)

cmake/leveldb.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ target_compile_definitions(leveldb
6060
HAVE_FULLFSYNC=$<BOOL:${HAVE_FULLFSYNC}>
6161
HAVE_O_CLOEXEC=$<BOOL:${HAVE_O_CLOEXEC}>
6262
FALLTHROUGH_INTENDED=[[fallthrough]]
63-
LEVELDB_IS_BIG_ENDIAN=${WORDS_BIGENDIAN}
63+
LEVELDB_IS_BIG_ENDIAN=$<STREQUAL:${CMAKE_CXX_BYTE_ORDER},BIG_ENDIAN>
6464
$<$<NOT:$<BOOL:${WIN32}>>:LEVELDB_PLATFORM_POSIX>
6565
$<$<BOOL:${WIN32}>:LEVELDB_PLATFORM_WINDOWS>
6666
$<$<BOOL:${WIN32}>:_UNICODE;UNICODE>

cmake/module/CrossPkgConfig.cmake

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,9 @@
1-
# Copyright (c) 2023 The Bitcoin Core developers
1+
# Copyright (c) 2023-present The Bitcoin Core developers
22
# Distributed under the MIT software license, see the accompanying
3-
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
3+
# file COPYING or https://opensource.org/license/mit/.
44

55
find_package(PkgConfig REQUIRED)
66

7-
function(remove_isystem_from_include_directories_internal target)
8-
#[=[
9-
A workaround for https://gitlab.kitware.com/cmake/cmake/-/issues/20652.
10-
11-
When the pkg-config provides CFLAGS with -isystem options, for instance:
12-
13-
$ pkg-config --cflags-only-I libzmq
14-
-isystem /usr/include/mit-krb5 -I/usr/include/pgm-5.3 -I/usr/include/libxml2
15-
16-
an old CMake fails to parse them properly and the INTERFACE_INCLUDE_DIRECTORIES
17-
property contains "-isystem" as a separated element:
18-
19-
-isystem;/usr/include/mit-krb5;/usr/include/pgm-5.3;/usr/include/libxml2
20-
21-
which ends with an error "Imported target includes non-existent path".
22-
23-
Fixing by removing the "-isystem" element from the INTERFACE_INCLUDE_DIRECTORIES.
24-
]=]
25-
26-
get_target_property(include_directories ${target} INTERFACE_INCLUDE_DIRECTORIES)
27-
if(include_directories)
28-
list(REMOVE_ITEM include_directories -isystem)
29-
set_target_properties(${target} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${include_directories}")
30-
endif()
31-
endfunction()
32-
337
macro(cross_pkg_check_modules prefix)
348
if(CMAKE_CROSSCOMPILING)
359
set(pkg_config_path_saved "$ENV{PKG_CONFIG_PATH}")
@@ -39,11 +13,9 @@ macro(cross_pkg_check_modules prefix)
3913
pkg_check_modules(${prefix} ${ARGN})
4014
set(ENV{PKG_CONFIG_PATH} ${pkg_config_path_saved})
4115
set(ENV{PKG_CONFIG_LIBDIR} ${pkg_config_libdir_saved})
16+
unset(pkg_config_path_saved)
17+
unset(pkg_config_libdir_saved)
4218
else()
4319
pkg_check_modules(${prefix} ${ARGN})
4420
endif()
45-
46-
if(CMAKE_VERSION VERSION_LESS 3.17.3 AND TARGET PkgConfig::${prefix})
47-
remove_isystem_from_include_directories_internal(PkgConfig::${prefix})
48-
endif()
4921
endmacro()

cmake/module/Maintenance.cmake

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,13 @@ function(setup_split_debug_script)
88
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
99
set(OBJCOPY ${CMAKE_OBJCOPY})
1010
set(STRIP ${CMAKE_STRIP})
11-
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.20)
12-
configure_file(
13-
contrib/devtools/split-debug.sh.in split-debug.sh
14-
FILE_PERMISSIONS OWNER_READ OWNER_EXECUTE
15-
GROUP_READ GROUP_EXECUTE
16-
WORLD_READ
17-
@ONLY
18-
)
19-
else()
20-
configure_file(
21-
contrib/devtools/split-debug.sh.in split-debug.sh
22-
@ONLY
23-
)
24-
endif()
11+
configure_file(
12+
contrib/devtools/split-debug.sh.in split-debug.sh
13+
FILE_PERMISSIONS OWNER_READ OWNER_EXECUTE
14+
GROUP_READ GROUP_EXECUTE
15+
WORLD_READ
16+
@ONLY
17+
)
2518
endif()
2619
endfunction()
2720

cmake/module/TestAppendRequiredLibraries.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ include_guard(GLOBAL)
99
# See: https://github.com/bitcoin/bitcoin/pull/21486
1010
function(test_append_socket_library target)
1111
if (NOT TARGET ${target})
12-
message(FATAL_ERROR "test_append_socket_library() called with non-existent target \"${target}\".")
12+
message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION}() called with non-existent target \"${target}\".")
1313
endif()
1414

1515
set(check_socket_source "
@@ -45,7 +45,7 @@ endfunction()
4545
# Sourced from http://bugs.debian.org/797228
4646
function(test_append_atomic_library target)
4747
if (NOT TARGET ${target})
48-
message(FATAL_ERROR "test_append_atomic_library() called with non-existent target \"${target}\".")
48+
message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION}() called with non-existent target \"${target}\".")
4949
endif()
5050

5151
set(check_atomic_source "

depends/toolchain.cmake.in

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -35,41 +35,14 @@ endfunction()
3535
if(NOT CMAKE_C_COMPILER)
3636
set(DEPENDS_C_COMPILER_WITH_LAUNCHER @CC@)
3737
split_compiler_launcher(DEPENDS_C_COMPILER_WITH_LAUNCHER CMAKE_C_COMPILER_LAUNCHER CMAKE_C_COMPILER)
38-
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.21)
39-
set(CMAKE_C_LINKER_LAUNCHER ${CMAKE_C_COMPILER_LAUNCHER})
40-
endif()
41-
if(CMAKE_VERSION VERSION_LESS 3.19)
42-
# Being provided with CC="compiler -arg1 -arg2", the old CMake cannot
43-
# store the compiler arguments in the CMAKE_C_COMPILER variable.
44-
# Therefore, we have to store them separately.
45-
set(mandatory_c_compiler_flags ${CMAKE_C_COMPILER})
46-
list(POP_FRONT mandatory_c_compiler_flags CMAKE_C_COMPILER)
47-
list(JOIN mandatory_c_compiler_flags " " mandatory_c_compiler_flags)
48-
string(PREPEND CMAKE_C_FLAGS_INIT "${mandatory_c_compiler_flags} ")
49-
unset(mandatory_c_compiler_flags)
50-
endif()
38+
set(CMAKE_C_LINKER_LAUNCHER ${CMAKE_C_COMPILER_LAUNCHER})
5139
set(DEPENDS_C_COMPILER_FLAGS @CFLAGS@)
5240
endif()
5341

5442
if(NOT CMAKE_CXX_COMPILER)
5543
set(DEPENDS_CXX_COMPILER_WITH_LAUNCHER @CXX@)
5644
split_compiler_launcher(DEPENDS_CXX_COMPILER_WITH_LAUNCHER CMAKE_CXX_COMPILER_LAUNCHER CMAKE_CXX_COMPILER)
57-
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.21)
58-
set(CMAKE_CXX_LINKER_LAUNCHER ${CMAKE_CXX_COMPILER_LAUNCHER})
59-
endif()
60-
if(CMAKE_VERSION VERSION_LESS 3.19)
61-
# Being provided with CXX="compiler -arg1 -arg2", the old CMake cannot
62-
# store the compiler arguments in the CMAKE_CXX_COMPILER variable.
63-
# Therefore, we have to store them separately.
64-
set(mandatory_cxx_compiler_flags ${CMAKE_CXX_COMPILER})
65-
list(POP_FRONT mandatory_cxx_compiler_flags CMAKE_CXX_COMPILER)
66-
list(JOIN mandatory_cxx_compiler_flags " " mandatory_cxx_compiler_flags)
67-
string(PREPEND CMAKE_CXX_FLAGS_INIT "${mandatory_cxx_compiler_flags} ")
68-
string(PREPEND CMAKE_OBJCXX_FLAGS_INIT "${mandatory_cxx_compiler_flags} ")
69-
string(PREPEND CMAKE_EXE_LINKER_FLAGS_INIT "${mandatory_cxx_compiler_flags} ")
70-
string(PREPEND CMAKE_SHARED_LINKER_FLAGS_INIT "${mandatory_cxx_compiler_flags} ")
71-
unset(mandatory_cxx_compiler_flags)
72-
endif()
45+
set(CMAKE_CXX_LINKER_LAUNCHER ${CMAKE_CXX_COMPILER_LAUNCHER})
7346
set(DEPENDS_CXX_COMPILER_FLAGS @CXXFLAGS@)
7447

7548
set(CMAKE_OBJCXX_COMPILER ${CMAKE_CXX_COMPILER})

0 commit comments

Comments
 (0)