diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2017-02-16 20:09:04 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-02-21 15:12:53 (GMT) |
commit | 175c89004425cdbb151d4e85876e2a2076432f28 (patch) | |
tree | 225f59fb45ebbb9b3cef76806cae2ba2e63d01bc /Source/cmQtAutoGenerators.cxx | |
parent | 80a007534f6287cd2e88c1b8fd72b68fc688da4e (diff) | |
download | CMake-175c89004425cdbb151d4e85876e2a2076432f28.zip CMake-175c89004425cdbb151d4e85876e2a2076432f28.tar.gz CMake-175c89004425cdbb151d4e85876e2a2076432f28.tar.bz2 |
Autogen: Sort includes before composing include options
Diffstat (limited to 'Source/cmQtAutoGenerators.cxx')
-rw-r--r-- | Source/cmQtAutoGenerators.cxx | 67 |
1 files changed, 33 insertions, 34 deletions
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 62fbe18..0eda4bc 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -510,15 +510,44 @@ void cmQtAutoGenerators::Init(cmMakefile* makefile) // Acquire header extensions this->HeaderExtensions = makefile->GetCMakeInstance()->GetHeaderExtensions(); + // Sort include directories on demand + if (this->IncludeProjectDirsBefore) { + // Move strings to temporary list + std::list<std::string> includes; + includes.insert(includes.end(), this->MocIncludePaths.begin(), + this->MocIncludePaths.end()); + this->MocIncludePaths.clear(); + this->MocIncludePaths.reserve(includes.size()); + // Append project directories only + { + const char* movePaths[2] = { this->ProjectBinaryDir.c_str(), + this->ProjectSourceDir.c_str() }; + for (const char* const* mpit = cmArrayBegin(movePaths); + mpit != cmArrayEnd(movePaths); ++mpit) { + std::list<std::string>::iterator it = includes.begin(); + while (it != includes.end()) { + const std::string& path = *it; + if (cmsys::SystemTools::StringStartsWith(path, *mpit)) { + this->MocIncludePaths.push_back(path); + it = includes.erase(it); + } else { + ++it; + } + } + } + } + // Append remaining directories + this->MocIncludePaths.insert(this->MocIncludePaths.end(), includes.begin(), + includes.end()); + } // Compose moc includes list - std::list<std::string> mocIncludes; { std::set<std::string> frameworkPaths; for (std::vector<std::string>::const_iterator it = this->MocIncludePaths.begin(); it != this->MocIncludePaths.end(); ++it) { const std::string& path = *it; - mocIncludes.push_back("-I" + path); + this->MocIncludes.push_back("-I" + path); // Extract framework path if (cmHasLiteralSuffix(path, ".framework/Headers")) { // Go up twice to get to the framework root @@ -532,40 +561,10 @@ void cmQtAutoGenerators::Init(cmMakefile* makefile) // Append framework includes for (std::set<std::string>::const_iterator it = frameworkPaths.begin(); it != frameworkPaths.end(); ++it) { - mocIncludes.push_back("-F"); - mocIncludes.push_back(*it); + this->MocIncludes.push_back("-F"); + this->MocIncludes.push_back(*it); } } - if (this->IncludeProjectDirsBefore) { - // Extract project includes - std::vector<std::string> mocSortedIncludes; - { - std::vector<std::string> movePaths; - movePaths.push_back("-I" + this->ProjectBinaryDir); - movePaths.push_back("-I" + this->ProjectSourceDir); - - for (std::vector<std::string>::const_iterator mpit = movePaths.begin(); - mpit != movePaths.end(); ++mpit) { - std::list<std::string>::iterator it = mocIncludes.begin(); - while (it != mocIncludes.end()) { - const std::string& path = *it; - if (cmsys::SystemTools::StringStartsWith(path, mpit->c_str())) { - mocSortedIncludes.push_back(path); - it = mocIncludes.erase(it); - } else { - ++it; - } - } - } - } - // Place extracted includes at the begin - this->MocIncludes.insert(this->MocIncludes.end(), - mocSortedIncludes.begin(), - mocSortedIncludes.end()); - } - // Append remaining includes - this->MocIncludes.insert(this->MocIncludes.end(), mocIncludes.begin(), - mocIncludes.end()); } bool cmQtAutoGenerators::RunAutogen() |