Repository navigation
Groundwork: case-insensitive template lookup + honest untagged-build diagnostic (issue #10) - #14
CraigHutchinson wants to merge 1 commit into
Conversation
Groundwork for issue #10, not a finished/ship-ready change. (a) Template selection: VERSION_H_FILENAME's default lookup for "${VERSION_H_FILENAME}.in" required an exact-case filename match, but the shipped template is "Version.hpp.in" while docs and consumer code have used "version.hpp". On a case-sensitive filesystem this missed silently and fell through to auto-generating the wrong (C-only) fallback template with no error -- reproduced on this Windows machine using NTFS's per-directory case-sensitive attribute (fsutil file setCaseSensitiveInfo), including a consumer target that failed to compile against the resulting header. Fixed with two additions: (1) the exact-match lookup now falls back to a case-insensitive scan of the same directory before giving up, so the existing convention keeps working across filesystems; (2) an explicit VERSION_H_TEMPLATE variable lets a consumer bypass the filename convention entirely, erroring at configure time if the given path does not exist. It reuses plumbing already in place to forward VERSION_H_TEMPLATE into genCmakeVersion's build-time re-invocation. (b) Untagged-build diagnostic: the "no tag reachable from HEAD" case (the ordinary state of a fresh clone) was reported with CHECK_FAIL even though it always resolves via VERSION_FALLBACK and the build succeeds. Changed to CHECK_PASS with wording that states the fallback is being used, so a reader scanning configure output for what broke their build does not stop here. The genuinely abnormal case -- a tag matched but failed to parse -- keeps CHECK_FAIL, since that indicates a real VERSION_TAG_PATTERN/parser mismatch.
|
Superseded by #11, which merged into Comparing the two: #11 is more complete than this prototype in two ways this session's groundwork pass didn't catch —
Real merge conflicts exist against current For the record, in case it's useful corroborating evidence: this branch's validation independently reproduced the case-sensitivity defect via NTFS's per-directory case-sensitive mode on Windows (rather than Linux CI) and validated a FetchContent invocation mirroring the CPM |
Draft — exploratory groundwork, not ready to merge. Opened to stage the work for review; see the open items below.
Relates to #10.
What the recently-merged tag-matching fix (#9,
de14713) did and didn't coverIt fixed tag filtering and made the untagged/no-tag case fall back to
VERSION_FALLBACKinstead of an empty header, and distinguished WARNING (tag matched but unparseable) from STATUS in the final summary line. It did not touch the mid-streammessage(CHECK_FAIL ...)at the "Parse version" checkpoint, and did not touch template-file lookup at all. Both halves of #10 were still fully open going into this branch.Part (a) — template lookup
CMake/Version.cmake:491builds an exact-case path fromVERSION_H_FILENAME;:496does an exact-case existence check and silently falls through to auto-generating the wrong (C-only) template on a miss, with no error. The docs (:40andVersion.hpp.in:5) documented the lowercase"version.hpp"spelling against the shipped, capital-VVersion.hpp.in— i.e. the docs themselves encouraged the exact casing that silently breaks.tests/test_cpp23_namespace/CMakeLists.txt:6sets the lowercase spelling, so that in-repo test itself only passes today because it happens to run on a case-insensitive filesystem.Reproduced with a genuinely case-sensitive filesystem, not simulated: enabled NTFS's per-directory case-sensitive attribute (
fsutil file setCaseSensitiveInfo) on this Windows machine and confirmed two differently-cased files coexist there. Against unmodifiedmasterin that directory, with a consumer using the documented lowercase filename: template lookup missed, the wrong template was generated, and the consumer'smain.cppfailed to compile with real MSVC errors (C2653,C2065) — this is a real, breaking consumer failure, not just an ugly log line.Fix: case-insensitive fallback scan of the template directory when the exact-case match misses, with a
CHECK_PASSnote suggesting the exact case for portability; plus a newVERSION_H_TEMPLATEvariable a consumer can set to an explicit path, bypassing the naming convention entirely (this reuses plumbing that already existed — it was already forwarded into the build-timecmake -Pre-invocation — so it needed almost no new wiring). An explicitVERSION_H_TEMPLATEthat doesn't exist is a hardFATAL_ERROR, not a silent fallback.Re-ran the same case-sensitive-directory repro against the fix: log shows the case-insensitive match being found, and the consumer compiles, links, and runs, printing the expected version string. The explicit-override path was verified independently with a template at an arbitrary filename.
Part (b) — diagnostic wording
CMake/Version.cmake:402emittedCHECK_FAILfor the ordinary "fresh clone / untagged branch" case, even thoughversion_applyFallback(:453) then generates valid constants successfully a few lines later and the final summary (:468-471) correctly reports success. Reproduced directly on this (case-insensitive) machine — this half doesn't need a case-sensitive filesystem to demonstrate.Fix: the "no tag reachable" case is now
CHECK_PASSwith wording stating the fallback is in use. A tag that matched but failed to parse — a genuine misconfiguration — correctly staysCHECK_FAIL. Doc comments inCMake/Version.cmakeandCMake/Version.hpp.inupdated to state the exact shipped filename and the newVERSION_H_TEMPLATEescape hatch.Other verification
ctestagainsttests/): all 24 tests still pass..git/tarball scenario: a consumer tree placed entirely outside any git repo (confirmed viagit rev-parse --show-toplevelfailing),VERSION_SOURCE_DIRpointed at it — falls back toVERSION_FALLBACKcorrectly, final summary reads success, consumer compiles and runs printing the fallback version.GIT_TAG <sha>, no manualinclude()) — configures, builds, and runs successfully against this branch's commit.Still open before #10 can close
tests/test_cpp23_namespace/CMakeLists.txt:6to the exact-case spelling (now optional, since the fallback handles it — but doing so keeps that test demonstrating the preferred spelling), or add a dedicated test that intentionally uses the wrong case to lock in the fallback behaviour long-term.README.mdalso documents the old lowercase convention; not checked in this pass.Local scratch artifacts from validating this (
scratch/,build_test/,.scratch_casetest/) are untracked and not part of this PR.