241 Commits
Author SHA1 Message Date
Marc Chevrier 386d1d874c Add support of custom rules
Fixes: #27383
2026-09-20 11:43:10 +02:00
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 6d3e9d8220 c++modules: single import std target 2026-06-18 15:20:54 -04:00
Vito Gamberini 55f60d918d c++modules: Remove remaining restrictions on config-sensitive module paths 2026-06-11 10:31:50 -04:00
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
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
Ben Boeckel 575c3dd990 builddb: support builds with empty configuration
Rotates the UUID to indicate changed behavior.

See: https://discourse.cmake.org/t/15654
2026-05-22 13:51:06 -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 92e0ca9046 Diagnostics: Show author message for all descendants
Tweak `cmMessenger` to also show the "warning is for project developers"
notice for all diagnostics that are descendants of the `CMD_AUTHOR`
category. When doing so, also show both command-line options which can
suppress the message.
2026-05-15 09:57:23 -04:00
Matthew Woehlke b0f9852990 Diagnostics: Update tests (automated)
Update expected test output to account for the new format of diagnostic
messages. These changes were applied entirely by `sed` using the
following commands:

  - `/Use -Wno-dev to suppress/s/-Wno-dev/-Wno-author/g`
  - `s/Warning [\\][(]dev[\\][)]/Warning \\(author\\)/g`
  - `s/CMake Deprecation Warning/CMake Warning \\(deprecated\\)/g`

This is not a complete fix, but covers a significant fraction of the
needed changes, and this commit is strictly automated changes.
2026-04-16 15:10:35 -04:00
Marc Chevrier df0a2aca6d FILE_SET: Add CXX_SCAN_FOR_MODULES property for per-file-set scanning control
This is more specific than both the target property and the
directory-wide source file property of the same name.
2026-04-03 09:29:29 -04:00
Marc Chevrier 5c5b68f44e FILE_SET: Add support for the SOURCES type
Fixes: #27550
2026-03-31 09:49:59 +02:00
Brad King eaecd6445b Merge topic 'import-std-experimental'
c1d58d3f3d Experimental: Restore `import std` gate
2e29354040 Experimental: Restore documentation link to CPS

Acked-by: Kitware Robot <kwrobot@kitware.com>
Reviewed-by: Ben Boeckel <ben.boeckel@kitware.com>
Merge-request: !11745
2026-02-27 08:28:52 -05:00
Brad King c1d58d3f3d Experimental: Restore import std gate
Several problems with this feature came up while testing 4.3.0-rc1.
These include both broken stdlib distributions and regressions in our
implementation of the feature since CMake 4.2.

Revert commit 70c1f0f43d (Experimental: Remove import std experimental
gate, 2026-02-04, v4.3.0-rc1~61^2) except for its incidental fixes.

Remove the 4.3 release notes related to `import std`.

Rotate the experimental gate's UUID.

Issue: #27426
Issue: #27597
Issue: #27626
Issue: #27635
2026-02-26 17:19:19 -05:00
Brad King 0d5069d5e8 Add deprecation warnings for policies CMP0155 and below
The OLD behaviors of all policies are deprecated, but only by
documentation.  Add an explicit deprecation diagnostic for policies
introduced in CMake 3.28 and below to encourage projects to port
away from setting policies to OLD.
2026-02-17 16:42:48 -05:00
Brad King 0c9759b11c Tests: Remove unnecessary UTF-8 sequences from .cmake sources 2026-02-08 16:16:20 -05:00
Vito Gamberini 70c1f0f43d Experimental: Remove import std experimental gate
Fixes: #27571
2026-02-07 09:03:43 -05:00
Vito Gamberini ce309f8885 cmDyndepCollation: Cxx module manifest format
Support the module manifest format added in !11422 as an output format
of dyndep collation for exports. This is necessary for CPS support of
modules, as CPS uses module manifests to describe C++20 modules.

