Skip to content

CMake Configuration fails with CMake 4 #21

@MarcSchaetz

Description

@MarcSchaetz

Checklist

  • [ x] I did not find a duplicate of this in the
    Issues section.

Description

The file cmake/AddSelfContainmentTest.cmake of this project enforces a minimum CMake version of 3.1.
Additionally CMakeLists.txt requires a minimum version of 3.5.

# cmake/AddSelfContainmentTest.cmake
cmake_minimum_required(VERSION 3.1)

# CMakeLists.txt
cmake_minimum_required(VERSION 3.5)

With the release of CMake 4 the compatibility with a minimum version < 3.5 has been removed. Future versions will also remove compatibility with versions < 3.10.

Steps to reproduce

Simply create a minimum Cpp project with a CMakeLists.txt

  1. Make sure you have CMake version 4 installed
  2. Create project and clone result
mkdir resulttest
cd resulttest
git clone https://github.com/bitwizeshift/result.git
  1. Create CMakeLists.txt
touch CMakeLists.txt
cmake_minimum_required(VERSION 3.19)
project(result_test)
add_executable(result_test main.cpp)
add_subdirectory(./result)
  1. Run Cmake
cmake -B build

Expected Behavior

The CMake configuration should run through without problems

-- Configuring done (0.0s)
-- Generating done (0.0s)
-- Build files have been written to: /home/marc/sandbox/resulttests/build

Actual Behavior

The CMake configuration stops with a warning an an error

CMake Deprecation Warning at result/CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  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.


CMake Error at result/cmake/AddSelfContainmentTest.cmake:1 (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.
Call Stack (most recent call first):
  result/CMakeLists.txt:110 (include)


-- Configuring incomplete, errors occurred!

Extra information

  • Library version: 1.0.0
  • Operating System: Linux workhorse 6.14.3-arch1-1 Checklist #1 SMP PREEMPT_DYNAMIC Sun, 20 Apr 2025 12:38:52 +0000 x86_64 GNU/Linux
  • Compiler: gcc (GCC) 14.2.1 20250207

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions