Let consumers override the import std gate UUID - #12
Merged
Conversation
This was referenced Jul 31, 2026
The version-keyed table added in #9 picks the right CMAKE_EXPERIMENTAL_CXX_IMPORT_STD value for known CMake releases, but it assigned it with a plain set(). That creates an ordinary variable which shadows the cache entry `-D` produces, so `-DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD=...` was silently discarded for every release listed in the table, leaving no escape hatch when a row is wrong. Skip the assignment when the consumer has put a value in the cache, so the command line wins while the table stays authoritative by default. Guard on the cache entry rather than on DEFINED. Testing DEFINED would also defer to an ordinary variable, so consuming this project via add_subdirectory() or FetchContent from a parent that hardcodes a single UUID -- the pattern the table replaced -- would let the parent's value win on every release and pass its staleness on to us. Assigning to the cache here would also restore the override, but it would pin the UUID in CMakeCache.txt for everyone: upgrading CMake in an existing build tree would keep using the previous release's value and quietly ignore the table, which is the failure the table exists to prevent. Report the gate value actually in effect. The unlisted-release warning previously fired whenever no value was set, so supplying an empty or false one on a listed release claimed CMake was newer than every listed release and asked for a row that already exists; empty and unlisted are now separate messages naming their real cause. A supplied value differing from the table gets a STATUS line, since `-D` is cached and outlives the command line that introduced it, making a stale override otherwise indistinguishable from the table's own choice.
stephenberry
force-pushed
the
import-std-gate-override
branch
from
July 31, 2026 03:48
32a110f to
909d988
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #9.
The problem
#9 replaced the single hardcoded
CMAKE_EXPERIMENTAL_CXX_IMPORT_STDvalue with a table keyed on the running CMake version, which fixed configuring across releases. But it assigned the value with a plainset(), and that creates a normal variable which shadows the cache entry-Dproduces:So
-DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD=...was ignored for every release listed in the table. If a row is ever wrong, there is no escape hatch short of editingCMakeLists.txt, and CMake's own gate-mismatch diagnostic blames the project rather than the stale row.The change
Skip the assignment when the consumer has put a value in the cache:
Two details in that condition are load-bearing.
Why not assign to the cache.
set(... CACHE STRING "")would also restore the override, but a non-FORCEcache write will not update an existing entry, so the UUID gets pinned inCMakeCache.txtfor everyone. A consumer who upgrades CMake in an existing build tree then keeps the old value and the table's corrected one never applies:That reintroduces the failure the table was added to prevent, in a form harder to diagnose than the original.
Why
DEFINED CACHE{...}and notDEFINED. TestingDEFINEDalso defers to an ordinary variable. When this project is consumed throughadd_subdirectory()orFetchContentfrom a parent that hardcodes a single UUID -- the pattern the table replaced, and what this project itself did before #9 -- the parent's value would win on every release and pass its staleness on to us. Testing the cache keeps the table authoritative there while still honouring a deliberate-D.Diagnostics
The unlisted-release warning now distinguishes three states, since each has a different cause and a different fix:
-U. Previously this produced the unlisted-release warning even on a release that is in the table, asking for a row that already existsSTATUSline naming both values. A-Doverride is cached, so it outlives the command line that introduced it; without this, a stale override is indistinguishable from the table's own choice. Passing the value the table already holds stays quietVerified
Against this branch's
CMakeLists.txtwith CMake 4.4.1, using--trace-expandto confirm which branch executes:-D-DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD=<uuid>STATUSnames both values-Dequal to the table value-DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD=-DNotes
project(), after these lines run, so it takes precedence.set(CACHE{VAR} VALUE ...)would be a tidier spelling but needs CMake 4.2, above this project'scmake_minimum_required(VERSION 3.31). Worth revisiting if the floor moves.import stdprobe on macOS, so a bogus UUID produces no local error. That coverage comes from the modules CI jobs.