cmExportFileGenerator: relocate include directories for C++ modules

Include directories are paths that need munged on install to support the
installation prefix.

Fixes: #25275
This commit is contained in:
Ben Boeckel
2023-09-26 08:51:12 -04:00
parent 349ff8b080
commit b3d1bbbbcc
+25 -8
View File
@@ -1256,6 +1256,18 @@ void cmExportFileGenerator::GenerateImportedFileChecksCode(
os << ")\n\n"; os << ")\n\n";
} }
enum class PropertyType
{
Strings,
Paths,
};
struct ModulePropertyTable
{
cm::static_string_view Name;
PropertyType Type;
};
bool cmExportFileGenerator::PopulateCxxModuleExportProperties( bool cmExportFileGenerator::PopulateCxxModuleExportProperties(
cmGeneratorTarget const* gte, ImportPropertyMap& properties, cmGeneratorTarget const* gte, ImportPropertyMap& properties,
cmGeneratorExpression::PreprocessContext ctx, std::string& errorMessage) cmGeneratorExpression::PreprocessContext ctx, std::string& errorMessage)
@@ -1279,14 +1291,14 @@ bool cmExportFileGenerator::PopulateCxxModuleExportProperties(
} }
} }
const cm::static_string_view exportedModuleProperties[] = { const ModulePropertyTable exportedModuleProperties[] = {
"INCLUDE_DIRECTORIES"_s, { "INCLUDE_DIRECTORIES"_s, PropertyType::Paths },
"COMPILE_DEFINITIONS"_s, { "COMPILE_DEFINITIONS"_s, PropertyType::Strings },
"COMPILE_OPTIONS"_s, { "COMPILE_OPTIONS"_s, PropertyType::Strings },
"COMPILE_FEATURES"_s, { "COMPILE_FEATURES"_s, PropertyType::Strings },
}; };
for (auto const& propName : exportedModuleProperties) { for (auto const& propEntry : exportedModuleProperties) {
auto const propNameStr = std::string(propName); auto const propNameStr = std::string(propEntry.Name);
cmValue prop = gte->Target->GetComputedProperty( cmValue prop = gte->Target->GetComputedProperty(
propNameStr, *gte->Target->GetMakefile()); propNameStr, *gte->Target->GetMakefile());
if (!prop) { if (!prop) {
@@ -1294,9 +1306,14 @@ bool cmExportFileGenerator::PopulateCxxModuleExportProperties(
} }
if (prop) { if (prop) {
auto const exportedPropName = auto const exportedPropName =
cmStrCat("IMPORTED_CXX_MODULES_", propName); cmStrCat("IMPORTED_CXX_MODULES_", propEntry.Name);
properties[exportedPropName] = properties[exportedPropName] =
cmGeneratorExpression::Preprocess(*prop, ctx); cmGeneratorExpression::Preprocess(*prop, ctx);
if (ctx == cmGeneratorExpression::InstallInterface &&
propEntry.Type == PropertyType::Paths) {
this->ReplaceInstallPrefix(properties[exportedPropName]);
prefixItems(properties[exportedPropName]);
}
} }
} }