summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2017-02-16 21:03:43 (GMT)
committerBrad King <brad.king@kitware.com>2017-02-21 15:12:54 (GMT)
commit41fb64e719817ce877565e6e11198df2f7e7e63d (patch)
tree2317d87f03145cc956265a7137bd1570de1ea3a1
parent175c89004425cdbb151d4e85876e2a2076432f28 (diff)
downloadCMake-41fb64e719817ce877565e6e11198df2f7e7e63d.zip
CMake-41fb64e719817ce877565e6e11198df2f7e7e63d.tar.gz
CMake-41fb64e719817ce877565e6e11198df2f7e7e63d.tar.bz2
Autogen: Search moc includes in include directories
-rw-r--r--Source/cmQtAutoGenerators.cxx39
-rw-r--r--Source/cmQtAutoGenerators.h8
2 files changed, 36 insertions, 11 deletions
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index 0eda4bc..fcc49d4 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -773,7 +773,8 @@ bool cmQtAutoGenerators::ParseContentForMoc(
cmsys::SystemTools::GetFilenameWithoutLastExtension(incString);
std::string incSubDir;
if (incString.find_first_of('/') != std::string::npos) {
- incSubDir = cmsys::SystemTools::GetFilenamePath(incString) + '/';
+ incSubDir = cmsys::SystemTools::GetFilenamePath(incString);
+ incSubDir += '/';
}
// If the moc include is of the moc_foo.cpp style we expect
@@ -785,8 +786,8 @@ bool cmQtAutoGenerators::ParseContentForMoc(
// Include: moc_FOO.cxx
// Remove the moc_ part
const std::string incRealBasename = incBasename.substr(4);
- const std::string headerToMoc = this->FindMatchingHeader(
- scannedFileAbsPath, incRealBasename, incSubDir);
+ const std::string headerToMoc =
+ this->FindMocHeader(scannedFileAbsPath, incRealBasename, incSubDir);
if (!headerToMoc.empty()) {
mocsIncluded[headerToMoc] = incString;
if (relaxed && (incRealBasename == scannedFileBasename)) {
@@ -814,8 +815,8 @@ bool cmQtAutoGenerators::ParseContentForMoc(
ownDotMocIncluded = true;
} else {
// In relaxed mode try to find a header instead but issue a warning
- const std::string headerToMoc = this->FindMatchingHeader(
- scannedFileAbsPath, incBasename, incSubDir);
+ const std::string headerToMoc =
+ this->FindMocHeader(scannedFileAbsPath, incBasename, incSubDir);
if (!headerToMoc.empty()) {
// This is for KDE4 compatibility:
fileToMoc = headerToMoc;
@@ -1607,9 +1608,23 @@ bool cmQtAutoGenerators::FindHeader(std::string& header,
return false;
}
-std::string cmQtAutoGenerators::FindMatchingHeader(
- const std::string& basePath, const std::string& baseName,
- const std::string& subDir) const
+bool cmQtAutoGenerators::FindHeaderGlobal(
+ std::string& header, const std::string& testBasePath) const
+{
+ for (std::vector<std::string>::const_iterator iit =
+ this->MocIncludePaths.begin();
+ iit != this->MocIncludePaths.end(); ++iit) {
+ const std::string fullPath = ((*iit) + '/' + testBasePath);
+ if (FindHeader(header, fullPath)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+std::string cmQtAutoGenerators::FindMocHeader(const std::string& basePath,
+ const std::string& baseName,
+ const std::string& subDir) const
{
std::string header;
do {
@@ -1621,7 +1636,15 @@ std::string cmQtAutoGenerators::FindMatchingHeader(
if (this->FindHeader(header, basePath + baseName)) {
break;
}
+ // Try include directories
+ if (this->FindHeaderGlobal(header, subDir + baseName)) {
+ break;
+ }
} while (false);
+ // Sanitize
+ if (!header.empty()) {
+ header = cmSystemTools::CollapseFullPath(header);
+ }
return header;
}
diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h
index b3c7a3c..6c9c3a8 100644
--- a/Source/cmQtAutoGenerators.h
+++ b/Source/cmQtAutoGenerators.h
@@ -118,9 +118,11 @@ private:
bool MakeParentDirectory(const std::string& filename);
bool FindHeader(std::string& header, const std::string& testBasePath) const;
- std::string FindMatchingHeader(const std::string& basePath,
- const std::string& baseName,
- const std::string& subDir) const;
+ bool FindHeaderGlobal(std::string& header,
+ const std::string& testBasePath) const;
+ std::string FindMocHeader(const std::string& basePath,
+ const std::string& baseName,
+ const std::string& subDir) const;
bool FindInIncludeDirectories(std::string& file_n,
const std::string& searchString) const;