Skip to content

Commit 6eafe4f

Browse files
committed
cmake: Increase cmake policy version
Increase cmake policy version from 3.12 to 4.1 in standalone builds to stop using very old and deprecated CMake policies in standalone builds. Also stop overriding policy version if a parent project has already set one, so parent projects are able to control which policies are used by default based on their own practices and needs. In the Bitcoin Core subtree, this change causes the libmultiprocess policy version to increase from 3.12 to 3.22, which is the version Bitcoin Core sets. This commit only changes the policy version, it does not change the specified minimum version of cmake required to build the project, which is 3.12.
1 parent 0ffdb14 commit 6eafe4f

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

CMakeLists.txt

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,33 @@
22
# Distributed under the MIT software license, see the accompanying
33
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5-
cmake_minimum_required(VERSION 3.12)
5+
# Call cmake_minimum_required() only if it was not already called, so parent
6+
# projects set the policy version when this project is included via
7+
# add_subdirectory().
8+
#
9+
# Rationale: Different projects have different practices for choosing policy
10+
# versions. For example, the Bitcoin Core project sets an old policy version,
11+
# causing CMake to use deprecated behaviors instead of new behaviors and
12+
# maximize compatibility with a single old version of CMake, reducing variance
13+
# between builds with newer CMake versions. By contrast CMake documentation
14+
# recommends setting the policy version to the latest supported version of
15+
# CMake, as an upgrading mechanism rather than a pinning mechanism, to let
16+
# project authors fix problems before enabling newer policies, while not opting
17+
# into deprecated policies on a longer term basis.
18+
if(NOT DEFINED CMAKE_MINIMUM_REQUIRED_VERSION
19+
OR CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 3.12)
20+
# The left number in the range below is the minimum CMake version required to
21+
# run this project. The right number is the CMake policy version.
22+
#
23+
# The purpose of the minimum version is to trigger a helpful error if a version
24+
# of CMake is being used that is too old to work. If this number is changed,
25+
# the version in ci/configs/olddeps.bash should be changed to match.
26+
#
27+
# The purpose of the policy version is to opt out of policies introduced in
28+
# newer versions of CMake until they have been tested. If this number is
29+
# changed, the version in ci/configs/newdeps.bash should be changed to match.
30+
cmake_minimum_required(VERSION 3.12...4.1 FATAL_ERROR)
31+
endif()
632

733
project("Libmultiprocess" CXX)
834
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)

ci/configs/newdeps.bash

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ CI_DESC="CI job using newest Cap'n Proto and cmake versions"
22
CI_DIR=build-newdeps
33
export CXXFLAGS="-Werror -Wall -Wextra -Wpedantic -Wno-unused-parameter -Wno-error=array-bounds"
44
CAPNP_CHECKOUT=master
5+
# cmakeVersion here should match policy version in CMakeLists.txt
56
NIX_ARGS=(--argstr capnprotoVersion "none" --argstr cmakeVersion "4.1.1")
67
BUILD_ARGS=(-k)

ci/configs/olddeps.bash

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
CI_DESC="CI job using old Cap'n Proto and cmake versions"
22
CI_DIR=build-olddeps
33
export CXXFLAGS="-Werror -Wall -Wextra -Wpedantic -Wno-unused-parameter -Wno-error=array-bounds"
4+
# cmakeVersion here should match minimum version in CMakeLists.txt
45
NIX_ARGS=(--argstr capnprotoVersion "0.7.1" --argstr cmakeVersion "3.12.4")
56
BUILD_ARGS=(-k)

0 commit comments

Comments
 (0)