651 Commits
Author SHA1 Message Date
Marc Chevrier 386d1d874c Add support of custom rules
Fixes: #27383
2026-09-20 11:43:10 +02:00
Tom Osika 2a2012e913 cmake_language: Add PRINT_PROPERTIES operation
Print CMake entities' properties in human-readable form for debugging.

Issue: #27513
2026-08-10 17:41:05 -04:00
Tom Osika 72ae7352d5 get_property: Refactor logic to shared function 2026-08-10 17:29:13 -04:00
Vito Gamberini 00d8e23414 c++modules: use synthetic interface objects for import std
Fixes: #27999
2026-08-01 19:55:07 -04:00
Matthew Woehlke 4c6b437265 Export: Expand CPS default targets
CPS provides "default targets" as a user convenience which can be linked
by specifying only the package name. CMake implements this via a utility
`INTERFACE` target. However, because it is not namespaced, this is not a
valid requirement, which prevents exporting anything linking to this
target to CPS.

Work around this by introducing a new (internal) target property which
replaces a target with its link interface targets at export time.
2026-07-30 15:01:47 -04:00
Matthew Woehlke f1d7bedc4b TargetTypes: Improve use of imported target scope type
Move `ImportedTargetScope` to `cmTargetTypes.h`, enabling it to be used
without dragging in all of `cmMakefile.h`. Use this in more places
instead of `bool global`.
2026-07-01 14:44:11 -04:00
Matthew Woehlke a5a9ec9113 TargetTypes: Extract target-related types to dedicated header
Move some target related enumeration types from `cmStateTypes.h` to a
new header, as these really aren't "state" types. Also, make
`TargetType` a strongly-typed enumeration.
2026-07-01 14:44:11 -04:00
Brad King c615883926 Merge topic 'target-init'
01a80f7401 cmTarget: Move initialization to implementation class

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12198
2026-06-23 10:01:01 -04:00
Matthew Woehlke 01a80f7401 cmTarget: Move initialization to implementation class
Move a bunch of low-level member initialization from `cmTarget` to
`cmTargetInternals`, and in particular, to inline default member
initializers where possible. This gives us the advantages of the latter
with no overhead, as the compiler will elide generating DMI code for
those members that are unconditionally initialized in the ctor. (We were
getting the same optimization already for members that were initialized
twice in the `cmTarget` ctor, but without the benefits of DMIs.)

Mostly, this means we have assurance, via the DMIs, that POD members are
initialized without having to verify whether there is explicit code to
do so, while retaining not paying for double initialization.

Also, because it just gets moved into place, change `cmTarget`'s ctor to
take the target name by value.
2026-06-19 16:40:47 -04:00
Vito Gamberini 42d2d63235 c++modules: Copy props from BMI consumers more correctly
Fixes: #27891
2026-06-19 09:23:38 -04:00
Vito Gamberini bfba7f68af c++modules: Correctly calculate and apply usage effects
Usage effects describe the relationship between a provider and a
consumer of C++ module interface units. They encompass the flags and
features used to construct BMIs for those units. If the usage effects of
a provider and consumer match, then the provider's BMI may be reused
as-is. If they do not match, then a synthetic target describing the
interface units with the consumer's usage effects applied must be
created.

This commit makes three major changes to how usage effects are reified
in CMake. The first is simple, usage effect hashes now use compile
options and features as the input to their hash instead of the consumer
name. A simply warning flag filter is also applied, mostly to
demonstrate the mechanism. This is the "correct calculation" for usage
effects.

The second is more impactful, usage effects now entirely replace the
compile options of providers with those of consumers if unmatched.
Compile definitions, includes, and links remain unchanged. This is
necessary to ensure successful builds, but is a tricky semantic change.

The third is mostly source-facing, the discovery model for CxxModule
synthetic targets is no longer the global target namespace. Instead,
non-synthetic targets manage their synthetic derivatives. Every target
maintains a usage effect-keyed cache of synthetic targets. When
determining if a synthetic target is necessary, a given provider checks
for compatibility with itself, then for presence in the cache, and if
the cache misses a new synthetic target is created.

Fixes: #27597
2026-06-02 15:41:40 -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 dee8799d16 FileSet management: Introduce dedicated classes for generation
To manage the generation step, introduce cmGeneratorFileSet and
cmGeneratorFileSets classes.
These reorganizations of the code are done in preparation of the
implementation of SOURCES file set type as well as user's file set types.

