diff options
author | Brad King <brad.king@kitware.com> | 2016-02-18 15:07:56 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2016-02-18 15:07:56 (GMT) |
commit | 135a0df525851e6fd35efc74c4b86309dfc381de (patch) | |
tree | ba89f02b328add42dcc42f80cef4734471d5694a /Source | |
parent | ede2a6ea6b6ff201ea1b2e2f7943b301a28b1df5 (diff) | |
parent | 9beb2744d7685fca9cd5717308d4457dffdefcdc (diff) | |
download | CMake-135a0df525851e6fd35efc74c4b86309dfc381de.zip CMake-135a0df525851e6fd35efc74c4b86309dfc381de.tar.gz CMake-135a0df525851e6fd35efc74c4b86309dfc381de.tar.bz2 |
Merge topic 'automoc-src-per-dir'
9beb2744 Automoc: Fix support of files with the same name (#12873)
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmQtAutoGenerators.cxx | 35 |
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)) { |