summaryrefslogtreecommitdiffstats
path: root/Source/cmQtAutoGenerators.cxx
diff options
context:
space:
mode:
authorMariusz Pluciński <mplucinski@mplucinski.com>2016-02-13 10:30:31 (GMT)
committerBrad King <brad.king@kitware.com>2016-02-16 15:45:19 (GMT)
commit9beb2744d7685fca9cd5717308d4457dffdefcdc (patch)
tree7a7771944d85d24eeb3ec9328bbb2f42e6df151c /Source/cmQtAutoGenerators.cxx
parent8dfb6f8b372b159c050b6ea5e16b4e44dd9ed095 (diff)
downloadCMake-9beb2744d7685fca9cd5717308d4457dffdefcdc.zip
CMake-9beb2744d7685fca9cd5717308d4457dffdefcdc.tar.gz
CMake-9beb2744d7685fca9cd5717308d4457dffdefcdc.tar.bz2
Automoc: Fix support of files with the same name (#12873)
Diffstat (limited to 'Source/cmQtAutoGenerators.cxx')
-rw-r--r--Source/cmQtAutoGenerators.cxx35
1 files changed, 32 insertions, 3 deletions
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index b16eccd..226ab43 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -1104,10 +1104,39 @@ void cmQtAutoGenerators::ParseHeaders(const std::set<std::string>& absHeaders,
std::cout << "AUTOGEN: Checking " << headerName << std::endl;
}
- const std::string basename = cmsys::SystemTools::
- GetFilenameWithoutLastExtension(headerName);
+ std::string headerDirectory;
+ if (cmsys::SystemTools::IsSubDirectory(headerName,
+ this->ProjectSourceDir))
+ {
+ headerDirectory = this->ProjectSourceDir;
+ }
+ else if (cmsys::SystemTools::IsSubDirectory(headerName,
+ this->ProjectBinaryDir))
+ {
+ headerDirectory = this->ProjectBinaryDir;
+ }
+ else
+ {
+ cmsys::SystemTools::SplitPathRootComponent(headerName,
+ &headerDirectory);
+ }
+
+ std::string baseHeaderName =
+ cmsys::SystemTools::GetFilenameWithoutLastExtension(headerName);
+
+ headerDirectory = cmsys::SystemTools::RelativePath(
+ headerDirectory, cmsys::SystemTools::GetParentDirectory(headerName));
+
+ if (!headerDirectory.empty())
+ {
+ headerDirectory += "/";
+ }
+
+ std::string mocName = headerDirectory + baseHeaderName;
+
+ cmSystemTools::ReplaceString(mocName, "/", "_");
- const std::string currentMoc = "moc_" + basename + ".cpp";
+ const std::string currentMoc = "moc_" + mocName + ".cpp";
std::string macroName;
if (requiresMocing(contents, macroName))
{