267 Commits
Author SHA1 Message Date
Robert Maynard ef3681667f Diagnostics: Add CMD_INSTALL_ABSOLUTE_DIR for all install types
The original addition of CMD_INSTALL_ABSOLUTE_DIR by commit
39a56136a3 (Diagnostic: Add warn or error on absolute install paths,
2026-03-25) didn't cover all install signatures. Add checks to cover
those install types that weren't covered by the original commit.
2026-06-05 13:10:12 -04:00
Robert Maynard f9fe9884ac Diagnostics: CMD_INSTALL_ABSOLUTE_DIR follows CMake message style 2026-06-03 18:23:25 -04:00
Tom Osika 273fc4cc49 SBOM: Support multi export set SBOMs 2026-06-01 12:27:13 -04:00
Brad King f4c33c7762 Merge topic 'better-policy-diagnostics'
763cfbcac8 Diagnostics: "Fix" policy warnings in modules
a7415d243a Diagnostics: Simplify issuing policy warnings

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12079
2026-05-21 09:47:07 -04:00
Matthew Woehlke a7415d243a Diagnostics: Simplify issuing policy warnings
Add and use a couple helper functions for issuing policy warnings. This
improves consistency and allows some simplification of many call sites.
(One or two instances in particular are greatly simplified.)
2026-05-20 11:55:13 -04:00
Brad King 9d94a2abe6 Merge branch 'backport-cps-fix-default-dest' into cps-fix-default-dest 2026-05-19 15:26:46 -04:00
Matthew Woehlke ed6e9abf98 CPS, SBOM: Fix default output destination
- Change default CPS install path on Windows from `cps` to `cps/<name>`,
per community recommendation that only paths containing the package name
should be considered as "officially" supported search locations (see
https://github.com/cps-org/cps/issues/79#issuecomment-2831102822).

- Change `export` to write to a subdirectory that allows the build
tree to be used as a search root.

- Change SBOM destinations to be consistent with the preceding.

Issue: #27785
2026-05-19 13:31:56 -04:00
Matthew Woehlke 028d3183ad Diagnostics: Add POLICY, EXPERIMENTAL
Add new diagnostic categories CMD_POLICY and CMD_EXPERIMENTAL, both as
children of CMD_AUTHOR. Use the former when issuing policy warnings. Use
the latter when issuing experimental feature warnings.
2026-05-15 09:57:23 -04:00
Matthew Woehlke 5ed6b90a31 Diagnostics: Capture install state
Modify `cmInstallGenerator` to have a `cmDiagnosticContext` instead of
just a `cmListFileBacktrace`. Create helpers to obtain a state capture
that includes `CMD_INSTALL_ABSOLUTE_DESTINATION`. Modify most subclasses
(namely, ones that have a `DESTINATION`) to use this new state capture.

This fixes a limitation identified when 39a56136a3 (Diagnostic: Add warn
or error on absolute install paths, 2026-03-25) added the aforementioned
diagnostic, that the install generator(s) no longer have access to the
diagnostic state as of the `install` invocation which ultimately caused
the diagnostic if that scope is not the top-most scope of the current
subdirectory.

Note that some of the generators which capture context have not actually
implemented the diagnostic yet.
2026-05-08 11:23:11 -04:00
Matthew Woehlke 732b9585a7 Style: Use camelCase identifiers
Fix most snake_case identifiers in cmInstall* to use camelCase instead.

Also, update clang-tidy configuration to help with applying these
changes, though the relevant check remains off by default.
2026-05-06 11:17:02 -04:00
Robert Maynard 39a56136a3 Diagnostic: Add warn or error on absolute install paths
Add `-Winstall-absolute-destination` diagnostic to warn or
error when an install command has an absolute destination.

This allow projects to enforce the best practice of not allowing
absolute install DESTINATIONS.
2026-04-29 09:22:29 -04:00
Matthew Woehlke 1309532390 Diagnostics: Use new methods
Find places that are currently relying on diagnostic-specific message
types to issue diagnostics and replace these with calls to the new
diagnostic methods.
2026-04-16 15:10:35 -04:00
Brad King 6355164f10 Merge topic 'install-default-component-from-project'
accabeb272 install: Add option to use project name as default component

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11811
2026-03-18 09:40:11 -04:00
Robert Maynard accabeb272 install: Add option to use project name as default component
Teach `CMAKE_INSTALL_DEFAULT_COMPONENT_NAME` to accept a special
`<PROJECT_NAME>` placeholder.

Fixes: #27682
2026-03-17 10:33:44 -04:00
Marc Chevrier 280733b7b2 File Sets: Refactor install/export to prepare for new file set types 2026-03-15 09:31:58 +01:00
Marc Chevrier 737b1da9fe cmInstallDirs: Factor out helper for install directories
To enable the retrieval of the various default install directories,
introduce functions in the namespace `cm::InstallDirs`.
2026-03-15 09:09:51 +01:00
Matthew Woehlke f5c515cbf2 CPS: Remove experimental gate (mostly)
Remove basic CPS import and export from 'experimental' status. Update
documentation and tests accordingly.

Note that mapped exports (CMAKE_EXPERIMENTAL_MAPPED_PACKAGE_INFO) are
still experimental.
2026-02-11 16:10:29 -05:00
Brad King b0bcc6c7c0 Merge topic 'UseMoreStringViews'
70509802f5 cmSystemTools: Fix clang tidy warning else after return
d932b6fb8d Prefer cmHasSuffix for specific extension checks
35af170961 cmSystemTools: Take view instead of ref as parameter
9daa1012d4 cmGlobalGenerator: Avoid string copies by returning view
e531e7420d Reduce string copies by using View function alternatives
62a4099fd2 cmGeneratorTarget: Cache GetAllConfigCompileLanguages
6ed75b1fe6 cmGlobalGenerator: Use transparent comparator to avoid string copies
9a575a835f cmPropertyDefinition: Avoid string copies for Property lookups
...

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !11634
2026-02-07 09:33:34 -05:00
Brad King 417d83fc3c Merge topic 'install-dir-empty'
4e7e6928cb install: Fix bugs around empty directories

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11660
2026-02-07 09:27:03 -05:00
John Franklin Rickard d932b6fb8d Prefer cmHasSuffix for specific extension checks 2026-02-06 12:27:23 -05:00
John Franklin Rickard e531e7420d Reduce string copies by using View function alternatives 2026-02-06 12:27:13 -05:00
Tyler Yankee 4e7e6928cb install: Fix bugs around empty directories
The conversion between internal list representations led to empty
directories being left behind when processing generator expressions in
the destination. This ensures the intended behavior of creating a
destination directory but installing nothing into it when no <dirs> are
specified, regardless of the presence or absence of genex.

Further, an explicit empty string <dir> (via `""`, or an undefined
variable) led to the current source directory being expanded as a file
to install, leading to the generation of an infinitely recursive
install command. Disallow this behavior, forcing projects to explicitly
specify the current source directory if that is their intention.

Fixes: #27568
2026-02-05 19:33:47 -05:00
Brad King 29c26a10a1 Merge topic 'sbom-cli-integration'
f25e41f992 cmSbom: Add flag to automatically export sbom information

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !11593
2026-02-05 13:18:53 -05:00
Taylor Sasser f25e41f992 cmSbom: Add flag to automatically export sbom information 2026-02-03 10:49:42 -05:00
Vito Gamberini 3771471310 CPS: Support C++20 modules
Modify the PackageInfo exporters and commands to support C++20 modules
via the collator-generated module manifest.

Fixes #27548
2026-01-29 13:26:35 -05:00
Taylor Sasser f2027a886b cmSbom: Add install(SBOM) generator and unit tests 2025-12-17 14:33:34 -05:00
Matthew Woehlke 2151e5f79d export, install: Improve argument parsing
Modify the `export(EXPORT)` and `install(PACKAGE_INFO)` commands to
actually enforce that certain arguments must be non-empty. With respect
to `export`, this is mainly targeted at CPS export, but ends up
affecting all flavors of `export(EXPORT)` because that is the level at
which argument parsing is performed.

Also, add unit tests to verify that the new rejection of arguments with
missing or empty values is working, update the existing tests due to
changes in error reporting, and remove no-longer-needed manual
validation of an empty `PACKAGE_INFO` argument.
2025-12-09 13:37:01 -05:00
Brad King a294c9ac1a Merge topic 'fix-cps-arg-parsing'
41b6b07527 cmExportCommand: Fix PACKAGE_INFO argument parsing

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11459
2025-12-02 15:20:14 -05:00
Matthew Woehlke 41b6b07527 cmExportCommand: Fix PACKAGE_INFO argument parsing
While I'm unsure about why `cmPackageInfoArguments` was originally
written the way it was, in its current form, the way command sub-parsers
work, the parser never considers arguments associated with a sub-parser
if the sub-parser keyword isn't present. This means that the arguments
associated with `cmPackageInfoArguments` are treated as unknown, and the
logic to reject them being set if `PACKAGE_INFO` is not present can
never actually execute. Therefore, remove it, and remove the associated
(and effectively useless) `enable` argument to its `Check` method.

Instead, ensure that the package name is actually specified. The only
case in which the parser will create the `optional` associated with the
sub-parser arguments is if the relevant keyword (i.e. `PACKAGE_INFO`) is
present. However, while the associated value is `NonEmpty`, the way we
are using the parser does not actually enforce this, and it looks like a
correct fix may be a breaking change. Therefore, enforce it manually for
now.
2025-12-01 11:22:58 -05:00
hanna.rusakovich bf3f69834d file(GET_RUNTIME_DEPENDENCIES): Normalize paths before matching
Regex-based filtering should not have to account for slash differences.
Add policy CMP0207 for compatibility.

Fixes: #26202
2025-11-14 17:23:26 +03:00
Matthew Woehlke 34343922a5 install: Add ability to generate CPS from install(EXPORT)
Add the ability to generate CPS package information when install(EXPORT)
is used. This relies on additional information to be passed to CMake,
and is intended as a way of getting CPS out of existing projects without
needing to make changes to the projects' CMakeLists.txt. (Particularly,
this feature is intended for package distributors, not project authors.)
2025-11-11 11:51:58 -05:00
Matthew Woehlke b9f3adb0a6 install(EXPORT): Fail earlier if EXPORT is missing
Add an explicit check in `install(EXPORT)` that the export name is
non-empty. Since an empty-named export set will never exist, this is
always an error. Previously, however, the error would not be caught
until generate time. Now an error will be produced immediately.
2025-10-14 11:52:03 -04:00
F. Pichot a20e9569f1 install(PACKAGE_INFO): Record COMPONENT in global COMPONENTS list
Fixes: #27249
2025-09-23 10:23:37 -04:00
F. Pichot 5e7f21328c install(EXPORT_ANDROID_MK): Record COMPONENT in global COMPONENTS list
Issue: #27249
2025-09-23 10:20:21 -04:00
F. Pichot abfc07f91f install(EXPORT): Record COMPONENT in global COMPONENTS list
Issue: #27249
2025-09-23 10:19:13 -04:00
Brad King 21e99dbf49 install(DIRECTORY): Revert "Add EXCLUDE_EMPTY_DIRECTORIES option"
Revert commit b70ef48b27 (install(DIRECTORY): Add
EXCLUDE_EMPTY_DIRECTORIES option, 2025-04-20, v4.1.0-rc1~212^2).
The implementation had at least two problems:

