Skip to content
Snippets Groups Projects
Commit 34ba5c53 authored by Brad King's avatar Brad King
Browse files

Makefile: Factor out response file checks into common helper

Factor CMAKE_<LANG>_USE_RESPONSE_FILE_FOR_{OBJECTS,LIBRARIES} lookup out
into a common helper.  Use a separate helper for each because more
specific logic may be added to each later.
parent df14a98e
Branches
Tags
No related merge requests found
......@@ -277,27 +277,10 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
}
}
// Select whether to use a response file for objects.
bool useResponseFileForObjects = false;
{
std::string responseVar = "CMAKE_";
responseVar += linkLanguage;
responseVar += "_USE_RESPONSE_FILE_FOR_OBJECTS";
if (this->Makefile->IsOn(responseVar)) {
useResponseFileForObjects = true;
}
}
// Select whether to use a response file for libraries.
bool useResponseFileForLibs = false;
{
std::string responseVar = "CMAKE_";
responseVar += linkLanguage;
responseVar += "_USE_RESPONSE_FILE_FOR_LIBRARIES";
if (this->Makefile->IsOn(responseVar)) {
useResponseFileForLibs = true;
}
}
bool useResponseFileForObjects =
this->CheckUseResponseFileForObjects(linkLanguage);
bool const useResponseFileForLibs =
this->CheckUseResponseFileForLibraries(linkLanguage);
// Expand the rule variables.
{
......
......@@ -429,27 +429,10 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
// Determine whether a link script will be used.
bool useLinkScript = this->GlobalGenerator->GetUseLinkScript();
// Select whether to use a response file for objects.
bool useResponseFileForObjects = false;
{
std::string responseVar = "CMAKE_";
responseVar += linkLanguage;
responseVar += "_USE_RESPONSE_FILE_FOR_OBJECTS";
if (this->Makefile->IsOn(responseVar)) {
useResponseFileForObjects = true;
}
}
// Select whether to use a response file for libraries.
bool useResponseFileForLibs = false;
{
std::string responseVar = "CMAKE_";
responseVar += linkLanguage;
responseVar += "_USE_RESPONSE_FILE_FOR_LIBRARIES";
if (this->Makefile->IsOn(responseVar)) {
useResponseFileForLibs = true;
}
}
bool useResponseFileForObjects =
this->CheckUseResponseFileForObjects(linkLanguage);
bool const useResponseFileForLibs =
this->CheckUseResponseFileForLibraries(linkLanguage);
// For static libraries there might be archiving rules.
bool haveStaticLibraryRule = false;
......
......@@ -1447,6 +1447,38 @@ void cmMakefileTargetGenerator::CreateLinkScript(
makefile_depends.push_back(linkScriptName);
}
bool cmMakefileTargetGenerator::CheckUseResponseFileForObjects(
std::string const& l) const
{
// Check for an explicit setting one way or the other.
std::string const responseVar =
"CMAKE_" + l + "_USE_RESPONSE_FILE_FOR_OBJECTS";
if (const char* val = this->Makefile->GetDefinition(responseVar)) {
if (*val) {
return cmSystemTools::IsOn(val);
}
}
// We do not need a response file for objects.
return false;
}
bool cmMakefileTargetGenerator::CheckUseResponseFileForLibraries(
std::string const& l) const
{
// Check for an explicit setting one way or the other.
std::string const responseVar =
"CMAKE_" + l + "_USE_RESPONSE_FILE_FOR_LIBRARIES";
if (const char* val = this->Makefile->GetDefinition(responseVar)) {
if (*val) {
return cmSystemTools::IsOn(val);
}
}
// We do not need a response file for libraries.
return false;
}
std::string cmMakefileTargetGenerator::CreateResponseFile(
const char* name, std::string const& options,
std::vector<std::string>& makefile_depends)
......
......@@ -151,6 +151,9 @@ protected:
std::string CreateResponseFile(const char* name, std::string const& options,
std::vector<std::string>& makefile_depends);
bool CheckUseResponseFileForObjects(std::string const& l) const;
bool CheckUseResponseFileForLibraries(std::string const& l) const;
/** Create list of flags for link libraries. */
void CreateLinkLibs(std::string& linkLibs, bool relink, bool useResponseFile,
std::vector<std::string>& makefile_depends,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment