Commit Graph
100 Commits
Author SHA1 Message Date
Martin Duffy a2643a6db6 instrumentation: Add instrumentation version to cmake -E capabilities 2026-09-22 08:39:58 -04:00
Martin Duffy 01fa1984e5 instrumentation: Send processMetrics data to CDash 2026-09-17 10:29:06 -04:00
Martin Duffy 68e2a3e793 instrumentation: Rename userTime and systemTime fields to exclude units
Drop the "USec" suffix from these fields for consistency with other
instrumentation fields which do not include units.
2026-09-17 10:10:31 -04:00
Martin Duffy ff48c8d4d2 Tests/Instrumentation: Fix exponential output spam from validate_json_schema
Schema validations in Tests/Instrumentation called add_error("${RunCMake_TEST_FAILED}")
in a loop. Because add_error itself appends the input to RunCMake_TEST_FAILED, this
resulted in exponential growth of error messages on each loop iteration, filling the
test log with duplicate errors.

Isolate error messages from validate_json_schema to avoid exponential duplication.
2026-09-16 13:12:03 -04:00
Martin Duffy 77443e7258 instrumentation: Don't expect staged CDash files when cdashSubmit is disabled 2026-09-14 15:38:40 -04:00
Martin Duffy 484cac3916 File API: Add interfaceIncludes field
Fixes: #28006
2026-09-04 11:54:02 +10:00
Martin Duffy 5f222e8f3a Instrumentation: Add Process Resource Usage Metrics
Issue: #26675, #27742
2026-08-27 10:24:25 -04:00
Martin Duffy c31f09a1e6 CMAKE_TEST_BUILD_DEPENDS: Use config when evaluating test dependency targets
Fixes: #27979
2026-07-22 10:41:30 -04:00
Martin Duffy 593c4ccaa6 CMAKE_TEST_BUILD_DEPENDS: Use config when evaluating test dependency targets
Fixes: #27979
2026-07-22 10:17:54 -04:00
Martin Duffy 89b1e21a5e instrumentation: Gather compile trace files in compile rsp
Updates instrumentation logic for gathering compile trace files to parse
compiler options in a response file for the presence of `-ftime-trace=...`.
2026-07-01 12:52:15 -04:00
Martin Duffy e11b5827c3 ctest: Add --out-of-date option for running out of date tests
Add an --out-of-date option to ctest which runs only those tests with
recorded build dependencies whose timestamps are newer than the timestamp
at which the test last finished.

Fixes: #27614
2026-06-30 11:31:35 -04:00
Martin Duffy 2d417b9371 FASTBuild: Generate test_prep/ targets for test build dependencies
Issue: #27879
2026-06-23 12:20:49 -04:00
Martin Duffy e2f4b9bedc pvs-studio: (V522) Prevent possible null-pointer dereference in RemoveRPathELF 2026-06-17 10:13:12 -04:00
Martin Duffy 77b874baa8 pvs-studio: (V1086) Fix buffer writes
Replace space-filling memset calls with bounded character initialization that
preserves null termination for the curses help text buffers.
2026-06-17 10:13:03 -04:00
Martin Duffy a77b7aa836 pvs-studio: (V557) Harden array boundary checks
Tighten array boundary checks to prevent possible overrun.
2026-06-16 17:16:32 -04:00
Martin Duffy 7217af55da pvs-studio: (V555) Clarify size_type comparison
The expression 'r - l > 0' implies a sign to r and l that does not exist.
2026-06-16 17:16:32 -04:00
Martin Duffy 576471ba47 Help/instrumentation: Add release notes for instrumentation data version 1.1 2026-06-10 15:19:41 -04:00
Martin Duffy 0480222ff4 instrumentation: Add compileTrace option
Adds support for optionally saving and reporting trace files generated by
Clang's `-ftime-trace` option.
2026-06-10 15:19:41 -04:00
Martin Duffy 8e2aecbe42 instrumentation: Increase data version to 1.1 2026-06-04 10:42:04 -04:00
Martin Duffy 1a85245496 instrumentation: Optionally Record Command Output
Add `stdout`  and `stderr` reporting to instrumentation for `compile`, `link`,
`custom`, `install` and `test` snippets when the `captureOutput` option is
enabled.

Fixes: #26704
2026-06-04 10:42:04 -04:00
Martin Duffy 6674be6d26 RunCMake: Allow error output suppression from run_cmake 2026-06-04 10:42:04 -04:00
Martin Duffy f5a0f6478e Merge branch 'backport-instrumentation-data-version-minor' into instrumentation-data-version-minor
Use the `-s ours` merge strategy because both sides have already
made equivalent changes.
2026-06-02 08:55:37 -04:00
Martin Duffy dcf146c34d instrumentation: Revise Data Version format
Give data version the new format <major>.<minor>, so that
the version can be incremented with the introduction of new
features without bumping the major version.

Add support for loading instrumentation JSON queries of unknown
data versions without error.

Issue: #27833
2026-06-02 08:55:20 -04:00
Martin Duffy df36317176 instrumentation: Revise Data Version format
Give data version the new format <major>.<minor>, so that
the version can be incremented with the introduction of new
features without bumping the major version.

Add support for loading instrumentation JSON queries of unknown
data versions without error.

Issue: #27833
2026-06-02 08:53:21 -04:00
Martin Duffy ba6b6fbc24 Ninja: Add Build Dependencies for Tests
Add `test_prep/<test_name>` convenience targets to the ninja generator
to build dependencies of tests, and `test_prep/all` to build the dependencies
of all tests.

Build dependencies of a test include:
- Executables directly invoked by test `COMMAND`.
- Targets mentioned in generator expressionf os test `COMMAND`.
- Anything explicitly listed with the new `BUILD_DEPENDS` argument of `add_test`.

Issue: #27613
2026-05-26 15:16:19 -04:00
Martin Duffy 1d0f587062 instrumentation: Clarify API and Data version distinction
The instrumentation docs were unclear about the difference between API
and Data version, with the hierarchy of the table of contents being
particularly misleading.

Rework `cmake-instrumentation` manual and `cmake_instrumentation` command
documentation to be more clear.
2026-05-20 15:20:09 -04:00
Martin Duffy bd059a9c54 Help: Allow command-line help of per-language and per-config variables
Extend commit 4e50320978 (Help: Allow help for arbitrary keywords,
2023-08-31, v3.28.0-rc1~31^2).
2026-05-19 15:10:11 -04:00
Martin Duffy 180746bc7c instrumentation: Don't instrument disabled tests
Fixes: #27791
2026-05-12 11:09:58 -04:00
Martin Duffy 3748deda58 pvs-studio: Add .pvsconfig exclusion file 2026-04-29 18:22:33 -04:00
Martin Duffy 0c2fcaec5d instrumentation: Avoid duplicate entries on concurrent indexing
When indexing occurs twice at exactly the same time, there was a possibility
for snippets to show up in more than one index file, and therefore to be
removed by one indexing process while another indexing process ran a user
callback which needed to read the file.

Add a file locking mechanism around indexing to prevent it from happening
concurrently within a project build tree.

Fixes: #27741
2026-04-10 14:06:38 -04:00
Martin Duffy b8d8faf900 Help/instrumentation: Improve CMake Instrumentation documentation
Fixes: #27688
2026-03-24 17:09:38 -04:00
Martin Duffy 35c9c85ff2 Help: Document instrumentation use case for CMAKE_CONFIG_DIR 2026-03-20 09:45:42 -04:00
Martin DuffyandTyler Yankee fb541168f0 instrumentation: Reset queries on repeat configure steps from CMake GUI
Prevent repeat configure calls from the CMake GUI or `ccmake` tool from
loading query duplicates, which caused many duplicate callbacks to be
invoked on each subsequent hook.

Also ensure that multiple subsequent configure steps invoked by CMake
GUI and `ccmake` each have an associated snippet file during generate.