Issues: #27550, #27383
2026-02-19 17:35:56 +01:00
Marc Chevrier c4c84ae0f7 cmFileSet: Enhance type management
Type management is now dynamic to ensure future support of user's types.
2026-02-19 17:03:45 +01:00
Brad King 43375ad8f8 Merge topic 'per-importer-bmi'
5c00749c5d cmCxxModuleUsageEffects: Collect and apply BMI compatibility requirements
5898c8d2e0 cxxmodules: Generate per-importer BMIs for native targets

Acked-by: Kitware Robot <kwrobot@kitware.com>
Reviewed-by: Vito Gamberini <vito.gamberini@kitware.com>
Reviewed-by: Ben Boeckel <ben.boeckel@kitware.com>
Merge-request: !11561
2026-02-11 12:03:15 -05:00
Daniel Tierney 5898c8d2e0 cxxmodules: Generate per-importer BMIs for native targets
C++ module importers may have specific usage requirements that differ from
other importers of the same module, potentially requiring separate Built Module
Interfaces (BMIs) for compatibility. CMake creates synthetic targets to
generate and link usage-specific BMIs. This change extends CMake's per-importer
BMI generation to native targets in addition to imported targets.
2026-02-09 14:16:17 -05:00
Ben Boeckel bc7fac6ad3 cmGeneratorTarget: detect colliding target directories
Some projects might get unlucky and have targets which collide in the
sha3-512 hash (truncated to 4) in a directory which also collides in the
same way (easily done by sharing it). Note such problems as potentially
colliding and offer potential remedies.

Also add a test which generates the error.

Closes: #27465
2026-02-05 12:33:56 -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
Brad King f49b0e6759 IWYU: Update for Debian 13 CI job
`include-what-you-use` diagnostics, in practice, are specific to
the environment's compiler and standard library.  Update includes
to satisfy IWYU for our CI job under Debian 13.  Some patterns:

* Types named in virtual `override` signatures no longer require
  includes since the overridden signature already names them.

* A function argument's type needs to be included even if its constructor
  is called only by implicit conversion.  For example, constructing a
  `std::function` from a lambda now requires `<functional>`.

* Some prior mysterious `<type_traits>` inclusions are no longer required.
2025-11-12 14:54:16 -05:00
Taylor Sasser d92b6c3e20 CPS: Add Symbolic Components
Adds support for "symbolic" components, which represent feature-level
capabilities of a package that do not correspond to actual build targets.
These are modeled as pseudo-targets, using the INTERFACE type as a base,
and can be queried via:

  get_target_property(... <tgt> "SYMBOLIC")

This enables consumers to declare requirements on optional features
(e.g., SSL support) even when they do not map to concrete targets.

Fixes: #27187
2025-10-02 10:46:02 -04:00
Matthew Woehlke a40896c0e4 cmTarget: Fix (new) configuration selection
The recently introduced CMP0200 improved configuration selection, but
did not correctly implement case-insensitivity. Add some additional case
smashing to ensure that matching is not case sensitive. Improve the test
which was passing due to falling back to the first listed configuration
rather than selecting a matching configuration.
2025-08-27 16:23:16 -04:00
Matthew Woehlke 702b7fda49 cmTarget: Improve code style
Rename `desired_config` argument of `GetMappedConfig[New]` to
`desiredConfig`, in accordance with our specified style preferences.
2025-08-27 16:18:40 -04:00
Brad King 46fc0232ae Merge topic 'fix-get-mapped-config'
05ae95c864 cmTarget: Overhaul GetMappedConfig

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !10995
2025-08-25 09:16:53 -04:00
Matthew Woehlke 05ae95c864 cmTarget: Overhaul GetMappedConfig
Create a brand new implementation of `cmTarget::GetMappedConfig` which
prioritized a target's `IMPORTED_CONFIGURATIONS` as the 'source of
truth' for what configurations are available. In particular, this means
that configuration selection when `IMPORTED_CONFIGURATIONS` is set does
not depend on the library type in any manner. The fallback logic also
uses a more consistent 'usability' criteria that should result in more
consistent configuration selection, particularly for `INTERFACE`
targets.

The previous implementation is retained as a separate method for users
requesting the OLD behavior.

Fixes: #27022
2025-08-20 14:44:05 -04:00
Daniel Pfeifer fa0e5906ff source: Pass cmStringRange by value 2025-07-30 11:55:34 -04:00
Matthew Woehlke cc42f1047b cmTarget: Add origin property
Add the concept of "origin" to cmTarget. For now, only CPS targets get a
unique origin, but this might be expanded in the future. This will allow
us to implement different behaviors based on a target's origin.

