From 34ba5c53481e7f2101dafa735504cb98f94ec6db Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 20 Jul 2016 14:39:38 -0400 Subject: Makefile: Factor out response file checks into common helper Factor CMAKE__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. --- Source/cmMakefileExecutableTargetGenerator.cxx | 25 ++++---------------- Source/cmMakefileLibraryTargetGenerator.cxx | 25 ++++---------------- Source/cmMakefileTargetGenerator.cxx | 32 ++++++++++++++++++++++++++ Source/cmMakefileTargetGenerator.h | 3 +++ 4 files changed, 43 insertions(+), 42 deletions(-) diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 8730ccd..3b8bf5a 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -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. { diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 7de2db0..68f8ff1 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -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; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 00b1219..abf50d6 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -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& makefile_depends) diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 4284549..29b8887 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -151,6 +151,9 @@ protected: std::string CreateResponseFile(const char* name, std::string const& options, std::vector& 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& makefile_depends, -- cgit v0.12