Optionally pass include directories with response files
Create platform option CMAKE_<lang>_USE_RESPONSE_FILE_FOR_INCLUDES to enable use of response files for passing the list of include directories to compiler command lines.
This commit is contained in:
parent
6e8a67f99a
commit
9a0b9bc8b7
|
@ -1451,6 +1451,8 @@ void cmDocumentVariables::DefineVariables(cmake* cm)
|
||||||
cmProperty::VARIABLE,0,0);
|
cmProperty::VARIABLE,0,0);
|
||||||
cm->DefineProperty("CMAKE_<LANG>_STANDARD_LIBRARIES_INIT",
|
cm->DefineProperty("CMAKE_<LANG>_STANDARD_LIBRARIES_INIT",
|
||||||
cmProperty::VARIABLE,0,0);
|
cmProperty::VARIABLE,0,0);
|
||||||
|
cm->DefineProperty("CMAKE_<LANG>_USE_RESPONSE_FILE_FOR_INCLUDES",
|
||||||
|
cmProperty::VARIABLE,0,0);
|
||||||
cm->DefineProperty("CMAKE_<LANG>_USE_RESPONSE_FILE_FOR_OBJECTS",
|
cm->DefineProperty("CMAKE_<LANG>_USE_RESPONSE_FILE_FOR_OBJECTS",
|
||||||
cmProperty::VARIABLE,0,0);
|
cmProperty::VARIABLE,0,0);
|
||||||
cm->DefineProperty("CMAKE_EXECUTABLE_SUFFIX_<LANG>",
|
cm->DefineProperty("CMAKE_EXECUTABLE_SUFFIX_<LANG>",
|
||||||
|
|
|
@ -1185,15 +1185,18 @@ cmLocalGenerator::ConvertToOutputForExisting(RelativeRoot remote,
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
const char* cmLocalGenerator::GetIncludeFlags(const char* lang)
|
const char* cmLocalGenerator::GetIncludeFlags(const char* lang,
|
||||||
|
bool forResponseFile)
|
||||||
{
|
{
|
||||||
if(!lang)
|
if(!lang)
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
if(this->LanguageToIncludeFlags.count(lang))
|
std::string key = lang;
|
||||||
|
key += forResponseFile? "@" : "";
|
||||||
|
if(this->LanguageToIncludeFlags.count(key))
|
||||||
{
|
{
|
||||||
return this->LanguageToIncludeFlags[lang].c_str();
|
return this->LanguageToIncludeFlags[key].c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
cmOStringStream includeFlags;
|
cmOStringStream includeFlags;
|
||||||
|
@ -1251,10 +1254,10 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang)
|
||||||
frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str());
|
frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str());
|
||||||
if(emitted.insert(frameworkDir).second)
|
if(emitted.insert(frameworkDir).second)
|
||||||
{
|
{
|
||||||
|
OutputFormat format = forResponseFile? RESPONSE : SHELL;
|
||||||
includeFlags
|
includeFlags
|
||||||
<< "-F" << this->Convert(frameworkDir.c_str(),
|
<< "-F" << this->Convert(frameworkDir.c_str(),
|
||||||
cmLocalGenerator::START_OUTPUT,
|
START_OUTPUT, format, true)
|
||||||
cmLocalGenerator::SHELL, true)
|
|
||||||
<< " ";
|
<< " ";
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
@ -1274,7 +1277,16 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang)
|
||||||
}
|
}
|
||||||
flagUsed = true;
|
flagUsed = true;
|
||||||
}
|
}
|
||||||
std::string includePath = this->ConvertToOutputForExisting(i->c_str());
|
std::string includePath;
|
||||||
|
if(forResponseFile)
|
||||||
|
{
|
||||||
|
includePath = this->Convert(i->c_str(), START_OUTPUT,
|
||||||
|
RESPONSE, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
includePath = this->ConvertToOutputForExisting(i->c_str());
|
||||||
|
}
|
||||||
if(quotePaths && includePath.size() && includePath[0] != '\"')
|
if(quotePaths && includePath.size() && includePath[0] != '\"')
|
||||||
{
|
{
|
||||||
includeFlags << "\"";
|
includeFlags << "\"";
|
||||||
|
@ -1292,11 +1304,11 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang)
|
||||||
{
|
{
|
||||||
flags[flags.size()-1] = ' ';
|
flags[flags.size()-1] = ' ';
|
||||||
}
|
}
|
||||||
this->LanguageToIncludeFlags[lang] = flags;
|
this->LanguageToIncludeFlags[key] = flags;
|
||||||
|
|
||||||
// Use this temorary variable for the return value to work-around a
|
// Use this temorary variable for the return value to work-around a
|
||||||
// bogus GCC 2.95 warning.
|
// bogus GCC 2.95 warning.
|
||||||
const char* ret = this->LanguageToIncludeFlags[lang].c_str();
|
const char* ret = this->LanguageToIncludeFlags[key].c_str();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -143,7 +143,8 @@ public:
|
||||||
const char* config);
|
const char* config);
|
||||||
virtual void AppendFlags(std::string& flags, const char* newFlags);
|
virtual void AppendFlags(std::string& flags, const char* newFlags);
|
||||||
///! Get the include flags for the current makefile and language
|
///! Get the include flags for the current makefile and language
|
||||||
const char* GetIncludeFlags(const char* lang);
|
const char* GetIncludeFlags(const char* lang,
|
||||||
|
bool forResponseFile = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encode a list of preprocessor definitions for the compiler
|
* Encode a list of preprocessor definitions for the compiler
|
||||||
|
|
|
@ -880,6 +880,20 @@ cmLocalUnixMakefileGenerator3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void
|
||||||
|
cmLocalUnixMakefileGenerator3
|
||||||
|
::AppendRuleDepends(std::vector<std::string>& depends,
|
||||||
|
std::vector<std::string> const& ruleFiles)
|
||||||
|
{
|
||||||
|
// Add a dependency on the rule file itself unless an option to skip
|
||||||
|
// it is specifically enabled by the user or project.
|
||||||
|
if(!this->Makefile->IsOn("CMAKE_SKIP_RULE_DEPENDENCY"))
|
||||||
|
{
|
||||||
|
depends.insert(depends.end(), ruleFiles.begin(), ruleFiles.end());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void
|
void
|
||||||
cmLocalUnixMakefileGenerator3
|
cmLocalUnixMakefileGenerator3
|
||||||
|
|
|
@ -320,6 +320,8 @@ protected:
|
||||||
|
|
||||||
void AppendRuleDepend(std::vector<std::string>& depends,
|
void AppendRuleDepend(std::vector<std::string>& depends,
|
||||||
const char* ruleFileName);
|
const char* ruleFileName);
|
||||||
|
void AppendRuleDepends(std::vector<std::string>& depends,
|
||||||
|
std::vector<std::string> const& ruleFiles);
|
||||||
void AppendCustomDepends(std::vector<std::string>& depends,
|
void AppendCustomDepends(std::vector<std::string>& depends,
|
||||||
const std::vector<cmCustomCommand>& ccs);
|
const std::vector<cmCustomCommand>& ccs);
|
||||||
void AppendCustomDepend(std::vector<std::string>& depends,
|
void AppendCustomDepend(std::vector<std::string>& depends,
|
||||||
|
|
|
@ -310,8 +310,7 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
|
||||||
this->LocalGenerator->AddSharedFlags(flags, lang, shared);
|
this->LocalGenerator->AddSharedFlags(flags, lang, shared);
|
||||||
|
|
||||||
// Add include directory flags.
|
// Add include directory flags.
|
||||||
this->LocalGenerator->
|
this->AddIncludeFlags(flags, lang);
|
||||||
AppendFlags(flags, this->LocalGenerator->GetIncludeFlags(lang));
|
|
||||||
|
|
||||||
// Append old-style preprocessor definition flags.
|
// Append old-style preprocessor definition flags.
|
||||||
this->LocalGenerator->
|
this->LocalGenerator->
|
||||||
|
@ -487,6 +486,8 @@ cmMakefileTargetGenerator
|
||||||
{
|
{
|
||||||
this->LocalGenerator->AppendRuleDepend(depends,
|
this->LocalGenerator->AppendRuleDepend(depends,
|
||||||
this->FlagFileNameFull.c_str());
|
this->FlagFileNameFull.c_str());
|
||||||
|
this->LocalGenerator->AppendRuleDepends(depends,
|
||||||
|
this->FlagFileDepends[lang]);
|
||||||
|
|
||||||
// generate the depend scanning rule
|
// generate the depend scanning rule
|
||||||
this->WriteObjectDependRules(source, depends);
|
this->WriteObjectDependRules(source, depends);
|
||||||
|
@ -1724,6 +1725,38 @@ cmMakefileTargetGenerator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags,
|
||||||
|
const char* lang)
|
||||||
|
{
|
||||||
|
std::string responseVar = "CMAKE_";
|
||||||
|
responseVar += lang;
|
||||||
|
responseVar += "_USE_RESPONSE_FILE_FOR_INCLUDES";
|
||||||
|
bool useResponseFile = this->Makefile->IsOn(responseVar.c_str());
|
||||||
|
|
||||||
|
std::string includeFlags =
|
||||||
|
this->LocalGenerator->GetIncludeFlags(lang, useResponseFile);
|
||||||
|
if(includeFlags.empty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(useResponseFile)
|
||||||
|
{
|
||||||
|
std::string name = "includes_";
|
||||||
|
name += lang;
|
||||||
|
name += ".rsp";
|
||||||
|
std::string arg = "@" +
|
||||||
|
this->CreateResponseFile(name.c_str(), includeFlags,
|
||||||
|
this->FlagFileDepends[lang]);
|
||||||
|
this->LocalGenerator->AppendFlags(flags, arg.c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->LocalGenerator->AppendFlags(flags, includeFlags.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
const char* cmMakefileTargetGenerator::GetFortranModuleDirectory()
|
const char* cmMakefileTargetGenerator::GetFortranModuleDirectory()
|
||||||
{
|
{
|
||||||
|
|
|
@ -146,6 +146,8 @@ protected:
|
||||||
bool useResponseFile, std::string& buildObjs,
|
bool useResponseFile, std::string& buildObjs,
|
||||||
std::vector<std::string>& makefile_depends);
|
std::vector<std::string>& makefile_depends);
|
||||||
|
|
||||||
|
void AddIncludeFlags(std::string& flags, const char* lang);
|
||||||
|
|
||||||
virtual void CloseFileStreams();
|
virtual void CloseFileStreams();
|
||||||
void RemoveForbiddenFlags(const char* flagVar, const char* linkLang,
|
void RemoveForbiddenFlags(const char* flagVar, const char* linkLang,
|
||||||
std::string& linkFlags);
|
std::string& linkFlags);
|
||||||
|
@ -177,6 +179,8 @@ protected:
|
||||||
// the stream for the flag file
|
// the stream for the flag file
|
||||||
std::string FlagFileNameFull;
|
std::string FlagFileNameFull;
|
||||||
cmGeneratedFileStream *FlagFileStream;
|
cmGeneratedFileStream *FlagFileStream;
|
||||||
|
class StringList: public std::vector<std::string> {};
|
||||||
|
std::map<cmStdString, StringList> FlagFileDepends;
|
||||||
|
|
||||||
// the stream for the info file
|
// the stream for the info file
|
||||||
std::string InfoFileNameFull;
|
std::string InfoFileNameFull;
|
||||||
|
|
Loading…
Reference in New Issue