mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-16 20:21:41 -06:00
Autogen: Search moc includes in include directories
This commit is contained in:
committed by
Brad King
parent
175c890044
commit
41fb64e719
@@ -773,7 +773,8 @@ bool cmQtAutoGenerators::ParseContentForMoc(
|
|||||||
cmsys::SystemTools::GetFilenameWithoutLastExtension(incString);
|
cmsys::SystemTools::GetFilenameWithoutLastExtension(incString);
|
||||||
std::string incSubDir;
|
std::string incSubDir;
|
||||||
if (incString.find_first_of('/') != std::string::npos) {
|
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
|
// If the moc include is of the moc_foo.cpp style we expect
|
||||||
@@ -785,8 +786,8 @@ bool cmQtAutoGenerators::ParseContentForMoc(
|
|||||||
// Include: moc_FOO.cxx
|
// Include: moc_FOO.cxx
|
||||||
// Remove the moc_ part
|
// Remove the moc_ part
|
||||||
const std::string incRealBasename = incBasename.substr(4);
|
const std::string incRealBasename = incBasename.substr(4);
|
||||||
const std::string headerToMoc = this->FindMatchingHeader(
|
const std::string headerToMoc =
|
||||||
scannedFileAbsPath, incRealBasename, incSubDir);
|
this->FindMocHeader(scannedFileAbsPath, incRealBasename, incSubDir);
|
||||||
if (!headerToMoc.empty()) {
|
if (!headerToMoc.empty()) {
|
||||||
mocsIncluded[headerToMoc] = incString;
|
mocsIncluded[headerToMoc] = incString;
|
||||||
if (relaxed && (incRealBasename == scannedFileBasename)) {
|
if (relaxed && (incRealBasename == scannedFileBasename)) {
|
||||||
@@ -814,8 +815,8 @@ bool cmQtAutoGenerators::ParseContentForMoc(
|
|||||||
ownDotMocIncluded = true;
|
ownDotMocIncluded = true;
|
||||||
} else {
|
} else {
|
||||||
// In relaxed mode try to find a header instead but issue a warning
|
// In relaxed mode try to find a header instead but issue a warning
|
||||||
const std::string headerToMoc = this->FindMatchingHeader(
|
const std::string headerToMoc =
|
||||||
scannedFileAbsPath, incBasename, incSubDir);
|
this->FindMocHeader(scannedFileAbsPath, incBasename, incSubDir);
|
||||||
if (!headerToMoc.empty()) {
|
if (!headerToMoc.empty()) {
|
||||||
// This is for KDE4 compatibility:
|
// This is for KDE4 compatibility:
|
||||||
fileToMoc = headerToMoc;
|
fileToMoc = headerToMoc;
|
||||||
@@ -1607,9 +1608,23 @@ bool cmQtAutoGenerators::FindHeader(std::string& header,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string cmQtAutoGenerators::FindMatchingHeader(
|
bool cmQtAutoGenerators::FindHeaderGlobal(
|
||||||
const std::string& basePath, const std::string& baseName,
|
std::string& header, const std::string& testBasePath) const
|
||||||
const std::string& subDir) 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;
|
std::string header;
|
||||||
do {
|
do {
|
||||||
@@ -1621,7 +1636,15 @@ std::string cmQtAutoGenerators::FindMatchingHeader(
|
|||||||
if (this->FindHeader(header, basePath + baseName)) {
|
if (this->FindHeader(header, basePath + baseName)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// Try include directories
|
||||||
|
if (this->FindHeaderGlobal(header, subDir + baseName)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
} while (false);
|
} while (false);
|
||||||
|
// Sanitize
|
||||||
|
if (!header.empty()) {
|
||||||
|
header = cmSystemTools::CollapseFullPath(header);
|
||||||
|
}
|
||||||
return header;
|
return header;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -118,9 +118,11 @@ private:
|
|||||||
bool MakeParentDirectory(const std::string& filename);
|
bool MakeParentDirectory(const std::string& filename);
|
||||||
|
|
||||||
bool FindHeader(std::string& header, const std::string& testBasePath) const;
|
bool FindHeader(std::string& header, const std::string& testBasePath) const;
|
||||||
std::string FindMatchingHeader(const std::string& basePath,
|
bool FindHeaderGlobal(std::string& header,
|
||||||
const std::string& baseName,
|
const std::string& testBasePath) const;
|
||||||
const std::string& subDir) const;
|
std::string FindMocHeader(const std::string& basePath,
|
||||||
|
const std::string& baseName,
|
||||||
|
const std::string& subDir) const;
|
||||||
bool FindInIncludeDirectories(std::string& file_n,
|
bool FindInIncludeDirectories(std::string& file_n,
|
||||||
const std::string& searchString) const;
|
const std::string& searchString) const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user