summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalGenerator.cxx
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2023-02-07 23:01:00 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2023-08-17 18:42:53 (GMT)
commit80d65443982ca1b2c98c84ae86e2bfccdbdd7678 (patch)
tree10a09814846a5eb88663d9de29e7de8175c24425 /Source/cmGlobalGenerator.cxx
parent3dc6676ecc4ef8a74b057f284f123fd54e867fa4 (diff)
downloadCMake-80d65443982ca1b2c98c84ae86e2bfccdbdd7678.zip
CMake-80d65443982ca1b2c98c84ae86e2bfccdbdd7678.tar.gz
CMake-80d65443982ca1b2c98c84ae86e2bfccdbdd7678.tar.bz2
cxxmodules: generate synthetic targets as an initial pass
We need to be able to construct BMIs that will be usable from the client modules for the target importing the module, so create BMI-only compilation rules for `IMPORTED` targets to create these BMIs.
Diffstat (limited to 'Source/cmGlobalGenerator.cxx')
-rw-r--r--Source/cmGlobalGenerator.cxx40
1 files changed, 40 insertions, 0 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 9af6e9b..d5099ee 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -55,6 +55,7 @@
#include "cmStateDirectory.h"
#include "cmStateTypes.h"
#include "cmStringAlgorithms.h"
+#include "cmSyntheticTargetCache.h"
#include "cmSystemTools.h"
#include "cmValue.h"
#include "cmVersion.h"
@@ -1560,6 +1561,17 @@ bool cmGlobalGenerator::Compute()
}
#endif
+ // Iterate through all targets and set up C++20 module targets.
+ // Create target templates for each imported target with C++20 modules.
+ // INTERFACE library with BMI-generating rules and a collation step?
+ // Maybe INTERFACE libraries with modules files should just do BMI-only?
+ // Make `add_dependencies(imported_target
+ // $<$<TARGET_NAME_IF_EXISTS:uses_imported>:synth1>
+ // $<$<TARGET_NAME_IF_EXISTS:other_uses_imported>:synth2>)`
+ if (!this->DiscoverSyntheticTargets()) {
+ return false;
+ }
+
// Add generator specific helper commands
for (const auto& localGen : this->LocalGenerators) {
localGen->AddHelperCommands();
@@ -1784,6 +1796,34 @@ void cmGlobalGenerator::ComputeTargetOrder(cmGeneratorTarget const* gt,
entry->second = index++;
}
+bool cmGlobalGenerator::DiscoverSyntheticTargets()
+{
+ cmSyntheticTargetCache cache;
+
+ for (auto const& gen : this->LocalGenerators) {
+ // Because DiscoverSyntheticTargets() adds generator targets, we need to
+ // cache the existing list of generator targets before starting.
+ std::vector<cmGeneratorTarget*> genTargets;
+ genTargets.reserve(gen->GetGeneratorTargets().size());
+ for (auto const& tgt : gen->GetGeneratorTargets()) {
+ genTargets.push_back(tgt.get());
+ }
+
+ for (auto* tgt : genTargets) {
+ std::vector<std::string> const& configs =
+ tgt->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig);
+
+ for (auto const& config : configs) {
+ if (!tgt->DiscoverSyntheticTargets(cache, config)) {
+ return false;
+ }
+ }
+ }
+ }
+
+ return true;
+}
+
bool cmGlobalGenerator::AddHeaderSetVerification()
{
for (auto const& gen : this->LocalGenerators) {