Description
CMake 4.0 removes compatibility with versions of CMake older than 3.5.
This means that projects that have a call to cmake_minimum_required()
where the version (or version range) does not cover 3.5 or higher,
will fail with the following error:
CMake Error at CMakeLists.txt: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.
This will impact users that install CMake 4.0 once it is released.
The following use cases in Conan Center may be affected:
- Building some recipes from source where the upstream
CMakeLists.txt
has not been updated. - Building some recipes from source where the
CMakeLists.txt
exists
in theconan-center-index
repository - Building the
test_package
project when building recipes a cloned
copy of theconan-center-index
repository (e.g.conan create
orconan test
)
NOT affected:
- Downloading existing binary packages (whether built locally or from the
Conan Center remote) - irrespective of the above. - Building recipes from source where the upstream project assumes CMake 3.5
or higher (this is the majority of recipes) - Building recipes from source that have a
tool_requires
that specifies a version of CMake lower than 4.0
This recipes will use CMake from Conan, irrespective of what is installed on the system.
Workaround
If you have CMake 4.0 installed on your system and encounter errors building recipes from source,
add the following to your Conan profile(s):
[tool_requires]
!cmake/*: cmake/[>=3 <4]
This will cause Conan to fetch the most recently available CMake 3.x from the Conan Center remote,
and use that to build the recipe.
Remedial actions in Conan Center index
The team is currently working on amending affected recipes to ensure they continue building
with CMake 4.0. This covers:
- Recipes where the upstream
CMakeLists.txt
needs to be fixed - Recipes where the
CMakeLists.txt
exists in theconan-center-index
repository - All the
CMakeLists.txt
found in thetest_package
folder in theconan-center-index
repository
Please do not open PRs addressing CMake 4.0 support, and instead comment on this issue, thanks.