summaryrefslogtreecommitdiffstats
path: root/Source/cmQtAutomoc.cxx
diff options
context:
space:
mode:
authorAlex Neundorf <neundorf@kde.org>2011-11-10 19:56:46 (GMT)
committerAlex Neundorf <neundorf@kde.org>2011-11-10 21:12:03 (GMT)
commit72428228970b8b7da54a3c98a36eca6810c46bb5 (patch)
tree7f61ddd3bd884fbea8320cccddb1c7e9ef8a0123 /Source/cmQtAutomoc.cxx
parentd08bc32bc29078764fc44fd3809eeda527e7017f (diff)
downloadCMake-72428228970b8b7da54a3c98a36eca6810c46bb5.zip
CMake-72428228970b8b7da54a3c98a36eca6810c46bb5.tar.gz
CMake-72428228970b8b7da54a3c98a36eca6810c46bb5.tar.bz2
automoc: rework the checking for the matching header, to give better warnings
Alex
Diffstat (limited to 'Source/cmQtAutomoc.cxx')
-rw-r--r--Source/cmQtAutomoc.cxx77
1 files changed, 35 insertions, 42 deletions
diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx
index 15a034c..3dc515e 100644
--- a/Source/cmQtAutomoc.cxx
+++ b/Source/cmQtAutomoc.cxx
@@ -545,64 +545,57 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
// finding the correct header, so we need to remove the moc_ part
basename = basename.substr(4);
- bool headerFound = false;
+ std::string mocSubDir;
+ if (currentMoc.find_first_of('/') != std::string::npos)
+ {
+ mocSubDir = absPath
+ + cmsys::SystemTools::GetFilenamePath(currentMoc) + '/';
+ }
+
+ std::string headerToMoc;
for(std::list<std::string>::const_iterator ext =
headerExtensions.begin();
ext != headerExtensions.end();
++ext)
{
- const std::string &sourceFilePath = absPath + basename + (*ext);
+ std::string sourceFilePath = absPath + basename + (*ext);
if (cmsys::SystemTools::FileExists(sourceFilePath.c_str()))
{
- headerFound = true;
- includedMocs[sourceFilePath] = currentMoc;
+ headerToMoc = sourceFilePath;
break;
}
- }
- if (!headerFound)
- {
- // the moc file is in a subdir => look for the header in the
- // same subdir
- if (currentMoc.find_first_of('/') != std::string::npos)
+ if (!mocSubDir.empty())
{
- const std::string &filepath = absPath
- + cmsys::SystemTools::GetFilenamePath(currentMoc)
- + '/' + basename;
-
- for(std::list<std::string>::const_iterator ext =
- headerExtensions.begin();
- ext != headerExtensions.end();
- ++ext)
- {
- const std::string &sourceFilePath = filepath + (*ext);
- if (cmsys::SystemTools::FileExists(sourceFilePath.c_str()))
- {
- headerFound = true;
- includedMocs[sourceFilePath] = currentMoc;
- break;
- }
- }
- if (!headerFound)
+ sourceFilePath = mocSubDir + basename + (*ext);
+ if (cmsys::SystemTools::FileExists(sourceFilePath.c_str()))
{
- std::cerr << "AUTOMOC: The file \"" << absFilename
- << "\" includes the moc file \"" << currentMoc
- << "\", but neither \"" << absPath << basename
- << '{' << this->Join(headerExtensions, ',')
- << "}\" nor \"" << filepath << '{'
- << this->Join(headerExtensions, ',') << '}'
- << "\" exist." << std::endl;
- ::exit(EXIT_FAILURE);
+ headerToMoc = sourceFilePath;
+ break;
}
}
+ }
+
+ if (!headerToMoc.empty())
+ {
+ includedMocs[headerToMoc] = currentMoc;
+ }
+ else
+ {
+ std::cerr << "AUTOMOC: The file \"" << absFilename
+ << "\" includes the moc file \"" << currentMoc
+ << "\", but could not find header \"" << basename
+ << '{' << this->Join(headerExtensions, ',') << "}\" ";
+ if (mocSubDir.empty())
+ {
+ std::cerr << "in " << absPath << std::endl;
+ }
else
{
- std::cerr << "AUTOMOC: The file \"" << absFilename
- << "\" includes the moc file \"" << currentMoc
- << "\", but \"" << absPath << basename << '{'
- << this->Join(headerExtensions, ',') << '}'
- << "\" does not exist." << std::endl;
- ::exit(EXIT_FAILURE);
+ std::cerr << "neither in " << absPath
+ << " nor in " << mocSubDir << std::endl;
}
+
+ ::exit(EXIT_FAILURE);
}
}
else