diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index c40518035d5eaf349f992ad3529d2f94248aa5a8..03f5d2c32bfb52a44a6a12ced03a6825c2aea9cd 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -722,6 +722,8 @@ std::string cmLocalGenerator::ExpandRuleVariable(
       std::map<std::string, std::string>::iterator compIt =
         compilers.find(variable);
 
+      std::string replace = this->Makefile->GetSafeDefinition(variable);
+
       if (compIt != compilers.end()) {
         std::string arg1 = compIt->first + "_ARG1";
         compilerArg1 = this->Makefile->GetDefinition(arg1);
@@ -743,7 +745,6 @@ std::string cmLocalGenerator::ExpandRuleVariable(
         cmSystemTools::ReplaceString(actualReplace, "${LANG}", lang);
       }
       if (actualReplace == variable) {
-        std::string replace = this->Makefile->GetSafeDefinition(variable);
         // if the variable is not a FLAG then treat it like a path
         if (variable.find("_FLAG") == variable.npos) {
           std::string ret = this->ConvertToOutputForExisting(replace);