* It did not exclude the top-level directory if empty.
* It did not exclude non-empty directories whose contents are
  all filtered out.

Revert the feature pending a revised implementation.

Issue: #19189
Closes: #27092
2025-07-28 14:21:09 -04:00
Vito Gamberini d71b59a4f7 install(TARGETS): Don't ignore non-extant file sets
When installing FILE_SETs, it is possible the FILE_SET has not yet been
created with target_sources(FILE_SET). Instead of ignoring this
situation, we need to track the installed FILE_SET names and their
possible install destinations.

At generation time we resolve the names and destinations concretely. If
a FILE_SET wasn't provided or isn't an INTERFACE, we silently bail out.

Fixes: #26697
2025-06-12 16:58:11 -04:00
Matthew Woehlke ecf81c1bc1 CPS: Get metadata from project
Modify {export,install}(PACKAGE_INFO) commands to inherit version
information from the current project in situations where it seems
reasonable to do so. Add an option to explicitly request inheritance
from a specific project.

This leverages the recently added project(COMPAT_VERSION).
2025-06-02 10:31:36 -04:00
Matthew Woehlke 0ccbe5a2e1 CPS: Refactor argument parsing
CPS package metadata involves a fair amount of passing around a
particular set of values, as well as shared argument handling, which is
only going to increase as additional features are added. In order to
reduce code duplication (now and going forward), create a helper class
to handle the shared argument parsing and to serve as a container to
pass metadata values.
2025-06-02 10:31:35 -04:00
Ben Boeckel 557c44b93e cmStrCat: use character literals where possible
Found and replaced using the `cmstrcat-to-char-literal` rule for
`ast-grep`.
2025-05-15 19:12:04 +02:00
Ben Boeckel 23779057fd cmStrCat: combine neighboring arguments where possible
Found using the `cmstrcat-adjacent-literals` rule for `ast-grep`.
2025-05-15 19:11:41 +02:00
Hao Dong b70ef48b27 install(DIRECTORY): Add EXCLUDE_EMPTY_DIRECTORIES option
EXCLUDE_EMPTY_DIRECTORIES option excludes empty directories under the
directory to install. A directory is considered not empty if and only if
the directory contains at least one file or one symbolic link or one
none-empty sub-directory.

