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).
This commit is contained in:
Ben Boeckel
2022-04-08 13:56:33 -04:00
parent ff30a5397d
commit 386465bf83
82 changed files with 1294 additions and 78 deletions

View File

@@ -1196,4 +1196,34 @@ public:
bool operator()(cmGeneratorTarget const* t1,
cmGeneratorTarget const* t2) const;
};
// C++20 module support queries.
/**
* Query whether the target expects C++20 module support.
*
* This will inspect the target itself to see if C++20 module
* support is expected to work based on its sources.
*/
bool HaveCxx20ModuleSources() const;
enum class Cxx20SupportLevel
{
// C++ is not available.
MissingCxx,
// The experimental feature is not available.
MissingExperimentalFlag,
// The target does not require at least C++20.
NoCxx20,
// C++20 modules are available and working.
Supported,
};
/**
* Query whether the target has C++20 module support available (regardless of
* whether it is required or not).
*/
Cxx20SupportLevel HaveCxxModuleSupport(std::string const& config) const;
// Check C++ module status for the target.
void CheckCxxModuleStatus(std::string const& config) const;
};