cmake_minimum_required version bump timing after CMake binary upgrade
0 reputation · 06 Jul 2026, 06:48 UTC
0 reputation · 06 Jul 2026, 06:48 UTC
Upgrading the CMake executable does not automatically change project behavior because cmake_minimum_required(VERSION x.y) pins the policy stack to the NEW state up to that version. The build directory, however, can become invalid when the generator or compiler metadata recorded in CMakeCache.txt no longer matches the new binary, so the documented recovery is a clean reconfigure in a fresh build tree.
Raising cmake_minimum_required flips additional policies to NEW (for example, CMP0077 makes option() honor normal variables) and drops support for older CMake binaries. Third-party Find modules or vendored scripts may rely on deprecated behavior that only surfaces after the minimum version moves. Deprecation warnings in newer releases signal that very old minimums will eventually stop configuring, making the bump mandatory at some point.
Teams must weigh the risk of silent behavior changes against the maintenance burden of supporting multiple CMake versions in CI and developer environments.
Bump cmake_minimum_required only when the policy floor — not the binary — is what blocks you. Upgrading the CMake executable changes nothing about project behavior on its own: the directive pins every policy introduced up to that version to NEW, and policies from later releases default to OLD with warnings. The binary upgrade and the minimum-version bump are two independent decisions, and conflating them is the most common mistake here.
option() honor normal variables), and per-policy opt-ins have become unwieldy.If none of these hold, keep the floor low. A lower minimum widens who can build from source.
Before committing the bump, trial the risky policies individually with cmake_policy(SET CMPxxxx NEW) — this isolates behavior changes one at a time instead of flipping a dozen at once. Then verify the full bump empirically:
# See which policies your current minimum leaves unset
cmake --help-policy-list
# Configure old vs new minimum into separate fresh build dirs
cmake -S . -B build-old # current minimum
cmake -S . -B build-new # bumped minimum
diff build-old/CMakeCache.txt build-new/CMakeCache.txt
diff build-old/compile_commands.json build-new/compile_commands.jsonGrep the configure log for Policy CMP warnings — each one names an exact behavior flip to audit. Finally, run the full CTest suite in both trees and compare results. Always reconfigure in a fresh build directory; a stale CMakeCache.txt from the old binary can fail in confusing ways that have nothing to do with the version bump.
The documented escape hatch is the version-range form:
cmake_minimum_required(VERSION 3.16...3.27)This keeps old binaries able to configure while opting into NEW policies up to the upper bound when a newer binary runs — ideal for a transition period. A practical rollout: bump the floor on the development branch first, leave long-lived release branches on the old minimum until end-of-life, and state the new floor prominently in release notes, since it is a breaking change for anyone building from source with an older CMake.
Exact policy numbers, deprecation schedules, and the lowest still-supported minimum vary by CMake release — confirm against your installed version's own cmake --help-policy output. Also audit vendored third-party scripts before bumping: they may silently rely on OLD behavior, and mechanisms like CMAKE_POLICY_DEFAULT_CMPxxxx can change them without any warning in your own code.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.