瀏覽代碼

cmLocalGenerator: Inline AddCompilerRequirementFlag in only call site

The call site in `AddLanguageFlags` is now the "one true place" for
adding language standard flags.  Inline the helper to reduce risk of
adding other call sites later.
Brad King 2 年之前
父節點
當前提交
a1c20b08b4
共有 2 個文件被更改,包括 13 次插入24 次删除
  1. 13 20
      Source/cmLocalGenerator.cxx
  2. 0 4
      Source/cmLocalGenerator.h

+ 13 - 20
Source/cmLocalGenerator.cxx

@@ -1935,7 +1935,19 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags,
        // selection, this will have to be reconciled with it.
        this->Makefile->IsOn(
          cmStrCat("CMAKE_", lang, "_LINK_WITH_STANDARD_COMPILE_OPTION")))) {
-    this->AddCompilerRequirementFlag(flags, target, lang, config);
+    cmStandardLevelResolver standardResolver(this->Makefile);
+    std::string const& optionFlagDef =
+      standardResolver.GetCompileOptionDef(target, lang, config);
+    if (!optionFlagDef.empty()) {
+      cmValue opt =
+        target->Target->GetMakefile()->GetDefinition(optionFlagDef);
+      if (opt) {
+        std::vector<std::string> optVec = cmExpandedList(*opt);
+        for (std::string const& i : optVec) {
+          this->AppendFlagEscape(flags, i);
+        }
+      }
+    }
   }
 
   std::string compiler = this->Makefile->GetSafeDefinition(
@@ -2221,25 +2233,6 @@ void cmLocalGenerator::AddSharedFlags(std::string& flags,
   }
 }
 
-void cmLocalGenerator::AddCompilerRequirementFlag(
-  std::string& flags, cmGeneratorTarget const* target, const std::string& lang,
-  const std::string& config)
-{
-  cmStandardLevelResolver standardResolver(this->Makefile);
-
-  std::string const& optionFlagDef =
-    standardResolver.GetCompileOptionDef(target, lang, config);
-  if (!optionFlagDef.empty()) {
-    cmValue opt = target->Target->GetMakefile()->GetDefinition(optionFlagDef);
-    if (opt) {
-      std::vector<std::string> optVec = cmExpandedList(*opt);
-      for (std::string const& i : optVec) {
-        this->AppendFlagEscape(flags, i);
-      }
-    }
-  }
-}
-
 static void AddVisibilityCompileOption(std::string& flags,
                                        cmGeneratorTarget const* target,
                                        cmLocalGenerator* lg,

+ 0 - 4
Source/cmLocalGenerator.h

@@ -164,10 +164,6 @@ public:
                                 const std::string& lang);
   void AddConfigVariableFlags(std::string& flags, const std::string& var,
                               const std::string& config);
-  void AddCompilerRequirementFlag(std::string& flags,
-                                  cmGeneratorTarget const* target,
-                                  const std::string& lang,
-                                  const std::string& config);
   void AddColorDiagnosticsFlags(std::string& flags, const std::string& lang);
   //! Append flags to a string.
   virtual void AppendFlags(std::string& flags,