فهرست منبع

VS: Remove always-true condition on compile options block

The cmVisualStudio10TargetGenerator::ComputeClOptions method is
only called when the target type compiles, so do not duplicate
that check in the implementation.
Brad King 11 سال پیش
والد
کامیت
8f4bdcc6cb
1فایلهای تغییر یافته به همراه32 افزوده شده و 36 حذف شده
  1. 32 36
      Source/cmVisualStudio10TargetGenerator.cxx

+ 32 - 36
Source/cmVisualStudio10TargetGenerator.cxx

@@ -1367,44 +1367,40 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
   Options& clOptions = *pOptions;
   Options& clOptions = *pOptions;
 
 
   std::string flags;
   std::string flags;
-  // collect up flags for
-  if(this->Target->GetType() < cmTarget::UTILITY)
+  const std::string& linkLanguage =
+    this->Target->GetLinkerLanguage(configName.c_str());
+  if(linkLanguage.empty())
     {
     {
-    const std::string& linkLanguage =
-      this->Target->GetLinkerLanguage(configName.c_str());
-    if(linkLanguage.empty())
-      {
-      cmSystemTools::Error
-        ("CMake can not determine linker language for target: ",
-         this->Name.c_str());
-      return false;
-      }
-    if(linkLanguage == "C" || linkLanguage == "CXX"
-       || linkLanguage == "Fortran")
-      {
-      std::string baseFlagVar = "CMAKE_";
-      baseFlagVar += linkLanguage;
-      baseFlagVar += "_FLAGS";
-      flags = this->
-        Target->GetMakefile()->GetRequiredDefinition(baseFlagVar.c_str());
-      std::string flagVar = baseFlagVar + std::string("_") +
-        cmSystemTools::UpperCase(configName);
-      flags += " ";
-      flags += this->
-        Target->GetMakefile()->GetRequiredDefinition(flagVar.c_str());
-      }
-    // set the correct language
-    if(linkLanguage == "C")
-      {
-      flags += " /TC ";
-      }
-    if(linkLanguage == "CXX")
-      {
-      flags += " /TP ";
-      }
-    this->LocalGenerator->AddCompileOptions(flags, this->Target,
-                                            linkLanguage, configName.c_str());
+    cmSystemTools::Error
+      ("CMake can not determine linker language for target: ",
+       this->Name.c_str());
+    return false;
+    }
+  if(linkLanguage == "C" || linkLanguage == "CXX"
+     || linkLanguage == "Fortran")
+    {
+    std::string baseFlagVar = "CMAKE_";
+    baseFlagVar += linkLanguage;
+    baseFlagVar += "_FLAGS";
+    flags = this->
+      Target->GetMakefile()->GetRequiredDefinition(baseFlagVar.c_str());
+    std::string flagVar = baseFlagVar + std::string("_") +
+      cmSystemTools::UpperCase(configName);
+    flags += " ";
+    flags += this->
+      Target->GetMakefile()->GetRequiredDefinition(flagVar.c_str());
+    }
+  // set the correct language
+  if(linkLanguage == "C")
+    {
+    flags += " /TC ";
+    }
+  if(linkLanguage == "CXX")
+    {
+    flags += " /TP ";
     }
     }
+  this->LocalGenerator->AddCompileOptions(flags, this->Target,
+                                          linkLanguage, configName.c_str());
 
 
   // Get preprocessor definitions for this directory.
   // Get preprocessor definitions for this directory.
   std::string defineFlags = this->Target->GetMakefile()->GetDefineFlags();
   std::string defineFlags = this->Target->GetMakefile()->GetDefineFlags();