Commit Graph

29 Commits

Author SHA1 Message Date
Ben Boeckel 458e3974a8 cxxmodules: detect and message about non-compiled sources
Previously an internal error was raised which ended up causing an
internal exception to be thrown. This is a typo situation that should
fall into an explicit error.

Fixes: #25207
2023-09-12 14:46:36 -04:00
Ben Boeckel a99b87a628 Tests/RunCMake/CXXModules: add a test for issue #25112
Add a test case for C++ `OBJECT` libraries providing modules to
consumers.
2023-07-22 06:53:38 -04:00
Ben Boeckel 677b28dc7b Ninja: include module mapper flags in compile_commands.json
Fixes: #24618
2023-07-09 11:04:29 -04:00
Brad King b9c99830c5 VS: Fix C++ modules in source files with the same name
When multiple source files in a single target have the same name, we
already set `ObjectFileName` explicitly to avoid a `.obj` collision. For
C++ module sources, set `Module{Output,Dependencies}File` to avoid
`.ifc` and `.module.json` collisions.

Fixes: #25038
2023-06-28 06:43:10 -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
Ben Boeckel 69e4525241 Tests/CXXModules: add example for private modules between targets
Adapted from the example in issue #24652 by Ivan Garramona.
2023-05-18 08:34:31 -04:00
Ben Boeckel f755296f9d Tests/RunCMake/CXXModules: add tests which don't export C++ module properties
The existing `export-interfaces-{build,install}` tests were actually
doing this, but make those test exporting the interfaces and copy the
existing tests to tests which explicitly test the "no properties"
condition.
2023-01-26 23:19:44 -05:00
Ben Boeckel 7abddcab08 Ninja: require Ninja 1.11 for C++ module support
See: https://gitlab.kitware.com/cmake/cmake/-/issues/18355#note_1296721
See: https://github.com/ninja-build/ninja/pull/1937
2023-01-23 12:21:05 -05:00
Ben Boeckel 388acfd46d Tests/RunCMake/CXXModules: add support for Visual Studio 2022-12-01 11:42:46 -05:00
Ben Boeckel 069a32b03c Tests/RunCMake/CXXModules: split out collation-requiring tests
Visual Studio does not currently have a place to insert the logic
required to implement this test, so skip it if possible.
2022-12-01 11:42:46 -05:00
Ben Boeckel ef03a3a2f5 Tests/RunCMake/CXXModules: factor out generator support detection
This keeps the condition to a readable limit.
2022-12-01 11:42:46 -05:00
Ben Boeckel a02d792c6e cxxmodules: add properties to control scanning
The `CXX_SCAN_FOR_MODULES` property may be used to control scanning for
targets and for source files rather than assuming "C++20 always needs to
be scanned".
2022-11-18 07:54:31 -05:00
Ben Boeckel 52e82dbb23 Tests/RunCMake/CXXModules: add a test with duplicate modules
Not in the same executable (as that is IFNDR), but in the same project.
This tests to make sure that there's not some project-wide cache that
gets confused.
2022-10-11 12:51:33 -04:00
Ben Boeckel e67f5d41af Tests/RunCMake/CXXModules: add a test with circular imports
The build should fail. However, the error message is completely
generator-dependent as it is the build tool which (should) eventually
detect this case.
2022-10-11 12:51:32 -04:00
Ben Boeckel c49d5f137b RunCMake/CXXModules: add a "deep-chain" test
This tests that transitive usages are propogated properly across long
import chains between targets.
2022-08-02 10:53:38 -04:00
Ben Boeckel f62c3c3c72 RunCMake/CXXModules: test public modules requiring private modules 2022-07-06 11:38:11 -04:00
Ben Boeckel c5d4dd713f RunCMake/CXXModules: add tests which export BMIs 2022-07-06 11:38:11 -04:00
Ben Boeckel 4d55f1422e RunCMake/CXXModules: test installation of BMIs and interfaces 2022-07-06 11:38:11 -04:00
Ben Boeckel eff45f790d RunCMake/CXXModules: fix example follow-on case names 2022-07-06 11:38:11 -04:00
Ben Boeckel a87c39dad1 RunCMake/CXXModules: output example test output upon failure 2022-07-06 11:38:10 -04:00
Ben Boeckel 727e3db07a RunCMake/CXXModules: append to the test options 2022-07-06 11:38:10 -04:00
Ben Boeckel fddd44c897 cmNinjaTargetGenerator: write out BMI install information for the collator 2022-07-06 10:15:23 -04:00
Ben Boeckel 95402a0bd7 cmNinjaTargetGenerator: write out export information for the collator
The collator will use this to know where the target's export information
needs to go so that module properties may be provided.
2022-07-06 10:15:23 -04:00
Ben Boeckel d3e2e61bcd cmNinjaTargetGenerator: write out fileset information for the collator
The collator will use this to generate property settings for the
imported targets in the build and install export sets.
2022-07-06 10:15:23 -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 29118091dc install: support CXX_MODULES_BMI installation bits 2022-07-06 10:15:23 -04:00
Ben Boeckel f3cfde394a cmTargetSourcesCommand: allow INTERFACE C++ modules when imported
`PUBLIC` filesets become `INTERFACE` upon installation. Allow
`INTERFACE` scopes for C++ modules when the target is imported.
2022-07-06 10:15:23 -04:00
Ben Boeckel 8c5a53096a Tests/RunCMake/CXXModules: add module-using examples
This includes a number of examples that should work for various levels
of support in a compiler.

There are a number of tests which are gated on various features in the
compilers. To enable the tests, set `CMake_TEST_MODULE_COMPILATION` to a
comma-separated (to avoid `;`-escaping problems) to the list of features
which are supported:

  - `named`: Named modules are supported.
  - `shared`: Shared libraries with module usage at the API boundary are
    supported.
  - `partitions`: Named module partitions are supported.
  - `internal_partitions`: Named module internal partitions are
    supported.

Additionally, a `CMake_TEST_MODULE_COMPILATION_RULES` file must be
passed which contains the rules for how to build modules using the
provided compiler. It will be included in the tests to provide these
rules. To verify that the file provided works as intended, it must set
`CMake_TEST_CXXModules_UUID` to a specific version to indicate that it
is an expected file.
2022-06-16 10:28:34 -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