Commit Graph

26 Commits

Author SHA1 Message Date
Ben Boeckel c53748cc09 Tests/RunCMake/CXXModules: mark IMPORTED targets as INTERFACE
Now that `Ninja` generators will know to generate rules for `IMPORTED`
targets, mark these as `INTERFACE` to avoid requirements of actual
artifacts.
2022-11-21 18:22:00 -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
Brad King 38c8866dd1 Merge topic 'msvc-19.34-cpp-modules'
0e9782b336 msvc: bless MSVC 19.34 support for C++ modules as experimental

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !7745
2022-11-14 10:18:21 -05:00
Ben Boeckel 0e9782b336 msvc: bless MSVC 19.34 support for C++ modules as experimental
Visual Studio 17.4 now contains official support for what CMake needs.
2022-11-11 16:54:05 -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 b90de0b492 RunCMake/CXXModules: support MSVC extensions 2022-08-02 10:53:38 -04:00
Ben Boeckel b5a6648c4b RunCMake/CXXModules: fix partition importing syntax
Apparently GCC accepts the ill-formed prior syntax.
2022-07-26 12:25:42 -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 ffd40c6b6e Tests/RunCMake/CXXModules: add a json comparison script 2022-07-06 10:15:23 -04:00
Ben Boeckel 48502a3781 cmExperimental: update CXX_MODULE_CMAKE_API UUID
The set of features available has been expanded, so update the UUID.
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
Raul Tambre e1adddc74e RunCMake/CXXModules/NoCXX20: Force older standard
Compile features ensure a compiler is aware of a standard version, but the one
actually used may be newer. The test relies on the standard chosen being
pre-C++20, so force C++17 explicitly.

This was exposed by a nightly bot that has a compiler defaulting to C++23. The
test would've broken anyway in a few years once GCC or Clang upped their
default.
2022-06-28 09:27:29 -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