From 3273b1897290731acbc3cdf9d5bc73f34a170772 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 2 Mar 2024 00:09:26 -0500 Subject: cmExportFileGenerator: support always exporting properties --- Source/cmExportFileGenerator.cxx | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 7867a8e..2d48f34 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -1388,6 +1388,12 @@ void cmExportFileGenerator::GenerateImportedFileChecksCode( os << ")\n\n"; } +enum class ExportWhen +{ + Defined, + Always, +}; + enum class PropertyType { Strings, @@ -1409,6 +1415,12 @@ bool PropertyTypeIsForPaths(PropertyType pt) } } +struct ModuleTargetPropertyTable +{ + cm::static_string_view Name; + ExportWhen Cond; +}; + struct ModulePropertyTable { cm::static_string_view Name; @@ -1424,18 +1436,21 @@ bool cmExportFileGenerator::PopulateCxxModuleExportProperties( return true; } - const cm::static_string_view exportedDirectModuleProperties[] = { - "CXX_EXTENSIONS"_s, + const ModuleTargetPropertyTable exportedDirectModuleProperties[] = { + { "CXX_EXTENSIONS"_s, ExportWhen::Defined }, }; - for (auto const& propName : exportedDirectModuleProperties) { - auto const propNameStr = std::string(propName); - cmValue prop = gte->Target->GetComputedProperty( + for (auto const& prop : exportedDirectModuleProperties) { + auto const propNameStr = std::string(prop.Name); + cmValue propValue = gte->Target->GetComputedProperty( propNameStr, *gte->Target->GetMakefile()); - if (!prop) { - prop = gte->Target->GetProperty(propNameStr); + if (!propValue) { + propValue = gte->Target->GetProperty(propNameStr); } - if (prop) { - properties[propNameStr] = cmGeneratorExpression::Preprocess(*prop, ctx); + if (propValue) { + properties[propNameStr] = + cmGeneratorExpression::Preprocess(*propValue, ctx); + } else if (prop.Cond == ExportWhen::Always) { + properties[propNameStr] = ""; } } -- cgit v0.12