Fixes: #27651
Co-Authored-By: Tyler Yankee <tyler.yankee@kitware.com>
2026-03-04 16:22:47 -05:00
Martin Duffy b6b946f7ec instrumentation: Test shell redirection in instrumented custom commands
Issue: #27610
2026-02-20 08:59:59 -05:00
Martin Duffy 50535776c5 cmake -E cat: Read from stdin when no other args are given 2026-02-19 16:33:06 -05:00
Martin Duffy 95dc40d8a8 Experimental: Remove Instrumentation experimental gating
Fixes: #27348
2026-02-05 14:05:42 -05:00
Martin Duffy ffff6576b4 instrumentation: Add project field to cmake content files 2026-02-03 09:15:49 -05:00
Martin Duffy 79c88703eb instrumentation: Add JSON schema for query files
Issue: #27504
2026-01-27 16:00:30 -05:00
Martin Duffy 65014c0ee3 Help/instrumentation: Fix "result" key in example snippet file
Snippet file example erroneously included a key of "return" instead of "result".
2026-01-23 17:04:27 -05:00
Martin Duffy 71fe659641 instrumentation: Write empty JSON object when custom content is empty
Replaces the previous value of `null` when no `CUSTOM_CONTENT` was specified.
2026-01-22 13:20:12 -05:00
Martin Duffy 5ede033f57 ci: Add job for instrumentation on Linux 2026-01-22 10:41:11 -05:00
Martin Duffy 614715d56f instrumentation: Fix cdashSubmit option
Setting cdashSubmit option automatically enables the dynamicSystemInformation
option and prepareForCDash hooks.
2026-01-19 13:26:29 -05:00
Martin Duffy ef12ef1bd6 pvs-studio: Add support for linting with PVS-Studio 2026-01-16 11:25:59 -05:00
Martin Duffy 5b63ea9ad3 instrumentation: Fix crash on cmake_instrumentation() call in initial cache 2026-01-15 15:14:19 -05:00
Martin Duffy bb23f65928 instrumentation: Fix crash on cmake_instrumentation() call in initial cache 2026-01-15 15:13:34 -05:00
Martin Duffy 4d712cfc25 fileapi: Fix crash on cmake_file_api() call in initial cache 2026-01-15 14:51:57 -05:00
Martin Duffy 8f722e0fac cmList: Expose container reserve 2026-01-13 11:29:23 -05:00
Martin Duffy 5d1f269658 cmcmd: Allow passing object file to co_compile commands 2026-01-13 11:29:23 -05:00
Martin Duffy 16b8cb2669 Help/instrumentation: Remove mention of undocumented options
Fixes: #27494
2026-01-09 15:37:32 +11:00
Martin Duffy 2bf3fd05cc instrumentation: Include MODULE_LIBRARY in CMake content
Issue: #27488
2026-01-07 09:32:04 -05:00
Martin Duffy 0b06a4cbbe instrumentation: Cleanup for RunCMake tests
- Add default instrumentation query for tests
- Ignore dev warnings by default and test experimental warning output
2025-12-16 11:50:43 -05:00
Martin Duffy 41c69f8c87 cmGeneratorExpression: Fix parser for adjacent colon and comma
Update ParseGeneratorExpression to allow correct parsing of adjacent
colon and comma separators in either order.

Fixes: #27324
2025-12-05 14:12:31 -05:00
Martin Duffy 956d36d3cd instrumentation: Add postCMakeWorkflow hook
Issue: #27414
2025-12-03 16:00:37 -05:00
Martin Duffy de3cb099a3 instrumentation: Add showOnly to ctest snippets
Fixes: #27269
2025-10-24 11:08:52 -04:00
Martin Duffy 2976742520 instrumentation: Only quote arguments that contain a space 2025-10-24 11:08:39 -04:00
Martin Duffy 6e637b1102 install(PACKAGE_INFO): Fix error when usage requirements contain certain genex
Since commit 13c7bb5b0c (cmGeneratorExpression: Update strip function to
collect parsed expressions, 2025-04-08, v4.1.0-rc1~361^2~1), the logic
to strip generator expressions would error if the stripped expressions
were being collected and an expression without a `:` was found inside an
expression with a `:`. This resulted in an error when exporting a target
that contained such a generator expression in its link libraries or
compile definitions.

Address the error by checking whether the latest `$<` proceeded the
latest `:`.
2025-10-17 11:34:43 -04:00
Martin Duffy f195c9ef2a genex: Add TARGET_INTERMEDIATE_DIR expression
Fixes: #27196
2025-10-09 08:07:20 -04:00
Martin Duffy 5c5634db52 cmGeneratorExpressionNode: Factor out HasKnownObjectFileLocation check 2025-10-08 17:34:02 -04:00
Martin Duffy 97adbc91fa instrumentation: Move target data into content files
Create a single place to store target data to prevent duplication.
This moves `targetType` and `targetLabels` out of the snippet files
and into a target map in the `cmakeContent` file referenced by each
snippet.

Fixes: #27244
2025-10-02 09:28:20 -04:00
Martin Duffy f6714b8949 instrumentation: Trigger PostGenerate hook after FileApi replies are written
Fixes: #27268
2025-09-29 09:43:53 -04:00
Martin Duffy e730008d7e instrumentation: Record build snippets regardless of hooks 2025-09-26 15:55:08 -04:00
Martin Duffy 2fdd1e787f instrumentation: Additional data in custom, install and link snippets
- Include `config` in all `install` and `custom` snippets
- Include `target` for `custom` snippets where applicable
- Document and test inclusion of `language` in `link` snippets

