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

176 Commits

Author SHA1 Message Date
Brad King
f0b1ca4d70 CMP0052: Remove support for OLD behavior 2025-01-20 09:46:54 -05:00
Brad King
7193c2d23d CMP0041: Remove support for OLD behavior 2025-01-19 09:41:02 -05:00
Martin Duffy
c8997fc046 export: Allow depending on targets exported multiple times
Fixes: #26556
2025-01-07 15:27:14 -05:00
Martin Duffy
7b553a3b1d cmExportInstallFileGenerator: Report errors with IssueMessage 2024-12-30 10:59:44 -05:00
Martin Duffy
6195cefcfe export: Convert ExportInfo to a struct with meaningful field names 2024-12-30 10:59:33 -05:00
Brad King
659d8bd430 cmPolicies: Remove now-unused REQUIRED_IF_USED and REQUIRED_ALWAYS states 2024-11-13 11:43:07 -05:00
Vitaly Stakhovsky
58da4aa47d Source: Avoid comparing pointers to nullptr 2024-08-27 10:56:38 -04:00
Matthew Woehlke
8178fd43e9 export: Fix handling of import prefix
Fix some additional places in export generation logic that were still
hard-coding the import prefix. Change cmGeneratorExpression::Preprocess
to take the desired prefix as an argument. (This replaces taking a
boolean whether to resolve relative paths; if a non-empty prefix is
given, that is used to resolve relative paths, otherwise relative paths
are left alone.) This should ensure that import properties always spell
the prefix according to the format being generated.
2024-07-26 16:40:03 -04:00
Matthew Woehlke
e5b73b60e3 export: Generalize GenerateImportFileConfig
Move some logic that is specific to CMake-format exports from
GenerateImportFileConfig to an overload of GenerateImportConfig, so that
the former can be moved (back) to the generic base class. This will
allow it to also be used for Common Package Specification exports. To
facilitate this, also add a method to get the format-specific character
used to separate the export file base name from the config suffix, so
that the rest of the logic to determine the file name can be shared.
2024-07-25 18:33:35 -04:00
Matthew Woehlke
cd217739f7 export: Refactor obtaining export information
Refactor methods in the build and install export file generators to have
the same, simplified API. Expose the resulting method as an abstract
method on the base class, so that it can be called from mode-agnostic
generators. While we're at it, refactor cmExportInstallFileGenerator's
version to use std::any_of.
2024-07-25 18:33:35 -04:00
Matthew Woehlke
ff24058e46 export: Use std::all_of to collect exports
Rewrite cmExport{Build,Install}FileGenerator::CollectExports to use
std::all_of as recommended by clang-tidy.
2024-07-23 12:13:39 -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
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
Brad King
be111897b3 Merge topic 'export-name-safe-name'
142a85f9c1 cxxmodules: use filesystem-safe export names in filenames
4452d41488 cmGeneratorTarget: add method to get a filesystem-safe export name

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !9474
2024-05-01 09:29:57 -04:00
Ben Boeckel
142a85f9c1 cxxmodules: use filesystem-safe export names in filenames
Also add tests.

Fixes: #25828
2024-04-30 09:05:16 -04: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
2837f592ab cmExportFileGenerator: Add function to set required CMake version 2023-11-13 11:07:52 -05: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
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
d4144b9c0a strings: use emplace_back with cmStrCat arguments 2023-07-27 20:15:51 -04:00
Brad King
4995017c26 Merge topic 'export-file-set-absolute-cmake-install-includedir'
70f36de1e5 File set: Allow absolute CMAKE_INSTALL_INCLUDEDIR

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !8577
2023-06-23 11:00:02 -04:00
Marc Chevrier
45f17e5a85 cmList: Add container conversion to string 2023-06-22 15:44:17 +02:00
Kyle Edwards
70f36de1e5 File set: Allow absolute CMAKE_INSTALL_INCLUDEDIR
When install(TARGETS) and install(EXPORT) were called with file sets
and an absolute CMAKE_INSTALL_INCLUDEDIR, "${_IMPORT_PREFIX}/" was
still being prepended to the base directory and files, resulting in
incorrect paths. Don't prepend this when absolute paths are used.

Fixes: #25010
2023-06-20 11:39:11 -04:00
Ben Boeckel
6ff5cdc533 cxxmodules: remove support for CXX_MODULE_HEADER_UNITS filesets
There's no backing implementation for header units anyways, so just
remove it for now.
2023-05-31 10:57:11 -04:00
Tyler
f2a699261b cxxmodules: Do not expect collator install scripts with no CXX_MODULES
Calling `install(EXPORT)` with the `CXX_MODULES_DIRECTORY` parameter
leads to installation rules being generated which `include()` CMake
scripts that set the `IMPORTED_CXX_MODULES_[CONFIG]` target property for
relevant targets.  However, these scripts don't get generated for
targets in an export set which don't have any C++20 modules.  When the
installation rules attempt to `include()` the missing scripts, the
install fails.

