492 Commits
Author SHA1 Message Date
Vito Gamberini ab1bd6f6c6 c++modules: Remove CXX_MODULE_STD and CMAKE_CXX_COMPILER_IMPORT_STD
Fixes: #27966, #27992, #28000
2026-08-03 10:05:34 -04:00
Vito Gamberini 00d8e23414 c++modules: use synthetic interface objects for import std
Fixes: #27999
2026-08-01 19:55:07 -04:00
Brad King 5c1f5210c9 Merge topic 'fix-imported-bmi-config'
82683ae8b0 c++modules: discover synth targets for all configs

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Reviewed-by: Ben Boeckel <ben.boeckel@kitware.com>
Merge-request: !12286
2026-07-17 10:52:58 -04:00
Vito Gamberini 82683ae8b0 c++modules: discover synth targets for all configs
Fixes: #26312
2026-07-16 12:10:02 -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
Vito Gamberini 42d2d63235 c++modules: Copy props from BMI consumers more correctly
Fixes: #27891
2026-06-19 09:23:38 -04:00
Vito Gamberini 6d3e9d8220 c++modules: single import std target 2026-06-18 15:20:54 -04:00
Brad King 5636aa7740 Merge topic 'cxx-module-usage-effects'
2049419196 c++modules: document BMI compatibility changes
bfba7f68af c++modules: Correctly calculate and apply usage effects

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !12116
2026-06-03 10:01:51 -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
Baudouin Feildel 8154a4bc5c Rust: Add support for compiling Rust with Makefile generator 2026-05-25 22:18:25 +02:00
Evan Wilde 94faee3099 Swift: Add option to pass package name to swiftc invocation
Add a `Swift_PACKAGE_NAME` target property to specify the package name.

Fixes: #26886
2026-04-28 15:24:05 -04:00
Evan Wilde 635f71737c Swift: Factor out Swift-specific target flags
Swift started the trend of piling language-specific target flags in
`cmLocalGenerator::AddLanguageFlags`. Other languages have added their
own under language-specific `Add<Lang>TargetFlags`.
I'm refactoring where Swift piles on its language-specific target flags
to match the pattern other languages are using.
2026-04-27 10:45:14 -07:00
Marc Chevrier 3e2765b354 c++modules: create synthetic targets only when needed
When the target has only private c++ modules, do not create a synthetic
target.
2026-04-06 16:52:18 -04:00
Baudouin Feildel 313769e766 Rust: Add support for Rust editions with Rust_EDITION target property 2026-03-26 23:15:58 +01:00
Baudouin Feildel 881faf67e5 Rust: Switch to building .rs files to .rlib instead of native object files
Each Rust source file given to a target is considered a separate crate
root. There's a concept of a "main crate root", which is the `.rs` file
that is given to the final linker phase in CMake. Other Rust source file
in a target are built as rlib separately.

The project can still build `.rs` files into object files by setting the
Rust_EMIT property on the desired source file.
2026-03-20 09:42: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
Brad King 647b075be0 Merge topic 'genex-TARGET_OBJECTS-SOURCE_FILES'
987e0af366 GenEx: Add `$<TARGET_OBJECTS:...>` option to filter on source files

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !11782
2026-03-11 13:17:00 -04:00
Kyle Edwards 987e0af366 GenEx: Add $<TARGET_OBJECTS:...> option to filter on source files
Fixes: #27675
2026-03-10 10:51:43 -04:00
Mickaël Germain f974ef0f75 cmGeneratorTarget: Refactor header set verification for C and CXX
Split GenerateHeaderSetVerificationFile into three focused helpers:
- ResolveHeaderLanguage: determines the language for a header; returns
  early for headers with an explicit LANGUAGE property (validated
  against the supported set), and otherwise computes and caches the
  target's default language using a lattice join (CXX > C) over target
  sources and globally enabled languages.
- GenerateStubForLanguage: maps a resolved language to a stub file
  extension (.c or .cxx) and creates the verification source.
- GenerateHeaderSetVerificationFile: orchestrates the above, moving
  the SKIP_LINTING guard here and switching the return type to
  cm::optional<std::string> so callers can distinguish "no file" from
  an empty path.

No behavior change; only C and CXX are supported at this point.
2026-03-10 09:21:52 -04: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 b45dcfd306 Extract cmTargetPropertyEntry class from cmGeneratorTarget class.
To enable to reuse this class in different classes.
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
John Franklin Rickard 62a4099fd2 cmGeneratorTarget: Cache GetAllConfigCompileLanguages 2026-02-06 12:27:13 -05:00
Craig Scott 909b54023a File sets: Specify verify file set target names in one place 2026-01-16 18:10:14 +11:00
Brad King 8832f78dd6 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:35 -05:00
Craig Scott f38f325e08 fileAPI: Add direct dependencies to target codemodel files
This adds the following new arrays, which together capture all direct
dependencies and interface dependencies of a target:

- linkLibraries
- interfaceLinkLibraries
- compileDependencies
- interfaceCompileDependencies
- objectDependencies
- orderDependencies