Additionally, adds some CMake-vendor fields to the module manifest to
support compile-options and compile-features on module sources.
2026-01-22 00:59:43 -05:00
Vito Gamberini fa10dc6c22 Experimental/CXXModules: Implement EcoStd Module Metadata parser
Adds a parser and serializer for the EcoStd Module Metadata format

RFC: https://github.com/ecostd/rfcs/pull/3

This adapts the existing experimental support for import std; to use
the new parser. The CMAKE_CXX_STDLIB_MODULES_JSON is now the canonical
variable for controlling how CMake discovers the stdlib module metadata,
and is used directly by compiler detection.

Toolchains can still override the __CMAKE::CXX## targets if they wish,
either in conjunction with CMAKE_CXX_STDLIB_MODULE_JSON or not. It is
possible to disable automatic detection of
CMAKE_CXX_STDLIB_MODULE_JSON by setting it to the empty string.

When available, the CMAKE_CXX_STDLIB_MODULE_JSON will be used to create
all requested C++ stdlibs which do not already have targets.
2025-11-18 11:39:59 -05:00
Ben Boeckel 9a8700296c Tests/CXXModules: split out compilation tests
The test is getting fairly large and timing out more and more often.
Split out actual compilation tests.
2025-11-14 09:26:51 -05:00
Ben Boeckel 2d988b7ec8 Tests/CXXModules: remove unused file 2025-11-10 14:48:44 -05:00
Brad King b7ad081f1a Tests: Fix RunCMake.CXXModules compilation with Clang 21
Clang 21 now enforces placement of the module declaration:

    .../scan_properties/module.cxx:7:8: error: module
       declaration must occur at the start of the translation unit
2025-10-30 17:40:02 -04:00
AJIOB 5de7a09e77 Tests/RunCMake: Match dots more precisely, part 3 2025-10-20 14:45:24 -04:00
AJIOB 62b112ee25 Tests/RunCMake: Match CMakeLists.txt file name more precisely 2025-10-16 17:42:12 +03:00
AJIOB 06ccd15457 Tests/RunCMake: Match xxx.cmake file name more precisely 2025-10-16 17:42:12 +03:00
Hanna Rusakovich 638cf8f194 Tests/RunCMake: Match CMakeLists.txt file name more precisely 2025-10-15 09:39:01 -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
Ben Boeckel 2f101b2c8c Tests/CXXModules: support testing with custom stdlib json locations 2025-09-11 18:03:05 -04:00
Ben Boeckel 050f891d81 Tests: choose an explicit FULL strategy in tests expecting it
Since it can be set in the environment when running the test suite,
guard tests which are sensitive to intermediate directory strategy
changes with explicit settings.
2025-07-29 08:06:30 -04:00
Ben Boeckel 52e2785018 experimental/CXXModules: recycle the UUID
Now that `clang -stdlib=libstdc++` is supported.
2025-04-30 13:48:13 +02:00
Ben Boeckel 12d73c9f78 cmExperimental: recycle build database uuid 2025-03-03 22:03:27 +01:00
Ben Boeckel 8a773168fd Tests/CXXModules: help diagnose build database errors
In tests that compare multiple files, knowing which file(s) errors come
from is difficult. Log the actual filepaths when this occurs to help
debugging.
2025-03-03 22:02:40 +01:00
Ben Boeckel 7ca4ac8e13 cmBuildDatabase: fix language comparison for visibility
Only C++ sources need checked for `CXX_MODULES` file set types, not the
other way around.
2025-03-03 22:00:23 +01:00
Brad King c283aafe62 CMP0057: Remove support for OLD behavior 2025-01-22 10:40:53 -05:00
Brad King 6c39558077 Merge topic 'test-ninja-1.13'
24f0848836 Tests: Update expected results for ninja post-1.12 development

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10182
2025-01-17 08:12:00 -05:00
Brad King 24f0848836 Tests: Update expected results for ninja post-1.12 development
Account for changes to upstream ninja:

* commit `5d93f2da28` (Add exit code to the failed target, 2024-12-03)
* commit `311bf93416` (Propagate jobs' exit codes to the ninja's exit code,
                       2024-12-03)