In particular, this has been requested as a means of addressing #26998
and #27022.
2025-07-22 11:20:10 -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 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 9f6011e307 CMP0049: Remove support for OLD behavior 2025-01-19 09:41:03 -05:00
Brad King ed99370f63 CMP0043: Remove support for OLD behavior
Note that per-source `COMPILE_DEFINITIONS_<CONFIG>` are not covered by
the policy, and are still supported.
2025-01-19 09:41:02 -05:00
Ben Boeckel c66821b22b cmGeneratorTarget: add the concept of a "family" name
With synthetic targets, a name which is the same between all synthetic
targets which share a base target is warranted.
2024-08-27 11:30:23 -04:00
Vitaly Stakhovsky 61ce6a6eeb Source: Delete unused prototypes 2024-07-29 10:45:02 -04:00
Aditya Vidyadhar Kamath d27fe9dfba AIX: Add option to archive shared libraries
Add option `CMAKE_AIX_SHARED_LIBRARY_ARCHIVE`.

There will no versions for the shared objects when this option is used.

Closes: #26033
2024-07-17 11:52:09 -04:00
Juan Ramos 197cb419d1 add_custom_command: Add CODEGEN support
By specifying CODEGEN as an argument to add_custom_command the
custom command will be added to a codegen build target.

The intent is to provide a convenient way for users to get
their generated files without having to build the whole project.

This can be helpful for code analysis tools which can be useful
for IDEs and CI.
2024-07-01 12:02:49 -04:00
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
Martin Duffy ec2ba29ac5 Ninja: Allow compilation before generation of dependencies' private sources
This requires knowing when a generated header is public, which we can
model using file sets.  Add policy CMP0154 to treat generated sources
as private by default in targets with file sets.  Generated public
headers can be specified in public file sets.

Fixes: #24959
Issue: #15555
2023-09-20 10:25:24 -04:00
Ben Boeckel 80d6544398 cxxmodules: generate synthetic targets as an initial pass
We need to be able to construct BMIs that will be usable from the client
modules for the target importing the module, so create BMI-only
compilation rules for `IMPORTED` targets to create these BMIs.
2023-08-17 14:42:53 -04:00
Craig Scott 84eae7aeda OPTIMIZE_DEPENDENCIES: Skip order-only deps for non-linking targets
Fixes: #21517
2023-08-10 09:17:56 +10:00
Brad King 241ee252ce IWYU: Update for Debian 12 CI job
`include-what-you-use` diagnostics, in practice, are specific to
the environment's compiler and standard library.  Update includes
to satisfy IWYU for our CI job under Debian 12.
2023-07-28 09:14:08 -04:00
Brad King f6435f799e Merge topic 'automoc-moc-options-test'
1f4b374d6e cmQtAutoGenInitializer: Reduce string copies
b6f66b445a cmQtAutoGenInitializer: Remove no-op calls
55d93bdabf cmQtAutoGenInitializer: Improve const correctness
feb56a666f cmTarget: Improve const correctness of AddUtility
5e513e562f Help: Add AUTOMOC_MOC_OPTIONS example
5380ad9d58 Tests: Add test for AUTOMOC_MOC_OPTIONS

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !8523
2023-06-01 11:19:19 -04:00
Orkun Tokdemir feb56a666f cmTarget: Improve const correctness of AddUtility 2023-05-31 13:01:29 -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
Marc Chevrier aa5fed5052 SetProperty: suppress raw pointer usage 2023-05-26 14:48:22 +02: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
Marc Chevrier fcbd723a50 Enhance support functions
* Avoid duplicate definiitions for IsExecutableWithExports, etc...
* Add helper IsApple()
2023-02-28 14:24:03 +01:00
Ben Boeckel c97de1047f cmMakefile: add support for a "synthesized" target
It is a normal target, but will end up copying its internals from
another target. Keep track of this state so that such copying can only
occur when intended.
2023-02-14 12:33:58 -05:00
Ben Boeckel 1d0426f642 cmTarget: make Visibility an enum class 2023-02-14 12:28:58 -05:00
Ben Boeckel 5b58695321 cmTarget: store visibility as an enum rather than bools
C++ modules are going to introduce a third concept of "synthesized"
targets, so update logic where needed to avoid assuming "not imported?
must be normal".

Also add an accessor method to perform queries against the visibility.
2023-02-14 12:23:15 -05:00