Closes: #19189
2025-05-06 10:59:24 -04:00
Kitware Robot 1772622772 LICENSE: Replace references to Copyright.txt with LICENSE.rst
```
git grep -lz 'Copyright.txt or https://cmake.org/licensing ' |
  while IFS= read -r -d $'\0' f ; do
    sed -i '/Copyright.txt or https:\/\/cmake.org\/licensing / {
              s/Copyright.txt/LICENSE.rst/
            }' "$f" ; done
```
2025-03-03 10:43:35 -05:00
Kitware Robot 0b96ae1f6a Revise C++ coding style using clang-format with "east const"
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`, now with "east const" enforcement.
Use `clang-format` version 18.

* If you reached this commit for a line in `git blame`, re-run the blame
  operation starting at the parent of this commit to see older history
  for the content.

* See the parent commit for instructions to rebase a change across this
  style transition commit.

Issue: #26123
2025-01-23 13:09:50 -05:00
Brad King 1d4d4362d9 Merge topic 'remove-old-compatibility'
77f71ad4e2 Remove compatibility with CMake versions older than 3.5
fb1bd1d330 CMP0065: Remove support for OLD behavior
d9dd38cccf CMP0064: Remove support for OLD behavior
d88047c329 Remove compatibility with CMake versions older than 3.3
ac1a9cb160 CMP0063: Remove support for OLD behavior
36fffb673a CMP0062: Remove support for OLD behavior
789a7d73d4 CMP0061: Remove support for OLD behavior
3dc19e24cb CMP0060: Remove support for OLD behavior
...

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10210
2025-01-23 09:36:59 -05:00
Brad King 36fffb673a CMP0062: Remove support for OLD behavior 2025-01-22 10:40:54 -05:00
Brad King 10cfc8f538 Merge topic 'extern-domain'
e109307c43 Add support for foreign targets

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !10171
2025-01-22 09:30:49 -05:00
Vito Gamberini e109307c43 Add support for foreign targets 2025-01-21 15:26:40 -05:00
Brad King 888259c894 CMP0022: Remove support for OLD behavior 2025-01-18 09:51:45 -05:00
Brad King 5fd46699fc CMP0006: Remove support for OLD behavior 2025-01-17 09:28:35 -05:00