1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-05-10 15:12:19 +08:00

293 Commits

Author SHA1 Message Date
Alex Turbov
bc8621d999
Fix: A lot of typos in code found by typos
Yet another great code spellchecker: https://github.com/crate-ci/typos/

(Will be added later as a `pre-commit` hook)
2025-01-12 18:49:34 +04:00
Matthew Woehlke
3d52d70b84 export: Add initial CPS support
Add initial support for exporting (install only, for now) Common Package
Specification (https://cps-org.github.io/cps/) format package
descriptions. This has some limitations, such as not supporting
generator expressions (as these cannot be portably exported), and only
partially supporting transitive dependencies, but should be usable for
at least some simple cases. (Actually, $<LINK_ONLY> is theoretically
supportable, but is not yet implemented.)

This still needs tests; these will be added in the next commit. Other
potential improvements include support for language-specific compile
definitions and inferring some package properties from project
properties. Additionally, there is no module support yet; this is partly
pending on having a tool agnostic format for providing the necessary
information.
2024-08-14 15:25:27 -04:00
Matthew Woehlke
20fa4ce8d8 export: Factor out CMake-specific export generation (2/2)
In order to support generation of Common Package Specifications, the
mechanisms CMake uses to export package information need to be made more
abstract. The prior commits began this refactoring; this continues by
(actually) restructuring the classes used to generate the actual export files.
To minimize churn, this introduces virtual base classes and
diamond inheritance in order to separate logic which is format-agnostic
but depends on the export mode (build-tree versus install-tree) from
logic which is format-specific but mode-agnostic.

This could probably be refactored further to use helper classes instead,
and a future commit may do that, however an initial attempt to do that
was proving even more invasive, such that this approach was deemed more
manageable.

While we're at it, add 'const' in more places where possible.
2024-07-23 12:13:39 -04:00
Matthew Woehlke
6c66340a64 export: Fix const placement
Use clang-format to fix placement of const qualifiers to be consistently
right of the typename. The inconsistency was getting annoying,
especially as the following refactor changes a lot of methods and
sometimes adds const. (Being inconsistent within a file is not ideal,
but in some cases there was inconsistency within single lines!)
2024-07-18 12:08:43 -04:00
Matthew Woehlke
a6cc595772 export: Factor out CMake-specific export generation (1/2)
In order to support generation of Common Package Specifications, the
mechanisms CMake uses to export package information need to be made more
abstract. As a first step toward this, refactor cmInstallExportGenerator
so that logic specific to config.cmake and Android .mk lives in separate
subclasses.

While we're at it, clean up the code style a bit and try to use moves a
bit more consistently.

This is step 1 of 2. The next step will refactor the individual file
generators along similar lines, which will also involve creating
additional classes for format-agnostic logic that is shared between
build-tree and install-tree variants.
2024-07-18 12:08:43 -04:00
Matthew Woehlke
0352376e44 export: Immediately report actual version required
Slightly tweak the logic that tests if a user can consume exported
targets to immediately report the actual version required, rather than
potentially giving the consumer false hope by reporting that 2.8 is
required, only to immediately run another check that requires a more
recent CMake version. (Note that the two-level check is presumably
needed because CMake < 2.8 wouldn't understand VERSION_LESS.)
2024-07-18 12:08:42 -04:00
Brad King
d34b428071 Merge topic 'custom-transitive-properties'
7a77a6c642 Restore support for exporting INTERFACE with missing dependencies

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Acked-by: Robert Maynard <robertjmaynard@gmail.com>
Merge-request: !9656
2024-07-16 10:32:15 -04:00
Brad King
7a77a6c642 Restore support for exporting INTERFACE with missing dependencies
Since commit c16acd35b3 (GenEx: Add support for custom transitive link
properties, 2024-05-09, v3.30.0-rc1~82^2) evaluation of
`TRANSITIVE_LINK_PROPERTIES` by `install(EXPORT)` enables discovery of
missing dependencies on INTERFACE libraries that we did not previously
diagnose.  This regressed existing projects that relied on such
non-diagnosis.  Although commit 2fc9e482a9 (Evaluation of
TRANSITIVE_LINK_PROPERTIES isn't considered a usage, 2024-07-05) fixed
this, it also made a significant change to the `UseTo` infrastructure
that may have other subtle effects.  Replace the fix with an approach
that explicitly models suppression of the relevant diagnostics.

Fixes: #26108
2024-07-15 14:08:10 -04:00
Brad King
ed376e470e export: Increase maximum policy version in exported files to 3.29
The files generated by `install(EXPORT)`, `export()`, and
`install_jar_exports()` commands are known to work with policies
as of CMake 3.29, so enable them in sufficiently new CMake versions.
2024-06-05 13:23:38 -04:00
Brad King
c16acd35b3 GenEx: Add support for custom transitive link properties
Teach the `$<TARGET_PROPERTY:...>` generator expression to check for a
new `TRANSITIVE_LINK_PROPERTIES` property in the target's link
closure to enable transitive evaluation of named properties through
the link closure, including entries guarded by `$<LINK_ONLY:...>`.

Fixes: #20416
2024-05-21 09:22:52 -04:00
Brad King
b9ee79b8a1 GenEx: Add support for custom transitive compile properties
Teach the `$<TARGET_PROPERTY:...>` generator expression to check for a
new `TRANSITIVE_COMPILE_PROPERTIES` property in the target's link
closure to enable transitive evaluation of named properties through
the link closure, excluding entries guarded by `$<LINK_ONLY:...>`.

Issue: #20416
2024-05-21 09:22:51 -04:00
Ben Boeckel
7146cf9248 cmTarget: support the CXX_MODULE_STD property 2024-04-11 10:19:44 -04:00
Ben Boeckel
3273b18972 cmExportFileGenerator: support always exporting properties 2024-04-11 10:19:43 -04:00
Brad King
47562c0547 Merge topic 'export-find_dependency-calls'
b1c4806914 install(EXPORT): Drop REQUIRED from exported find_dependency calls

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !9329
2024-03-12 08:43:25 -04:00
Brad King
b1c4806914 install(EXPORT): Drop REQUIRED from exported find_dependency calls
In commit c6e6861e63 (install(EXPORT): Export find_dependency() calls,
2023-11-07, v3.29.0-rc1~439^2~1) we made the calls `REQUIRED`.  However,
a dependency is only required if the dependent package is required.
`find_dependency` already forwards the `REQUIRED` mark, and also already
marks the dependent package as not found if the dependency is missing.

Fixes: #25756
2024-03-11 12:07:32 -04:00
Brad King
9c69bd8d42 Merge topic 'cxxmodules-no-export-basedirs-as-include-paths'
65bd837786 Merge branch 'backport-3.28-cxxmodules-no-export-basedirs-as-include-paths'
028f3134e5 cmExportFileGenerator: only export include paths for HEADERS file sets

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !9295
2024-02-29 08:02:29 -05:00
Brad King
65bd837786 Merge branch 'backport-3.28-cxxmodules-no-export-basedirs-as-include-paths' 2024-02-28 09:20:15 -05:00
Ben Boeckel
028f3134e5 cmExportFileGenerator: only export include paths for HEADERS file sets 2024-02-28 05:26:10 -05:00
Brad King
07c219da13 Merge topic 'cxxmodules-transitive-modules-usage'
ec348ee4b9 cmGeneratorTarget: discover synthetic targets recursively
67466ddf65 cmExportFileGenerator: export link libraries as-is
a2e3e61a31 Tests/CXXModules: test transitive modules usage

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !9273
2024-02-21 13:34:36 -05:00
Brad King
c66396699b Merge topic 'cxxmodules-transitive-modules-usage' into release-3.29
ec348ee4b9 cmGeneratorTarget: discover synthetic targets recursively
67466ddf65 cmExportFileGenerator: export link libraries as-is
a2e3e61a31 Tests/CXXModules: test transitive modules usage

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !9273
2024-02-21 13:34:34 -05:00
Ben Boeckel
67466ddf65 cmExportFileGenerator: export link libraries as-is
This allows for transitive modules to work because
`$<COMPILE_ONLY>`-wrapped dependencies do not end up in the
`linked-target-dirs` collator property. Test suite exported property
tests updated to account for the change.
2024-02-20 10:53:31 -05:00
Brad King
c432365e10 export: Increase maximum policy version in exported files to 3.28
The files generated by `install(EXPORT)`, `export()`, and
`install_jar_exports()` commands are known to work with policies
as of CMake 3.28, so enable them in sufficiently new CMake versions.
2024-02-06 17:07:16 -05:00
Brad King
4cd153afe3 Merge branch 'backport-cxxmodules-export-file-collisions' 2024-01-18 17:45:07 -05:00
Ben Boeckel
d791f3a180 cxxmodules: make export trampoline script files unique
Include the name of the `EXPORT` in the filename when generating export
information for C++ modules. This allows the same directory to be used
for multiple sets of C++ module-using targets.

For `export(TARGETS)` uses, generate a name based on the hash of the
concatenation of the target names involved with the `export()` call.

Fixes: #25609
2024-01-18 17:40:44 -05:00
Kyle Edwards
256bb0cc40 install(EXPORT): Add ability to point to .xcframework file
Issue: #25262
2023-11-15 09:10:58 -05:00
Kyle Edwards
c6e6861e63 install(EXPORT): Export find_dependency() calls
Issue: #20511
Co-Authored-by: Brad King <brad.king@kitware.com>
Co-Authored-by: Robert Maynard <rmaynard@nvidia.com>
2023-11-13 11:07:52 -05:00
Kyle Edwards
2837f592ab cmExportFileGenerator: Add function to set required CMake version 2023-11-13 11:07:52 -05:00
Brad King
46dc523d7e Merge topic 'cxxmodules-export-fileset-info'
0f36156740 cxxmodules: include `INCLUDES DESTINATION` directories

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !8886
2023-10-17 09:50:07 -04:00
Ben Boeckel
0f36156740 cxxmodules: include INCLUDES DESTINATION directories
These paths are added outside the normal property management mechanisms.
Shuttle the value to the C++ module export as needed.

Fixes: #25289
2023-10-16 13:57:54 -04:00
Brad King
c5f1af1ffe export: Increase maximum policy version in exported files to 3.27
The files generatd by `install(EXPORT)` and `export()` commands
are known to work with policies as of CMake 3.27, so enable them
in sufficiently new CMake versions.
2023-10-03 17:21:47 -04:00
Ben Boeckel
b3d1bbbbcc cmExportFileGenerator: relocate include directories for C++ modules
Include directories are paths that need munged on install to support the
installation prefix.

Fixes: #25275
2023-09-26 14:32:46 -04:00
Ben Boeckel
249cd3efad cmExportFileGenerator: export private compile info for C++ modules
When consuming exported targets which contain C++ modules, the consuming
project must be able to recompile BMI files using the original target's
flags. This is because a module source may use some private target usage
requirement but not want to propagate it to consumers. To facilitate
this, export the private information as necessary for consumers to be
able to perform the BMI compilations.
2023-08-17 14:42:53 -04:00
Ben Boeckel
e166bbef7b cmComputeLinkInformation: prepare Item consumers for OBJECT libraries
After b665966933 (cmComputeLinkInformation: track `OBJECT` library
dependencies, 2023-07-22), introduced in !8645 as a fix for #25112,
`OBJECT` libraries were tracked in a separate member to reduce the risk
of further regressions. This commit prepares consumers to handle
`OBJECT` libraries once they start appearing as link items.
2023-08-01 10:06:02 -04:00
Marc Chevrier
45f17e5a85 cmList: Add container conversion to string 2023-06-22 15:44:17 +02:00
Brad King
ee80960f78 export: Increase maximum policy version in exported files to 3.26
The files generatd by `install(EXPORT)` and `export()` commands
are known to work with policies as of CMake 3.26, so enable them
in sufficiently new CMake versions.
2023-06-07 14:32:03 -04:00
Brad King
5924630e6d Merge topic 'compile-only-genex'
c42630ee62 cmGeneratorExpressionNode: implement `COMPILE_ONLY` genex
0fb923c460 cmGeneratorExpressionNode: implement `COMPILE_ONLY` genex

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !8411
2023-05-05 12:42:23 -04:00
Marc Chevrier
e08ba229ee CMake code rely on cmList class for CMake lists management (part. 1) 2023-04-24 10:41:10 +02:00
Ben Boeckel
0fb923c460 cmGeneratorExpressionNode: implement COMPILE_ONLY genex
This generator expression is the inverse of `LINK_ONLY` and only coveys
usage requirements for the purposes of compilation. Its intended use is
to avoid needing to export targets that do not have link usage
requirements (e.g., header-only libraries) when used by another target.

It will also be used to represent private usage requirements on exported
C++ module-containing targets in the future.

Eventually there should be logic to collapse nesting of
`$<COMPILE_ONLY>` and `$<LINK_ONLY>` when generating instances of
either. A TODO is left in the code for this case.

See: #15415
2023-04-12 10:43:48 -04:00
Kyle Edwards
42e5be8cef install(EXPORT): Fall back to set_property(APPEND) for FILE_SET
FILE_SET was introduced in CMake 3.23, so install(EXPORT) puts it
behind a version gate. However, this results in the include directories
not being picked up by older versions of CMake. Fall back to
set_property(APPEND) for versions of CMake older than 3.23.

Fixes: #24787
2023-04-12 09:33:24 -04:00
Marc Chevrier
ede33f30cf Apple: Handle generation and comsuption of text-based stubs (.tbd files)
Fixes: #24123
2023-03-01 12:23:28 +01:00
Brad King
4feea27761 export: Increase maximum policy version in exported files to 3.25
The files generatd by `install(EXPORT)` and `export()` commands
are known to work with policies as of CMake 3.25, so enable them
in sufficiently new CMake versions.
2023-02-01 17:01:38 -05:00
Kyle Edwards
830eed374d CMake: fix sizeof string literal violations 2022-11-18 09:37:58 -05:00
Kyle Edwards
09d7f947d6 cmGeneratorExpression: Require cmake instance 2022-11-11 12:29:41 -05:00
Brad King
6bd18eed8e export: Increase maximum policy version in exported files to 3.24
The files generatd by `install(EXPORT)` and `export()` commands
are known to work with policies as of CMake 3.24, so enable them
in sufficiently new CMake versions.
2022-10-12 12:41:25 -04:00
Brad King
ea73a8ea38 Merge topic 'export-no-shdeps'
0ebff0d61a export: Restore exclusion of private shared library dependencies from checks

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7557
2022-08-16 12:42:21 -04:00
Brad King
0ebff0d61a export: Restore exclusion of private shared library dependencies from checks
Refactoring in commit 8c65b7042e (cmExportFileGenerator: Simplify
collection of targets missing from export set, 2022-04-11,
v3.24.0-rc1~281^2) accidentally dropped the behavior change from
commit 0ad2a1c181 (Export: Never treat private link libraries as
public package dependencies., 2013-09-24, v3.0.0-rc1~559^2).
Restore the behavior and add a test.

Fixes: #23838
2022-08-15 10:40:03 -04:00
Ben Boeckel
3526b8c123 cmExport*FileGenerator: support exporting C++ module properties
C++ module properties will be generated at build time, so generate code
that includes the files actually responsible for the information.
2022-07-06 10:15:23 -04:00
Da Quexian
9680b3b279 Add EXPORT_NO_SYSTEM target property, deprecate IMPORTED_NO_SYSTEM
Issue: #18040

Signed-off-by: Da Quexian <daquexian566@gmail.com>
2022-06-17 22:38:07 +08:00
Brad King
25b1312a6d export: Increase maximum policy version in exported files to 3.23
The files generatd by `install(EXPORT)` and `export()` commands
are known to work with policies as of CMake 3.23, so enable them
in sufficiently new CMake versions.
2022-06-14 15:05:09 -04:00
Ben Boeckel
a1a7f62918 generated-scripts: improve prose messages with CMake lists
Instead of printing a CMake list, make it an English-style list. This
also allows the line-break algorithm to make these messages much more
readable.
2022-04-20 15:36:21 -04:00