Fixes: #21995, #25213
2025-10-07 10:44:28 -04:00
Craig Scott 1b764b6816 cmLinkItem: Remove redundant cmLinkImplItem class
The cmLinkImplItem class used to contain some additional members
to support the CMP0027 policy. Since the CMP0027 policy and those
associated members were removed, the cmLinkImplItem class has been
a plain wrapper around cmLinkItem with no additional members.
It is no longer needed and cmLinkItem can be used directly wherever
cmLinkImplItem was used previously.
2025-10-07 10:44:28 -04:00
AJIOB 6874efb592 MSVC: Always define a character set
When targeting the MSVC ABI, define `_MBCS` by default if the project
does not define `_SBCS` or `_UNICODE`.  Visual Studio has long defined
one of the three character set macros automatically.  For consistency,
define it when compiling for the MSVC ABI with other generators.
Add policy CMP0204 for compatibility.

Fixes: #27275
2025-10-07 09:29:32 -04:00
Brad King 0d01bc72b8 Merge topic 'cps-symbolic-info'
62a1d3e7f1 FileAPI: Add symbolic property to targets
d92b6c3e20 CPS: Add Symbolic Components
03284e018f Help: Simplify file-api version information for "abstract" field

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !11132
2025-10-03 11:24:50 -04: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
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
AJIOB 83bbde5449 MSVC: Define _WINDLL consistently for shared libraries
Visual Studio defines this automatically for `.dll` targets.
For consistency, define it when compiling for the MSVC ABI
with other generators.  Add policy CMP0203 for compatibility.

Fixes: #27253
2025-09-29 18:26:44 -04:00
Brad King 26413a3e3d Merge topic 'file-GENERATE-CMP0189'
deb7b4b658 file(GENERATE): Record CMP0189 at each call site
9b862e7013 cmGeneratorTarget: Pass genex evaluation context to IsTransitiveProperty

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !11234
2025-09-24 08:45:14 -04:00
Brad King 9b862e7013 cmGeneratorTarget: Pass genex evaluation context to IsTransitiveProperty 2025-09-23 10:57:22 -04:00
Brad King 2a14338676 Merge branch 'backport-genex-refactor' into genex-refactor 2025-09-21 20:22:24 -04:00
Brad King 4697f7122b GenEx: Rename cmGeneratorExpressionContext to cm::GenEx::Evaluation
It has grown to hold information about the evaluation itself,
not just the context in which the evaluation occurs.
2025-09-21 20:21:32 -04:00
Brad King 77570a1ac1 GenEx: Consolidate target property evaluation context arguments 2025-09-21 20:20:03 -04:00
Brad King e1035dc307 GenEx: Rename cmGeneratorExpressionContext to cm::GenEx::Evaluation
It has grown to hold information about the evaluation itself,
not just the context in which the evaluation occurs.
2025-09-21 18:58:55 -04:00
Ben Boeckel 388923818d cmGeneratorTarget: return the source file added
A few callsites uses this codepath to generate `cmSourceFile` instances;
allow them to access it.
2025-09-08 11:59:57 -04:00
Ben Boeckel c651b0e002 objects: implement installation naming strategies 2025-08-16 09:18:44 -04:00
Ben Boeckel 8180ecad9b autogen: support the SHORT intermediate dir strategy 2025-07-29 09:44:03 -04:00
Ben Boeckel c4bf198aed cmGeneratorTarget: add a query for whether to use short object names 2025-07-28 12:01:28 -04:00
Ben Boeckel d1393cc69e cmRulePlaceholderExpander: expand <TARGET_SUPPORT_DIR> placeholders 2025-07-28 12:01:27 -04:00
Ben Boeckel f78f592b78 pchreuse: defer target existence enforcement to generation time
Now that generation can work with any way the state gets to the way it
is, just do the target enforcement at generation time. This allows PCH
reuse targets to be declared before or after targets which use them.

Also update `cmLocalGenerator` to use the methods now that they reliably
provide values rather than parallel construction.
2025-07-22 12:42:57 -04:00
Ben Boeckel 1d701491a2 pchreuse: always ask the PCH reuse target for PDB information
The property settings set things up once, but nothing ensures that
post-reuse hookup that any property changes propagate. Instead, when
computing PDB information, if PCH reuse is enabled, just always use its
values.

Also drop enforcement at generate time of property value consistency as
it is now ignored when PCH reuse is in effect.

Additionally, if a target is PCH-reused, generate a PDB output directory
for it.

The `PchReuseFromIgnoreOwnProps` test failed previously because the
post-reuse link update of the consuming `PDB` properties are no longer
considered. The `PchReuseFromUseUpdatedProps` failed because the
post-reuse link did not update the copy of the properties added to
consuming reuse target properties.
2025-07-22 12:42:57 -04:00
Ben Boeckel 6e7da8aa95 cmGeneratorTarget: factor out reuse target computation 2025-07-22 12:42:57 -04:00
Ben Boeckel c95a8348ce cmLocalGenerator: add an override for CMakeFiles-using paths
Visual Studio doesn't use a `CMakeFiles` subdirectory for its support
directories. However, some codepaths expect to use paths which are
always under `CMakeFiles`. Add a mechanism to keep the path for such
files.
2025-05-24 15:28:50 +02:00
Peter Kokot 72e5ebcbd3 FindXCTest: Update documentation
- Module documentation synced with other similar find modules.
- Added examples section.
- Added note about Swift Testing framework, which supersedes the XCTest.
- Added note about the XCTEST target property and synced docs a bit.
- Used word "commands" instead of "macros" or "functions".
2025-04-28 00:12:14 +02:00
Giacomo Rombaut 15a1769bd8 GenEx: Add support for PDB_NAME and COMPILE_PDB_NAME
Closes: #26729
2025-03-11 10:28:12 -04:00