summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2017-02-15 11:53:39 (GMT)
committerBrad King <brad.king@kitware.com>2017-02-21 15:12:49 (GMT)
commit3cc42863a43cd4256efdeb2eda2d235d5533bad9 (patch)
tree168c3499df470dfc38854770ba088dc426c564c9
parent074534a56d4d6146c2389fd256299197e5bad027 (diff)
downloadCMake-3cc42863a43cd4256efdeb2eda2d235d5533bad9.zip
CMake-3cc42863a43cd4256efdeb2eda2d235d5533bad9.tar.gz
CMake-3cc42863a43cd4256efdeb2eda2d235d5533bad9.tar.bz2
Autogen: Overhaul moc include list generation
-rw-r--r--Source/cmQtAutoGenerators.cxx102
-rw-r--r--Source/cmQtAutoGenerators.h3
2 files changed, 56 insertions, 49 deletions
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index a167705..f67543f 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -7,6 +7,7 @@
#include <cmConfigure.h>
#include <cmsys/FStream.hxx>
#include <cmsys/Terminal.h>
+#include <list>
#include <sstream>
#include <stdlib.h>
#include <string.h>
@@ -539,58 +540,65 @@ void cmQtAutoGenerators::Init()
this->ProjectSourceDir,
this->ProjectBinaryDir);
- std::vector<std::string> incPaths;
- cmSystemTools::ExpandListArgument(this->MocInfoIncludes, incPaths);
-
- std::set<std::string> frameworkPaths;
- for (std::vector<std::string>::const_iterator it = incPaths.begin();
- it != incPaths.end(); ++it) {
- const std::string& path = *it;
- this->MocIncludes.push_back("-I" + path);
- if (cmHasLiteralSuffix(path, ".framework/Headers")) {
- // Go up twice to get to the framework root
- std::vector<std::string> pathComponents;
- cmsys::SystemTools::SplitPath(path, pathComponents);
- std::string frameworkPath = cmsys::SystemTools::JoinPath(
- pathComponents.begin(), pathComponents.end() - 2);
- frameworkPaths.insert(frameworkPath);
+ // Compose moc includes list
+ std::list<std::string> mocIncludes;
+ {
+ std::set<std::string> frameworkPaths;
+ {
+ std::vector<std::string> incPaths;
+ cmSystemTools::ExpandListArgument(this->MocInfoIncludes, incPaths);
+ for (std::vector<std::string>::const_iterator it = incPaths.begin();
+ it != incPaths.end(); ++it) {
+ const std::string& path = *it;
+ mocIncludes.push_back("-I" + path);
+ // Extract framework path
+ if (cmHasLiteralSuffix(path, ".framework/Headers")) {
+ // Go up twice to get to the framework root
+ std::vector<std::string> pathComponents;
+ cmsys::SystemTools::SplitPath(path, pathComponents);
+ std::string frameworkPath = cmsys::SystemTools::JoinPath(
+ pathComponents.begin(), pathComponents.end() - 2);
+ frameworkPaths.insert(frameworkPath);
+ }
+ }
+ }
+ // 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);
}
}
-
- for (std::set<std::string>::const_iterator it = frameworkPaths.begin();
- it != frameworkPaths.end(); ++it) {
- this->MocIncludes.push_back("-F");
- this->MocIncludes.push_back(*it);
- }
-
if (this->IncludeProjectDirsBefore) {
- const std::string binDir = "-I" + this->ProjectBinaryDir;
- const std::string srcDir = "-I" + this->ProjectSourceDir;
-
- std::list<std::string> sortedMocIncludes;
- std::list<std::string>::iterator it = this->MocIncludes.begin();
- while (it != this->MocIncludes.end()) {
- if (cmsys::SystemTools::StringStartsWith(*it, binDir.c_str())) {
- sortedMocIncludes.push_back(*it);
- it = this->MocIncludes.erase(it);
- } else {
- ++it;
- }
- }
- it = this->MocIncludes.begin();
- while (it != this->MocIncludes.end()) {
- if (cmsys::SystemTools::StringStartsWith(*it, srcDir.c_str())) {
- sortedMocIncludes.push_back(*it);
- it = this->MocIncludes.erase(it);
- } else {
- ++it;
+ // 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;
+ }
+ }
}
}
- sortedMocIncludes.insert(sortedMocIncludes.end(),
- this->MocIncludes.begin(),
- this->MocIncludes.end());
- this->MocIncludes = sortedMocIncludes;
- }
+ // 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(cmMakefile* makefile)
diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h
index e60320b..f6caed9 100644
--- a/Source/cmQtAutoGenerators.h
+++ b/Source/cmQtAutoGenerators.h
@@ -7,7 +7,6 @@
#include <cmFilePathChecksum.h>
#include <cmsys/RegularExpression.hxx>
-#include <list>
#include <map>
#include <set>
#include <string>
@@ -146,7 +145,7 @@ private:
std::string MocInfoIncludes;
std::string OutMocCppFilenameRel;
std::string OutMocCppFilenameAbs;
- std::list<std::string> MocIncludes;
+ std::vector<std::string> MocIncludes;
std::vector<std::string> MocDefinitions;
std::vector<std::string> MocOptions;
// - Uic