Browse Source

Makefile,Ninja: Use tool-specific response file flag for include dirs

When we use a response file for `-I` flags, not all compilers support
the `@<file>` syntax.  Define `CMAKE_<LANG>_RESPONSE_FILE_FLAG` to
specify tool-specific flag, just as we do for linking already via
`CMAKE_<LANG>_RESPONSE_FILE_LINK_FLAG`.
Brad King 7 năm trước cách đây
mục cha
commit
e342e4100a
2 tập tin đã thay đổi với 17 bổ sung4 xóa
  1. 8 1
      Source/cmMakefileTargetGenerator.cxx
  2. 9 3
      Source/cmNinjaTargetGenerator.cxx

+ 8 - 1
Source/cmMakefileTargetGenerator.cxx

@@ -1625,10 +1625,17 @@ void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags,
   }
 
   if (useResponseFile) {
+    std::string const responseFlagVar =
+      "CMAKE_" + lang + "_RESPONSE_FILE_FLAG";
+    std::string responseFlag =
+      this->Makefile->GetSafeDefinition(responseFlagVar);
+    if (responseFlag.empty()) {
+      responseFlag = "@";
+    }
     std::string name = "includes_";
     name += lang;
     name += ".rsp";
-    std::string arg = "@" +
+    std::string arg = std::move(responseFlag) +
       this->CreateResponseFile(name.c_str(), includeFlags,
                                this->FlagFileDepends[lang]);
     this->LocalGenerator->AppendFlags(flags, arg);

+ 9 - 3
Source/cmNinjaTargetGenerator.cxx

@@ -416,14 +416,20 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
   std::string flags = "$FLAGS";
   std::string rspfile;
   std::string rspcontent;
-  std::string responseFlag;
 
   bool const lang_supports_response = !(lang == "RC" || lang == "CUDA");
   if (lang_supports_response && this->ForceResponseFile()) {
+    std::string const responseFlagVar =
+      "CMAKE_" + lang + "_RESPONSE_FILE_FLAG";
+    std::string responseFlag =
+      this->Makefile->GetSafeDefinition(responseFlagVar);
+    if (responseFlag.empty()) {
+      responseFlag = "@";
+    }
     rspfile = "$RSP_FILE";
-    responseFlag = "@" + rspfile;
+    responseFlag += rspfile;
     rspcontent = " $DEFINES $INCLUDES $FLAGS";
-    flags = responseFlag;
+    flags = std::move(responseFlag);
     vars.Defines = "";
     vars.Includes = "";
   }