Issue: #27244
2025-09-24 16:39:09 -04:00
Martin Duffy 3db07b0189 cmInstallScriptHandler: Refactor to store config and path for each command 2025-09-24 12:41:32 -04:00
Martin Duffy b8014633dc Experimental: Update the Instrumentation UUID
Update experimental UUID for instrumentation after commit 4683db44a1
(instrumentation: Write index files to data/index/ subdirectory, 2025-09-19)
updated the location of index files.
2025-09-23 10:59:54 -04:00
Martin Duffy ba3c278da2 instrumentation: Don't remove content files older than an index
Prevent callbacks from referencing deleted content files by holding onto them
if any index files exist that may contain a reference.
2025-09-19 11:29:16 -04:00
Martin Duffy 4683db44a1 instrumentation: Write index files to data/index/ subdirectory 2025-09-19 11:29:03 -04:00
Martin Duffy e5db41147a Tests/instrumentation: Improve error message when postBuild check fails 2025-09-16 09:45:37 -04:00
Martin Duffy 903d35353f instrumentation: Update tests and documentation for FASTBuild support
Fixes: #27184
2025-09-03 10:49:51 -04:00
Martin Duffy bd24854d56 FASTBuild: Expand TargetLabels and Config for Link Commands 2025-09-03 10:40:17 -04:00
Martin Duffy 451e2cb2a1 instrumentation: Add cmake_instrumentation check to ctest_instrumentation test
Update the `ctest_instrumentation` test cases to cover use of the
`cmake_instrumentation` command and some of its arguments as a way of enabling
instrumentation.
2025-08-21 07:20:20 -04:00
Martin Duffy e6b37105ba instrumentation: Collect custom content from CMake configure
Add a `CUSTOM_CONTENT` argument to `cmake_instrumentation()` for collecting
custom content from configure time.

Snippet files include a reference to a JSON file containing any `CUSTOM_CONTENT`
that was added by this command.

Fixes: #26703
2025-08-21 07:20:12 -04:00
Martin Duffy 8227028e49 string(GENEX_STRIP): Fix regression on nested generator expressions
Since commit 13c7bb5b0c (cmGeneratorExpression: Update strip function to
collect parsed expressions, 2025-04-08), the logic to strip generator
expressions from a string made incorrect assumptions about the contents of
generator expressions, leading certain cases to be stripped incorrectly.

Clean up the logic and fix broken behavior, and add test coverage with
`string(GENEX_STRIP)`.

Fixes: #27133
2025-08-13 15:52:16 -04:00
Martin Duffy a97bb70bd9 Tests: Isolate tests from CTEST_USE_INSTRUMENTATION variable
Prevent CMake's own tests from gathering instrumentation data when
`CTEST_USE_INSTRUMENTATION` is enabled in the environment.

Fixes: #26916
2025-08-08 09:52:01 -04:00
Martin Duffy 2e05695b30 Help: Fix documentation for CTEST_USE_*_INSTRUMENTATION variables 2025-08-06 17:11:03 -04:00
Martin Duffy a249e820a8 instrumentation: Add file lock for build daemon
Prevent starting instrumentation build daemon and related hooks if one is
already running, and when during `cmake --build`.
2025-08-06 11:45:40 -04:00
Martin Duffy aaf433d99a Utilities/Sphinx: Add option to disable documentation from ALL 2025-08-06 09:30:39 -04:00
Martin Duffy 7435cabef3 Help: Add clarifying text to instrumentation API and Data versions 2025-08-06 09:18:09 -04:00
Martin Duffy 9b65be6da5 instrumentation: Don't load query files before configure
Prevent the duplication of callbacks that came from loading instrumentation
queries both before and after configure.
2025-08-05 14:16:45 -04:00
Martin Duffy 21ac285cd8 Experimental: Update the Instrumentation UUID
Update experimental UUID for instrumentation after commit afa94bae1e
(instrumentation: Rename queries field to options, 2025-07-08) broke compatibility
for old queries.
2025-07-15 08:38:44 -04:00
Martin Duffy 9dec460c8c instrumentation: Store CDash settings in query files
Adds new `cdashSubmit` and `cdashVerbose` options to allow enabling
instrumentation in CDash submissions using query files or the
`cmake_instrumentation` command.

