bitwizeshift / bitwizeshift/result
CMake Configuration fails with CMake 4
- Dominant language
- C++
- Stars
- 313
- Forks
- 18
- PR merge metrics
- No merged PRs in 30d
Description
### Checklist
- [ x] I did not find a duplicate of this in the
[Issues](https://github.com/bitwizeshift/result/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
# 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
```sh
mkdir resulttest
cd resulttest
git clone https://github.com/bitwizeshift/result.git
```
3. Create CMakeLists.txt
```sh
touch CMakeLists.txt
```
```cmake
cmake_minimum_required(VERSION 3.19)
project(result_test)
add_executable(result_test main.cpp)
add_subdirectory(./result)
```
4. Run Cmake
```sh
cmake -B build
```
#### Expected Behavior
The CMake configuration should run through without problems
```sh
-- 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
```sh
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 value. Or, use the ... syntax
to tell CMake that the project requires at least but has been updated
to work with policies introduced by 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 value. Or, use the ... syntax
to tell CMake that the project requires at least but has been updated
to work with policies introduced by 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 #1 SMP PREEMPT_DYNAMIC Sun, 20 Apr 2025 12:38:52 +0000 x86_64 GNU/Linux**
* Compiler: **gcc (GCC) 14.2.1 20250207**
Contributor guide
Research direction
Start with the minimum-version declarations in CMakeLists.txt and cmake/AddSelfContainmentTest.cmake, then reproduce the failure using CMake 4 and the sample add_subdirectory setup described in the issue. Done means the project configures and generates successfully without the compatibility error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100