2025-01-16 08:14:25 -05:00
Brad King 92f6b92155 Merge topic 'duplicate-source-behavior'
3e15419bd4 target_sources: Restore toleration of duplicate CXX_MODULES sources
5cfb8ae790 Tests/CXXModules: add a test with duplicate sources

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !10155
2025-01-10 09:28:16 -05:00
Ben Boeckel 3e15419bd4 target_sources: Restore toleration of duplicate CXX_MODULES sources
In commit 9c0491a3e4 (cmDyndepCollation: write out scanned source
information too, 2024-03-25) via !9708, the `sf_map` gained a new job of
also being used to track non-file set sources which could import
modules. This was implemented by removing processed `FILE_SET TYPE
CXX_MODULES` sources from the map and working with the sources
remaining. When a `FILE_SET TYPE CXX_MODULES` source appeared multiple
times, this would then erroneously complain that it "was not scheduled
for compilation". Use a set of source paths to track sources that have
already been processed. If duplicates are found, trigger an author
warning and skip the duplicate file.

Fixes: #26549
2025-01-09 22:36:06 +01:00
Ben Boeckel 5cfb8ae790 Tests/CXXModules: add a test with duplicate sources
See: #26549
2025-01-09 22:36:06 +01:00
Ben Boeckel 469175c2e6 Experimental: recycle the import std UUID
Now that GCC is supported, update the feature UUID.
2025-01-08 16:32:14 -05:00
Ben Boeckel a980dab9b1 gcc: support import std 2025-01-08 16:32:14 -05:00
Ben Boeckel 2791b7564b Tests/RunCMake: handle C++26 support where needed 2025-01-08 16:32:14 -05:00
Brad King 35425256a5 Merge topic 'iface-public-modules'
854eba0c53 target_sources: Improve error message for CXX_MODULES on INTERFACE libraries
cd179e7560 Tests/RunCMake/CXXModules: Rename FileSetModules cases to be more specific

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !10090
2024-12-12 09:12:01 -05:00
Brad King 2670dd4ed1 Merge topic 'iface-public-modules' into release-3.31
854eba0c53 target_sources: Improve error message for CXX_MODULES on INTERFACE libraries
cd179e7560 Tests/RunCMake/CXXModules: Rename FileSetModules cases to be more specific

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !10090
2024-12-12 09:11:59 -05:00
Brad KingandBen Boeckel 854eba0c53 target_sources: Improve error message for CXX_MODULES on INTERFACE libraries
We support non-compiled `SOURCES` on `INTERFACE` libraries, and also
support `CXX_MODULES` on *imported* `INTERFACE` libraries (via synthetic
targets that compile module interface units).  However, we do not
support `CXX_MODULES` on non-imported `INTERFACE` libraries because
there is no place to hold module interface unit's object files for their
module initializers.  Previously this was not explicitly rejected, and
so was diagnosed only by "CMake Internal Error" messages due to
assumption violations in the implementation.

Fixes: #26524
Co-authored-by: Ben Boeckel <ben.boeckel@kitware.com>
2024-12-11 12:34:29 -05:00
Brad King cd179e7560 Tests/RunCMake/CXXModules: Rename FileSetModules cases to be more specific
They all add `CXX_MODULES` to `STATIC` libraries.
2024-12-11 12:20:45 -05:00
Brad King bc69ff7c6d Tests/RunCMake/CXXModules: Improve failure message formatting 2024-10-21 19:53:46 -04:00
Ben Boeckel e77655555c cmExperimental: gate build database support behind a flag
Given that the feature currently only supports C++ sources and is not
formally accepted by ISO yet, gate it behind a flag.
2024-09-03 10:05:40 -04:00
Ben Boeckel 6863c1d823 Tests/CXXModules: add tests for module commands 2024-09-03 10:05:40 -04:00
Ben Boeckel 123107c1a4 Tests/CXXModules: add support for running targets under a given config 2024-08-27 12:37:36 -04:00