Co-authored-by: Brad King <brad.king@kitware.com>
2023-05-23 15:01:32 -04:00
Orkun Tokdemir
c5c3aff1f5
Autogen: Add INTERFACE_AUTOMOC_MACRO_NAMES target property
Add this target property to specify macro names that propagate to
dependents as `AUTOMOC_MACRO_NAMES`.  The dependents will automatically
generate MOC files for source files that contain the inherited macro
names.

Co-Authored-By: Craig Scott <craig.scott@crascit.com>
Fixes: #19679
2023-04-09 20:51:15 +10: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
Kyle Edwards
09d7f947d6 cmGeneratorExpression: Require cmake instance 2022-11-11 12:29:41 -05:00
Harry Mallon
d26c520f4b export: Fix IMPORTED_LOCATION of iOS flat app bundles
iOS/tvOS app bundles are flat and do not include the `Contents/MacOS/`
layers, so they should not be in the `IMPORTED_LOCATION`.  Use the same
logic that commit 34f5ef564a (iOS: Fix App Bundle layout, 2015-12-10,
v3.5.0-rc1~129^2~1) added for the installation layout.

Fixes: #23963
2022-09-14 14:49:05 -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
Ben Boeckel
386465bf83 cmTarget: add support for C++ module fileset types
C++ modules have two variants which are of importance to CMake:

  - `CXX_MODULES`: interface modules (those using `export module M;`,
    `export module M:part;`, or `module M:internal_part;`)
  - `CXX_MODULE_HEADER_UNITS`: importable header units

Creating C++ modules or partitions are *not* supported in any other
source listing. This is because the source files must be installed (so
their scope matters), but not part of usage requirements (what it means
for a module source to be injected into a consumer is not clear at this
moment). Due to the way `FILE_SET` works with scopes, they are a perfect
fit as long as `INTERFACE` is not allowed (which it is not).
2022-06-16 10:28:34 -04:00
Ben Boeckel
4085128586 generated-scripts: use CMAKE_CURRENT_LIST_DIR where possible 2022-04-20 15:36:21 -04:00
Ben Boeckel
c2194176db generated-scripts: unset used variables 2022-04-20 15:36:20 -04:00
Ben Boeckel
233997a914 generated-scripts: use foreach(IN LISTS) 2022-04-20 15:34:28 -04:00
Ben Boeckel
2ec44be41e generated-scripts: quote variable expansions 2022-04-20 15:34:06 -04:00
Ben Boeckel
59cc92085e generated-cmake: use _cmake_ prefixes for local variables
This avoids stomping on any user variables.
2022-04-20 15:33:06 -04:00
Brad King
8c65b7042e cmExportFileGenerator: Simplify collection of targets missing from export set
Store the list of missing target names in a member instead of threading
an explicit reference to it through the call stack.
2022-04-11 13:40:13 -04:00
Brad King
069d836dab Merge topic 'restore-target-export-includes'
83d79636bf install(TARGETS): Restore per-export INCLUDES DESTINATION

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !6969
2022-02-10 09:07:35 -05:00
Eugene Shalygin
83d79636bf install(TARGETS): Restore per-export INCLUDES DESTINATION
In commit 55e4753bbb (Refactor cmTargetExport removing
InterfaceIncludeDirecories, 2021-07-20, v3.22.0-rc1~337^2~1) the storage
of `INCLUDES DESTINATION` was moved into each target.  However, a target
may be installed in multiple exports, and their `INCLUDES DESTINATION`
should not be mixed.

Convert the IncludeDirectoriesEntries vector to a map and modify access
function to store the directories lists with respect to cmExportTarget
object. This fixes error when the same target is exported more than once
via different exports and each for consequent export its include
directories list grows. Add a test for this case.

Fixes: #23183
2022-02-09 13:31:26 -05:00
Kyle Edwards
2a78d47b16 install(EXPORT): Install file sets 2021-10-27 15:17:23 -04:00
Marc Chevrier
cc56dc7468 Rename cmProp in cmValue 2021-09-21 17:14:04 +02:00
Marc Chevrier
e5cd39ca80 cmProp: refactoring: transform alias in class
To handle safely the values used by CMake variables and properties,
introduce the class cmProp as a replacement from the simple pointer
to std::string instance.
2021-08-08 16:19:08 +02:00
Eugene Shalygin
e8e19ed8f2 Refactor export file generator inteface
Replace cmTargetExport with const cmGeneratorTarget to allow recursive
processing of exported targets and their link dependencies.
2021-07-22 13:08:58 +02:00
Daan De Meyer
51acae534a install(EXPORT): Set copy-if-different on install export config files
Avoid reinstalling the per-config export install files if the
contents didn't change after a configure.
2021-01-19 09:59:19 -05:00
Deniz Bahadir
38bcb5c0a3 export: Do not fail generation for separate namelink only case
Update the change from commit 64690f6df0 (export: Do not fail generation
for namelink-only case, 2020-10-09, v3.19.0-rc1~7^2) to also handle
separate namelink-only and namelink-skip calls.

Fixes: #21529
2020-12-01 07:35:17 -05:00
Kyle Edwards
3c85f11fed INSTALL_NAME_DIR: Add support for generator expressions 2019-11-04 12:01:05 -05:00