Merge bitcoin/bitcoin#32693: depends: fix cmake compatibility error for freetype

d7c37906e7 build: patch cmake min version on freetype (josibake)

Pull request description:

  ## Problem

  While doing a depends build with CMake 4.0.1, I got the following error:

  ```
  Extracting freetype...
  /root/bitcoin/depends/sources/freetype-2.11.0.tar.xz: OK
  Preprocessing freetype...
  Configuring freetype...
  CMake Error at CMakeLists.txt:100 (cmake_minimum_required):
    Compatibility with CMake < 3.5 has been removed from CMake.

    Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
    to tell CMake that the project requires at least <min> but has been updated
    to work with policies introduced by <max> or earlier.

    Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway.

  -- Configuring incomplete, errors occurred!
  make: *** [funcs.mk:343: /root/bitcoin/depends/x86_64-pc-linux-gnu/.freetype_stamp_configured] Error 1
  make: Leaving directory '/root/bitcoin/depends'
  ```

  .. which led me to https://cmake.org/cmake/help/latest/release/4.0.html#deprecated-and-removed-features, which states compatibility with CMake versions less than 3.5 has been removed in 4.0.

  ## Fix
  Based on the suggestion from the error message (and from reading the CMake docs), I added `-DCMAKE_POLICY_VERSION_MINIMUM=3.22`. I picked `3.22` (as opposed to 3.5) since that is the minimum version of CMake we specify in `doc/dependencies.md`. Would be nice if there was a way to pipe the min version in as a variable (since presumably we'd want to update this to be in lock step with the minimum CMake version of the whole project), but I couldn't think of a simple way to do this. Open to suggestions on a more robust way to do this if this is deemed too brittle.

ACKs for top commit:
  fanquake:
    ACK d7c37906e7
  hebasto:
    ACK d7c37906e7. Tested on Ubuntu 25.04 with both cmake 4.0.2 and the default cmake 3.31.6.

Tree-SHA512: fb664ec73bfffc504f1dcc9076072307f443d056d14325de41c4a29f3ee4077f1922e79b5895b49e7354f45ad6a35be4973c153c2baf3376df6c0d209efc9c54
This commit is contained in:
merge-script
2025-06-13 12:27:46 +01:00
2 changed files with 18 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ $(package)_download_path=https://download.savannah.gnu.org/releases/$(package)
$(package)_file_name=$(package)-$($(package)_version).tar.xz
$(package)_sha256_hash=8bee39bd3968c4804b70614a0a3ad597299ad0e824bc8aad5ce8aaf48067bde7
$(package)_build_subdir=build
$(package)_patches += cmake_minimum.patch
define $(package)_set_vars
$(package)_config_opts := -DCMAKE_BUILD_TYPE=None -DBUILD_SHARED_LIBS=TRUE
@@ -12,6 +13,10 @@ define $(package)_set_vars
$(package)_config_opts += -DCMAKE_DISABLE_FIND_PACKAGE_BrotliDec=TRUE
endef
define $(package)_preprocess_cmds
patch -p1 < $($(package)_patch_dir)/cmake_minimum.patch
endef
define $(package)_config_cmds
$($(package)_cmake) -S .. -B .
endef

View File

@@ -0,0 +1,13 @@
build: set minimum required CMake to 3.12
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -97,7 +97,7 @@
# FreeType explicitly marks the API to be exported and relies on the compiler
# to hide all other symbols. CMake supports a C_VISBILITY_PRESET property
# starting with 2.8.12.
-cmake_minimum_required(VERSION 2.8.12)
+cmake_minimum_required(VERSION 3.12)
if (NOT CMAKE_VERSION VERSION_LESS 3.3)
# Allow symbol visibility settings also on static libraries. CMake < 3.3