Browse Source

cmGeneratorExpressionNode: Factor out local variable for global generator

Brad King 4 years ago
parent
commit
83c8272280
1 changed files with 4 additions and 3 deletions
  1. 4 3
      Source/cmGeneratorExpressionNode.cxx

+ 4 - 3
Source/cmGeneratorExpressionNode.cxx

@@ -1635,10 +1635,11 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode
       reportError(context, content->GetOriginalExpression(), e.str());
       return std::string();
     }
-    if (!context->EvaluateForBuildsystem) {
-      cmGlobalGenerator* gg = context->LG->GetGlobalGenerator();
+    cmGlobalGenerator* gg = context->LG->GetGlobalGenerator();
+    {
       std::string reason;
-      if (!gg->HasKnownObjectFileLocation(&reason)) {
+      if (!context->EvaluateForBuildsystem &&
+          !gg->HasKnownObjectFileLocation(&reason)) {
         std::ostringstream e;
         e << "The evaluation of the TARGET_OBJECTS generator expression "
              "is only suitable for consumption by CMake (limited"