Kaynağa Gözat

cmExportFileGenerator: support always exporting properties

Ben Boeckel 1 yıl önce
ebeveyn
işleme
3273b18972
1 değiştirilmiş dosya ile 24 ekleme ve 9 silme
  1. 24 9
      Source/cmExportFileGenerator.cxx

+ 24 - 9
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] = "";
     }
   }