diff options
author | Brad King <brad.king@kitware.com> | 2008-01-30 01:46:25 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2008-01-30 01:46:25 (GMT) |
commit | 66e0b4212fbbaaf3c5aa5af6a51aa3a5af002edf (patch) | |
tree | 6a18f76856cfe10f1e7be02d2b1cf41896a34cd6 /Source/cmMakefileTargetGenerator.cxx | |
parent | 44cf465ff5f768c96e8708eba35f31f296e78b1e (diff) | |
download | CMake-66e0b4212fbbaaf3c5aa5af6a51aa3a5af002edf.zip CMake-66e0b4212fbbaaf3c5aa5af6a51aa3a5af002edf.tar.gz CMake-66e0b4212fbbaaf3c5aa5af6a51aa3a5af002edf.tar.bz2 |
ENH: Added build rule variables CMAKE_<LANG>_ARCHIVE_CREATE, CMAKE_<LANG>_ARCHIVE_APPEND, and CMAKE_<LANG>_ARCHIVE_FINISH to support creation of static archive libraries out of a large number of objects. See bug #6284.
Diffstat (limited to 'Source/cmMakefileTargetGenerator.cxx')
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 107 |
1 files changed, 77 insertions, 30 deletions
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 0c550ef..3e8084c 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1200,49 +1200,96 @@ void cmMakefileTargetGenerator ::WriteObjectsString(std::string& buildObjs) { - std::string object; - const char* no_quoted = - this->Makefile->GetDefinition("CMAKE_NO_QUOTED_OBJECTS"); - const char* space = ""; - for(std::vector<std::string>::const_iterator i = this->Objects.begin(); - i != this->Objects.end(); ++i) + std::vector<std::string> objStrings; + this->WriteObjectsStrings(objStrings); + buildObjs = objStrings[0]; +} + +//---------------------------------------------------------------------------- +class cmMakefileTargetGeneratorObjectStrings +{ +public: + cmMakefileTargetGeneratorObjectStrings(std::vector<std::string>& strings, + cmMakefile* mf, + cmLocalUnixMakefileGenerator3* lg, + std::string::size_type limit): + Strings(strings), Makefile(mf), LocalGenerator(lg), LengthLimit(limit) { - if ( this->ExtraContent.find(i->c_str()) != this->ExtraContent.end() ) + this->NoQuotes = mf->IsOn("CMAKE_NO_QUOTED_OBJECTS"); + this->Space = ""; + } + void Feed(std::string const& obj) + { + // Construct the name of the next object. + if(this->NoQuotes) { - continue; + this->NextObject = + this->LocalGenerator->Convert(obj.c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::SHELL); } - buildObjs += space; - space = " "; - if(no_quoted) + else { - buildObjs += - this->Convert(i->c_str(), cmLocalGenerator::START_OUTPUT, - cmLocalGenerator::SHELL); + this->NextObject = + this->LocalGenerator->ConvertToQuotedOutputPath(obj.c_str()); } - else + + // Roll over to next string if the limit will be exceeded. + if(this->LengthLimit != std::string::npos && + (this->CurrentString.length() + 1 + this->NextObject.length() + > this->LengthLimit)) { - buildObjs += - this->LocalGenerator->ConvertToQuotedOutputPath(i->c_str()); + this->Strings.push_back(this->CurrentString); + this->CurrentString = ""; + this->Space = ""; } + + // Separate from previous object. + this->CurrentString += this->Space; + this->Space = " "; + + // Append this object. + this->CurrentString += this->NextObject; + } + void Done() + { + this->Strings.push_back(this->CurrentString); + } +private: + std::vector<std::string>& Strings; + cmMakefile* Makefile; + cmLocalUnixMakefileGenerator3* LocalGenerator; + std::string::size_type LengthLimit; + bool NoQuotes; + std::string CurrentString; + std::string NextObject; + const char* Space; +}; + +//---------------------------------------------------------------------------- +void +cmMakefileTargetGenerator +::WriteObjectsStrings(std::vector<std::string>& objStrings, + std::string::size_type limit) +{ + cmMakefileTargetGeneratorObjectStrings + helper(objStrings, this->Makefile, this->LocalGenerator, limit); + for(std::vector<std::string>::const_iterator i = this->Objects.begin(); + i != this->Objects.end(); ++i) + { + if ( this->ExtraContent.find(i->c_str()) != this->ExtraContent.end() ) + { + continue; + } + helper.Feed(*i); } for(std::vector<std::string>::const_iterator i = this->ExternalObjects.begin(); i != this->ExternalObjects.end(); ++i) { - buildObjs += space; - space = " "; - if(no_quoted) - { - buildObjs += - this->Convert(i->c_str(), cmLocalGenerator::START_OUTPUT, - cmLocalGenerator::SHELL); - } - else - { - buildObjs += - this->LocalGenerator->ConvertToQuotedOutputPath(i->c_str()); - } + helper.Feed(*i); } + helper.Done(); } //---------------------------------------------------------------------------- |