Commit Graph

127 Commits

Author SHA1 Message Date
Daksh Mamodiya
e6482b840a fileapi: Fix dangling reply reference on case-insensitive filesystems
Reply file names embed the configuration name verbatim.  Reconfiguring
a build tree with a build type that differs from the previous one only
in case (e.g. Debug -> debug) makes CMake write a reply whose name also
differs only in case from the existing file.  On a case-insensitive
filesystem the write is skipped because the name already exists, but
RemoveOldReplyFiles compared on-disk names to the just-written names
textually and deleted the surviving file, leaving the reply index
citing a target or directory reply that no longer exists on disk.

Prune reply files by file identity via cmSystemTools::GetFileId instead
of by name, so an on-disk entry that aliases a reply we just wrote is
kept.  An entry whose identity cannot be obtained is retained rather
than deleted.

Fixes: #28022
2026-08-06 17:44:54 +02:00
Vito Gamberini
ab1bd6f6c6 c++modules: Remove CXX_MODULE_STD and CMAKE_CXX_COMPILER_IMPORT_STD
Fixes: #27966, #27992, #28000
2026-08-03 10:05:34 -04:00
Brad King
dffb8a0839 Merge topic 'jsonstate-fileapi'
d3ccd49eeb cmFileAPI: Use cmJSONState to read client queries

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12317
2026-07-27 10:08:50 -04:00
Tyler Yankee
4eda69be82 Tests: Centralize JSON schema validation
As the number of areas in CMake for which we've provided JSON schemas
has expanded, testing infrastructure has mostly been copy-pasted across
the relevant test suites. Unify it to a single reusable validator
script and CMake helper.
2026-07-24 09:55:23 -04:00
Tyler Yankee
d3ccd49eeb cmFileAPI: Use cmJSONState to read client queries
This approach will be more portable.
2026-07-24 07:47:19 -04:00
Brad King
84e1dbc893 Merge topic 'fileapi-import-std-target-refs'
11c93dd6da fileapi: Test import std target references in codemodel

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !12209
2026-06-24 09:52:25 -04:00
kkkzbh
11c93dd6da fileapi: Test import std target references in codemodel
Add a regression test for the File API codemodel graph produced for an
import std target. The test verifies that emitted target references,
including those to the CMake-provided stdlib target, resolve to targets
present in the codemodel.

Closes: #27890
2026-06-24 03:02:18 +08:00
Tyler Yankee
a3b5591bbc fileapi: Omit NONE language entries from toolchains
Fixes: #27885
2026-06-23 08:42:00 -04:00
Tyler Yankee
9f4cf1cef7 fileAPI: Report full backtraces for sources in multiple file sets
Previously, if a single source file was added to multiple file sets via
multiple `target_sources` calls, only the first call originally adding
it to the target was stored in the backtrace graph and referenced by
index in the singular "backtrace" field.

Add a "backtraces" field expanding this to cover all command
invocations which associate the given source file with that target.
Preserve the original "backtrace" field for compatibility. Update
spellings in the test suite to check against both fields.

Issue: #27035
2026-05-12 16:45:13 -04:00
Tyler Yankee
3d249d2aa9 fileAPI: Support files added to multiple file sets
The `fileSetIndex` field of target sources replies is incomplete, as a
single source file can be added to arbitrarily many file sets. Add a
`fileSetIndexes` field to report all file sets to which a source
belongs, and preserve `fileSetIndex` for compatibility as the index of
the most recent addition.

Tweak the test suite to use the plural spelling only in expected JSON
snippets and verify that the singular `fileSetIndex` is always the last
element of the new list. (Note that remaining occurrences of the
singular spelling correspond to "installers" objects, which is entirely
different.)

Fixes: #27035
2026-05-12 16:45:12 -04:00
Brad King
8f969efc07 Merge topic 'fix_compile_only_genex_dependencies'
3f811dc56f Add target ordering dependencies guarded by $<COMPILE_ONLY> genex

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !12015
2026-05-11 11:19:06 -04:00
Robert Maynard
3f811dc56f Add target ordering dependencies guarded by $<COMPILE_ONLY> genex
`LINK_LIBRARIES` entries guarded by `$<COMPILE_ONLY:...>` are not
linked, but must participate in target ordering so files generated by
compile-only dependencies, like headers, are available before
compilation.

Fixes: #27792
2026-05-06 16:39:31 -04:00
Marc Chevrier
56b3136f60 fileapi: Add build properties for SOURCES file set type to codemodel
This complements commit 5c5b68f44e (FILE_SET: Add support for the
SOURCES type, 2026-03-12).

Co-Authored-By: Brad King <brad.king@kitware.com>
Co-Authored-By: Tyler Yankee <tyler.yankee@kitware.com>
2026-05-05 19:57:54 -04:00
Craig Scott
b8af7837b3 fileapi: Add interfaceSources to the target codemodel replies
Fixes: #27489
2026-02-05 21:20:48 +09:00
Brad King
8cc406ccab Merge topic 'fileapi-instrumentation-initial-cache'
ed023e0cfc Merge branch 'backport-4.0-fileapi-instrumentation-initial-cache'
5b63ea9ad3 instrumentation: Fix crash on cmake_instrumentation() call in initial cache
1bd6e70430 Merge branch 'backport-4.0-fileapi-instrumentation-initial-cache'
bb23f65928 instrumentation: Fix crash on cmake_instrumentation() call in initial cache
8523e579dc Merge branch 'backport-3.31-fileapi-initial-cache'
4d712cfc25 fileapi: Fix crash on cmake_file_api() call in initial cache

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11598
2026-01-16 09:34:44 -05:00
Brad King
1bd6e70430 Merge branch 'backport-4.0-fileapi-instrumentation-initial-cache' 2026-01-15 15:14:01 -05:00
Brad King
8523e579dc Merge branch 'backport-3.31-fileapi-initial-cache' 2026-01-15 15:13:13 -05:00
Martin Duffy
4d712cfc25 fileapi: Fix crash on cmake_file_api() call in initial cache 2026-01-15 14:51:57 -05:00
Brad King
2a1e1f69b2 Merge topic 'fileapi-windows-implib-missing-error'
c6a940761c fileapi: Handle unused imported libraries with missing IMPORTED_IMPLIB

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !11585
2026-01-13 10:32:20 -05:00
Craig Scott
c6a940761c fileapi: Handle unused imported libraries with missing IMPORTED_IMPLIB
CMake 4.1 and earlier did not issue an error if an imported shared library target
was missing an IMPORTED_IMPLIB property and nothing used that imported
library. There was no code path checking for the CMP0111 NEW behavior. Since
b626843d71 (fileAPI: Output all INTERFACE and IMPORTED targets, 2025-09-13),
we now include all imported targets in the file API replies, and that does trigger
that check. We need to tolerate such imported targets to preserve backward
compatibility, and to avoid issuing errors for problems in targets likely to be
coming from outside the project and beyond the developer's control.

Fixes: #27496
2026-01-10 00:26:55 +11:00
Craig Scott
6abf9ba501 fileapi: Fix missing file set index for headers in subdirectories
Fixes: #26402
2026-01-06 15:38:31 +11:00
Craig Scott
c98bec6ae6 Merge topic 'fileapi-compilerargs'
71a4e34d97 fileAPI: Expose CMAKE_<LANG>_COMPILER_ARG1
1e02926c9a fileAPI: Refactor toolchains schema to prepare for new version
3caa572c05 fileAPI: Output more info for test failures

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11419
2025-12-02 16:27:43 -05:00
Christian Walther
71a4e34d97 fileAPI: Expose CMAKE_<LANG>_COMPILER_ARG1
Compiler arguments coming from CC environment variables or multi-element
CMAKE_<LANG>_COMPILER variables set by toolchain files were previously not
exposed in the file API. Among other possible problems, this caused clients
to determine wrong system include paths and built-in preprocessor macros by
calling the compiler without these important arguments.

This is fixed by adding an optional "commandFragment" attribute to the
compiler description in the `toolchains` object, containing these arguments
as a command line fragment. This is already the form in which they are
internally stored in the CMAKE_<LANG>_COMPILER_ARG1 variable, so all that is
required is adding this variable to the set of exported variables, besides
some logic to omit it if empty.

Issue: #22568
2025-12-03 07:34:53 +11:00
Matthew Woehlke
a1a75f4008 cmake_file_api: Improve error message consistency
Remove literal text "subcommand" from error messages. This addresses the
other use of this and improves consistency (see preceding commit). Also,
omit some unnecessary articles, which also improves consistency.
2025-12-01 15:52:36 -05:00
Christian Walther
3caa572c05 fileAPI: Output more info for test failures
Add actual and expected values to the output for some possible failures in
the toolchains-v1 tests to make it easier to understand why a test failed.
2025-12-01 12:27:57 +01:00
AJIOB
5de7a09e77 Tests/RunCMake: Match dots more precisely, part 3 2025-10-20 14:45:24 -04:00
AJIOB
06ccd15457 Tests/RunCMake: Match xxx.cmake file name more precisely 2025-10-16 17:42:12 +03:00
Craig Scott
f38f325e08 fileAPI: Add direct dependencies to target codemodel files
This adds the following new arrays, which together capture all direct
dependencies and interface dependencies of a target:

- linkLibraries
- interfaceLinkLibraries
- compileDependencies
- interfaceCompileDependencies
- objectDependencies
- orderDependencies

Fixes: #21995, #25213
2025-10-07 10:44:28 -04:00
Craig Scott
004d825f3e fileAPI: Add test coverage for interface direct and genex contexts 2025-10-07 10:44:28 -04:00
Craig Scott
53ed1e5893 fileAPI: Fix wrong linking relationship in symbolic library test
Commit 62a1d3e7f1 (FileAPI: Add symbolic property to targets, 2025-09-30)
contained an error in added test code where a wrong library was linked.
The naming of the targets involved make clear the intended linking
relationship, but nothing in the test was actually testing or relying on
that relationship so it went undetected.
2025-10-07 10:44:28 -04:00
AJIOB
6874efb592 MSVC: Always define a character set
When targeting the MSVC ABI, define `_MBCS` by default if the project
does not define `_SBCS` or `_UNICODE`.  Visual Studio has long defined
one of the three character set macros automatically.  For consistency,
define it when compiling for the MSVC ABI with other generators.
Add policy CMP0204 for compatibility.