Fixes: #26783, #26727
2025-07-14 15:44:52 -04:00
Martin Duffy 35f002e293 string(JSON): Include invalid JSON in parse error 2025-07-11 11:16:39 -04:00
Martin Duffy afa94bae1e instrumentation: Rename queries field to options
Fixes: #26728
2025-07-10 16:25:07 -04:00
Martin Duffy e01d12c14f instrumentation: Prevent unnecessary query loading
Don't load queries from instrumentation directories when GetIsInTryCompile
or before ClearGeneratedQueries from previous configures has run.
2025-06-09 11:33:24 -04:00
Martin Duffy f26f127183 instrumentation: Reuse single cmsys::SystemInformation 2025-06-09 11:33:18 -04:00
Martin Duffy cc2cbfc61e file: Add more context to errors from file(DOWNLOAD) 2025-04-18 13:30:05 -04:00
Martin Duffy 20858ddb29 CMake: Enable parallel install for CMake itself 2025-04-15 11:41:06 -04:00
Martin Duffy ebe487ea81 export: Allow export with LINK_ONLY library dependencies 2025-04-11 13:20:14 -04:00
Martin Duffy 13c7bb5b0c cmGeneratorExpression: Update strip function to collect parsed expressions 2025-04-11 10:54:20 -04:00
Martin Duffy 39f365ec3c instrumentation: Unique snippet file names
Updates the hash in snippet file naming to take the ProcessId into account
so that snippets with identical commands don't risk a collision in filename.

Additionally, this adds a `workingDir` to snippet files so that snippets with
identical commands can be more easily differentiated, such as with install
snippets.
2025-03-18 13:23:02 -04:00
Martin Duffy d723409e8e export: Allow multiple exports when only one export is installed
Since commit c8997fc046 (export: Allow depending on targets exported
multiple times, 2024-12-26, v4.0.0-rc1~241^2), it is possible to depend
on a target exported multiple times so long as the target is exported in
only one set and with a consistent namespace.  However, as a
side-effect, a target could not be in multiple export sets even if only
one of those sets was installed.

Update the check so that uninstalled export sets do not count towards a
target being exported multiple times.
2025-03-17 18:01:30 -04:00
Martin Duffy bed7e90bae cmJSONState: Use StructuredErrors when available
When the version of JsonCpp permits it, use StructuredErrors to generate
error messages for parse errors in the same style as other CMake-generated
JSON error messages.

Fixes: #26717
2025-03-17 14:17:34 -04:00
Martin Duffy 40039ddbac Help: Document backtrace member of link commandFragments in FileApi manual 2025-03-14 11:18:48 -04:00
Martin Duffy f134468a98 JSON: Improve JSON error message formatting
This improves the output of JSON-related error messages. It adds the filename to
the output and excludes the column number.

This is particularly useful when there are multiple JSON files being read that
could be responsible for an error, ie CMakePresets.json and
CMakeUserPresets.json, or multiple instrumentation queries.

Issue: #26717
2025-03-13 10:44:31 -04:00
Martin Duffy 857a039d66 find_*: Add variable to default calls to REQUIRED
This adds a `CMAKE_FIND_REQUIRED` variable which causes `find_package`,
`find_path`, `find_file`, `find_library` and `find_program` to be
considered `REQUIRED` by default.

It also introduces an `OPTIONAL` keyword to those commands, allowing
them to ignore the value of this variable.

Issue: #26576
2025-02-27 10:51:07 -05:00
Martin Duffy 609c949061 add_dependencies: Allow calling with no dependencies
Fixes: #26713
2025-02-24 13:56:31 -05:00
Martin Duffy 4e7b37cad3 instrumentation: Quote command arguments to preserve separation
Fixes: #26702
2025-02-24 13:11:19 -05:00
Martin Duffy 99cd4d979b CTest: Fix startTime in test snippets when using instrumentation
Initialize SystemStartTime for TestProcess.
2025-02-24 11:50:11 -05:00
Martin Duffy 45d3ffaa95 instrumentation: Use auto for variables holding closures 2025-02-17 11:08:30 -05:00
Martin Duffy d75ccd9f8d instrumentation: Fix docs for ctest --collect-instrumentation option 2025-02-17 11:03:28 -05:00
Martin Duffy a2232db802 instrumentation: Make hooks compatible with presets 2025-02-17 11:03:28 -05:00