Commit 8310857
authored
Add a CMake override path for fast_float (#11758)
## Motivation
`fast_float` was bundled in v2026.12, but unlike the bundled
dependencies already covered by this
convention it shipped **without** a `SLANG_OVERRIDE_*_PATH` CMake
option. Builds that pre-stage or
mirror their dependencies (e.g. air-gapped / vendored-mirror CI) can
point each of the 14 existing
`SLANG_OVERRIDE_*_PATH` dependencies at an external copy via
`-DSLANG_OVERRIDE_<DEP>_PATH=<dir>`, but
for `fast_float` they have to patch the checkout. This adds the missing
option so `fast_float` follows
the same convention. (`metal-cpp` shares the same gap and is
intentionally out of scope — see Scope.)
Concrete example — before this change there is no way to do:
```
cmake --preset default -DSLANG_OVERRIDE_FAST_FLOAT_PATH=/mirror/deps
# (where /mirror/deps/fast_float/include holds the headers)
```
## Proposed solution
Mirror the existing override-path shape:
1. Declare `advanced_option(SLANG_OVERRIDE_FAST_FLOAT_PATH ... OFF)` in
the top-level `CMakeLists.txt`
alongside the other 14 `SLANG_OVERRIDE_*_PATH` options.
2. In `external/CMakeLists.txt`, branch the `fast_float` INTERFACE
target's include directory: use the
override path when set, otherwise the bundled path — unchanged from
today.
`fast_float` is header-only, so (unlike the buildable deps that use
`add_subdirectory`) the branch
swaps the include-dir *string* rather than the subdirectory. The
conditional `${system}` SYSTEM-include
keyword is preserved, so the headers (bundled or override-supplied)
still don't trip Slang's `-Werror`.
The override resolves to
`${SLANG_OVERRIDE_FAST_FLOAT_PATH}/fast_float/include`, matching the
documented
"directory-containing-a-subdirectory-named-after-the-dep" semantics
noted at `CMakeLists.txt:242-245`.
Because the header-only path is just a string (with no
`add_subdirectory` to error on a missing source
directory), a `message(FATAL_ERROR ...)` existence check is added **on
the override branch only**, so a
mistyped `SLANG_OVERRIDE_FAST_FLOAT_PATH` fails loudly at *configure*
time instead of as an opaque
"header not found" *compile* error — restoring the fail-fast behavior
the `add_subdirectory` siblings
get implicitly. The bundled branch keeps no such check (its submodule
path is in-contract).
This is the minimal change that satisfies the request and keeps
`fast_float` consistent with its
siblings. A `SLANG_USE_SYSTEM_FAST_FLOAT` / `find_package` toggle was
rejected: the issue asks for the
override-path convention, `fast_float` is rarely a system package, and
`find_package` is far more
surface for a header-only dep.
## Change summary
| File | Change |
| --- | --- |
| `CMakeLists.txt` | Add `advanced_option(SLANG_OVERRIDE_FAST_FLOAT_PATH
...)` after the `SLANG_OVERRIDE_CMARK_PATH` declaration. |
| `external/CMakeLists.txt` | Branch the `fast_float` INTERFACE include
dir on `SLANG_OVERRIDE_FAST_FLOAT_PATH` (`${system}` preserved); add a
configure-time `FATAL_ERROR` existence check on the override path. |
## Concepts and vocabulary
- **`advanced_option`** (`cmake/AutoOption.cmake`): thin wrapper =
`option()` + `mark_as_advanced()`.
Using it makes the new option identical in kind to the other
`SLANG_OVERRIDE_*_PATH` entries (hidden
unless advanced view is on). When the value is supplied on the command
line via `-D`, the cache entry
exists before `option()` runs, so `option()` is a no-op and the path
string is preserved — which is
exactly why `if(NOT SLANG_OVERRIDE_*_PATH)` works as a "was an override
given?" test across all of
these options.
- **`${system}`**: expands to `SYSTEM` on CMake ≥ 3.25 (else empty);
marks the include as a system
include so warnings from third-party headers are suppressed under
`-Werror`.
## Process report
Two edits, both required, both minimal:
1. `CMakeLists.txt` — without the `advanced_option` declaration the
override variable would not be a
recognized (advanced) cache option, breaking parity with the 14 sibling
overrides. Placed after the
CMARK block to keep the option list grouped as-is.
2. `external/CMakeLists.txt` — the `fast_float` target had a hard-coded
include dir
(`"${CMAKE_CURRENT_LIST_DIR}/fast_float/include"`) with no override
branch. Added an
`if(NOT SLANG_OVERRIDE_FAST_FLOAT_PATH)/else()` that sets
`_fast_float_include` and feeds it to the
single `target_include_directories` call, keeping `${system}` in place.
On the override branch only,
a `message(FATAL_ERROR ...)` fires if the resolved include dir does not
exist, so a wrong override is
caught at configure time. The block comment is widened from "the bundled
headers" to "the bundled (or
override-supplied) headers" so it still describes the code after the
branch is added.
**Input-shape check** (per the methodology): there is no malformed
AST/IR here — this is a build-config
feature, and the "shape" being handled is a user-supplied override
directory. The branch follows the
same documented producer convention as every other override option, so
the fix sits at the right
layer (the dependency-declaration site), not as a downstream workaround.
The override path is the
out-of-contract input, which is why the explicit existence check is on
that branch (the siblings get
the equivalent configure-time failure for free from `add_subdirectory`;
this header-only override does
not, hence the only deliberate exception — confined to user-supplied
input).
**Why no `.slang` regression test:** this is a CMake-only change; no
compiler behavior is affected and
the `SLANG_OVERRIDE_*_PATH` options are not exercised by per-PR CI (the
options matrix runs on
`workflow_dispatch` / weekly). Verified locally instead:
- `gersemi` (the repo's CMake formatter, same invocation as
`extras/formatting.sh`) — clean.
- A configure-time probe over the **exact edited bytes** confirmed all
three branches:
- override **unset** → `<repo>/external/fast_float/include` (the same
resolved path as today's bundled include; no check fires);
- override **set** to an existing dir → `<dir>/fast_float/include`,
configure succeeds;
- override **set** to a missing dir → `FATAL_ERROR` naming the bad path,
at configure time.
## Scope
`fast_float` only. `metal-cpp` (`external/CMakeLists.txt:161-166`) has
the same missing-override shape
but is intentionally left out of scope.
Closes #11756.
<sub>🤖 Generated by an automated Slang coworker — may be inaccurate. A
human maintainer should verify.</sub>
---------
Co-authored-by: nv-slang-bot[bot] <274397474+nv-slang-bot[bot]@users.noreply.github.com>1 parent 838d6b4 commit 8310857
2 files changed
Lines changed: 26 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
314 | 314 | | |
315 | 315 | | |
316 | 316 | | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
317 | 322 | | |
318 | 323 | | |
319 | 324 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
168 | | - | |
169 | | - | |
| 168 | + | |
| 169 | + | |
170 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
171 | 189 | | |
172 | 190 | | |
173 | 191 | | |
174 | | - | |
| 192 | + | |
175 | 193 | | |
176 | 194 | | |
177 | 195 | | |
| |||
0 commit comments