Fixes: #27275
2025-10-07 09:29:32 -04:00
Taylor Sasser
62a1d3e7f1 FileAPI: Add symbolic property to targets 2025-10-02 10:46:16 -04:00
AJIOB
83bbde5449 MSVC: Define _WINDLL consistently for shared libraries
Visual Studio defines this automatically for `.dll` targets.
For consistency, define it when compiling for the MSVC ABI
with other generators.  Add policy CMP0203 for compatibility.

Fixes: #27253
2025-09-29 18:26:44 -04:00
AJIOB
206fcbb392 Tests/RunCMake/FileAPI: Fix whitespace in codemodel-v2 expectation data 2025-09-29 18:08:04 -04:00
Craig Scott
b626843d71 fileAPI: Output all INTERFACE and IMPORTED targets
Fixes: #27248
2025-09-26 22:01:45 +10:00
Brad King
bb704d0390 Tests: Refactor RunCMake.FileAPI check script to support more arguments 2025-09-18 10:00:51 -04:00
Peter Kokot
2997d37adf FindJsonCpp: Add JsonCpp_VERSION
This also removes the JsonCpp_VERSION_STRING result variable, which
doesn't need to be deprecated and further provided by the module as this
is internal module.

Issue: #27088
2025-08-17 08:15:13 +02:00
Ben Boeckel
050f891d81 Tests: choose an explicit FULL strategy in tests expecting it
Since it can be set in the environment when running the test suite,
guard tests which are sensitive to intermediate directory strategy
changes with explicit settings.
2025-07-29 08:06:30 -04:00
Craig Scott
aa63990ca9 file API: Add JSON schema files
Fixes: #26987
2025-07-26 18:51:27 +10:00
Craig Scott
4315076f2e fileapi: Add codemodelVersion fields to target and directory objects
This will allow JSON schemas for these two types of files to describe the
version-specific content without requiring any outside information.

Fixes: #27031
2025-07-13 14:59:03 +10:00
Vito Gamberini
ea6404b9c4 FileAPI: Ignore unresolved FileSet generators
Fixes: #27054
2025-07-09 10:08:47 -04:00
Ben Boeckel
8df9819839 find_package: generate find_package-v1 configure log events
Since `find_package` is far more complex than other `find_*` commands,
it gets its own event.

Closes: #24833
2025-05-09 16:46:43 +02:00
Ben Boeckel
a3f273b657 cmFindBase: Create find-v1 configure log events
Record `find_` command events in the configure log, except
`find_package` as it is far more complicated (and will have its own
event kind).

Note that testing only generates the events of interest, there is no
verification. Also note that testing that the "found" to "notfound"
transition causes an event is not testable because a truthy value in the
variable skips any kind of verification or other logic beyond
normalization.

Co-Authored-by: Ryan Krattiger <ryan.krattiger@kitware.com>
See: #24833
2025-04-28 13:55:36 +02:00
Brad King
0cc962665b fileapi: Generate partial reply when buildsystem generation fails
In particular, the `configureLog` reply is useful for IDEs to read
`CMakeFiles/CMakeConfigureLog.yaml` when configuration fails.

Fixes: #26621
2025-04-14 10:42:03 -04:00
Brad King
5e0a644ee8 Tests/RunCMake/FileAPI: Explicitly specify expected reply index prefix 2025-04-14 09:34:22 -04:00
Stefan Wüthrich
1ae7497b6a fileapi: Restrict reply object file path lengths
Fixes: #23389
2025-01-27 09:49:19 +01:00
Garrett Campbell
0a9fb88121 fileapi: Report DEBUGGER_WORKING_DIRECTORY in codemodel-v2 target objects
Closes: #16478
2024-12-10 09:04:31 -05:00
Brad King
200efab4d4 Tests/RunCMake/FileAPI: Improve error on unexpected line numbers 2024-12-06 18:05:20 -05:00
Brad King
655a245d60 Tests: Explicitly disable AIX_SHARED_LIBRARY_ARCHIVE in some cases
We do not want AIX shared library archives in test cases that rely on
cross-platform appearance of `.so` files.
2024-11-23 15:23:25 -05:00
Brad King
7b19531291 macOS: Do not pass any SDK/-isysroot to compilers by default
On modern macOS, compiler wrappers like `/usr/bin/cc` automatically
choose a SDK to pass via `-isysroot` to an underlying compiler from
Xcode or the CommandLineTools.  Other toolchains like Homebrew's `gcc-*`
come with a default SDK too.  Therefore, when targeting macOS, we no
longer need to choose any SDK or pass an `-isysroot` flag by default.

Update initialization of `CMAKE_OSX_SYSROOT` to be empty by default when
targeting macOS.

Fixes: #19180
2024-11-07 09:46:10 -05:00