summaryrefslogtreecommitdiffstats
path: root/Source/cmQtAutoGenerators.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-07-21 13:08:43 (GMT)
committerBrad King <brad.king@kitware.com>2016-07-21 13:27:19 (GMT)
commit5e55d87bdc4d14507fec2bae7a41f3fb9498db1a (patch)
tree5836ad2a646a2ee22fc6a2ebd39f229f9338251b /Source/cmQtAutoGenerators.cxx
parente31084e65745f9dd422c6aff0a2ed4ada6918805 (diff)
downloadCMake-5e55d87bdc4d14507fec2bae7a41f3fb9498db1a.zip
CMake-5e55d87bdc4d14507fec2bae7a41f3fb9498db1a.tar.gz
CMake-5e55d87bdc4d14507fec2bae7a41f3fb9498db1a.tar.bz2
Autogen: Revert changes to generate moc/rcc in subdirectories
Revert these commits: * v3.6.0-rc1~134^2 Tests: QtAutogen: Same source name in different directories test, 2016-04-13 * v3.6.0-rc1~134^2~1 Autogen: Generate qrc_NAME.cpp files in subdirectories, 2016-04-19 * v3.6.0-rc1~134^2~2 Autogen: Generate not included moc files in subdirectories, 2016-04-19 They regress existing builds that depend on the paths/symbols generated previously. Another approach will be needed to solve the name collision problem they were intended to solve. Leave the error diagnostics for the colliding cases that were added in the same topic as the above commits because they provide a useful early failure in relevant cases. Fixes #16209.
Diffstat (limited to 'Source/cmQtAutoGenerators.cxx')
-rw-r--r--Source/cmQtAutoGenerators.cxx79
1 files changed, 15 insertions, 64 deletions
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index ac64397..3677a28 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -358,12 +358,11 @@ void cmQtAutoGenerators::WriteOldMocDefinitionsFile(
void cmQtAutoGenerators::Init()
{
- this->TargetBuildSubDir = this->TargetName;
- this->TargetBuildSubDir += ".dir/";
-
this->OutMocCppFilenameRel = this->TargetName;
this->OutMocCppFilenameRel += ".cpp";
- this->OutMocCppFilenameAbs = this->Builddir + this->OutMocCppFilenameRel;
+
+ this->OutMocCppFilename = this->Builddir;
+ this->OutMocCppFilename += this->OutMocCppFilenameRel;
std::vector<std::string> cdefList;
cmSystemTools::ExpandListArgument(this->MocCompileDefinitionsStr, cdefList);
@@ -440,7 +439,7 @@ static std::string ReadAll(const std::string& filename)
bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile)
{
- if (!cmsys::SystemTools::FileExists(this->OutMocCppFilenameAbs.c_str()) ||
+ if (!cmsys::SystemTools::FileExists(this->OutMocCppFilename.c_str()) ||
(this->OldCompileSettingsStr != this->CurrentCompileSettingsStr)) {
this->GenerateAll = true;
}
@@ -948,13 +947,12 @@ void cmQtAutoGenerators::ParseHeaders(
this->LogInfo(err.str());
}
+ const std::string basename =
+ cmsys::SystemTools::GetFilenameWithoutLastExtension(headerName);
+
+ const std::string currentMoc = "moc_" + basename + ".cpp";
std::string macroName;
if (requiresMocing(contents, macroName)) {
- const std::string parentDir =
- this->TargetBuildSubDir + this->SourceRelativePath(headerName);
- const std::string basename =
- cmsys::SystemTools::GetFilenameWithoutLastExtension(headerName);
- const std::string currentMoc = parentDir + "moc_" + basename + ".cpp";
notIncludedMocs[headerName] = currentMoc;
}
}
@@ -1032,7 +1030,7 @@ bool cmQtAutoGenerators::GenerateMocFiles(
// check if we even need to update _automoc.cpp
if (!automocCppChanged) {
// compare contents of the _automoc.cpp file
- const std::string oldContents = ReadAll(this->OutMocCppFilenameAbs);
+ const std::string oldContents = ReadAll(this->OutMocCppFilename);
if (oldContents == automocSource) {
// nothing changed: don't touch the _automoc.cpp file
if (this->Verbose) {
@@ -1055,7 +1053,7 @@ bool cmQtAutoGenerators::GenerateMocFiles(
}
{
cmsys::ofstream outfile;
- outfile.open(this->OutMocCppFilenameAbs.c_str(), std::ios::trunc);
+ outfile.open(this->OutMocCppFilename.c_str(), std::ios::trunc);
outfile << automocSource;
outfile.close();
}
@@ -1264,10 +1262,8 @@ bool cmQtAutoGenerators::GenerateQrcFiles()
if (ext == ".qrc") {
std::string basename =
cmsys::SystemTools::GetFilenameWithoutLastExtension(*si);
- std::string qrcOutputFile = this->TargetBuildSubDir +
- this->SourceRelativePath(*si) + "qrc_" + basename + ".cpp";
- // std::string qrcOutputFile = "CMakeFiles/" + this->OriginTargetName
- // + ".dir/qrc_" + basename + ".cpp";
+ std::string qrcOutputFile = "CMakeFiles/" + this->OriginTargetName +
+ ".dir/qrc_" + basename + ".cpp";
qrcGenMap[*si] = qrcOutputFile;
}
}
@@ -1302,10 +1298,8 @@ bool cmQtAutoGenerators::GenerateQrcFiles()
bool cmQtAutoGenerators::GenerateQrc(const std::string& qrcInputFile,
const std::string& qrcOutputFile)
{
- std::string relName = this->SourceRelativePath(qrcInputFile);
- std::replace(relName.begin(), relName.end(), '/', '_');
- relName += cmsys::SystemTools::GetFilenameWithoutLastExtension(qrcInputFile);
-
+ const std::string basename =
+ cmsys::SystemTools::GetFilenameWithoutLastExtension(qrcInputFile);
const ::std::string qrcBuildFile = this->Builddir + qrcOutputFile;
int sourceNewerThanQrc = 0;
@@ -1332,7 +1326,7 @@ bool cmQtAutoGenerators::GenerateQrc(const std::string& qrcInputFile,
}
command.push_back("-name");
- command.push_back(relName);
+ command.push_back(basename);
command.push_back("-o");
command.push_back(qrcBuildFile);
command.push_back(qrcInputFile);
@@ -1357,49 +1351,6 @@ bool cmQtAutoGenerators::GenerateQrc(const std::string& qrcInputFile,
return true;
}
-std::string cmQtAutoGenerators::SourceRelativePath(const std::string& filename)
-{
- std::string pathRel;
-
- // Test if the file is child to any of the known directories
- {
- std::string fileNameReal = cmsys::SystemTools::GetRealPath(filename);
- std::string parentDirectory;
- bool match(false);
- {
- const ::std::string* testDirs[4];
- testDirs[0] = &(this->Srcdir);
- testDirs[1] = &(this->Builddir);
- testDirs[2] = &(this->ProjectSourceDir);
- testDirs[3] = &(this->ProjectBinaryDir);
- for (int ii = 0; ii != sizeof(testDirs) / sizeof(const ::std::string*);
- ++ii) {
- const ::std::string testDir =
- cmsys::SystemTools::GetRealPath(*(testDirs[ii]));
- if (cmsys::SystemTools::IsSubDirectory(fileNameReal, testDir)) {
- parentDirectory = testDir;
- match = true;
- break;
- }
- }
- }
- // Use root as fallback parent directory
- if (!match) {
- cmsys::SystemTools::SplitPathRootComponent(fileNameReal,
- &parentDirectory);
- }
- pathRel = cmsys::SystemTools::RelativePath(
- parentDirectory, cmsys::SystemTools::GetParentDirectory(fileNameReal));
- }
-
- // Sanitize relative path
- if (!pathRel.empty()) {
- pathRel += '/';
- cmSystemTools::ReplaceString(pathRel, "..", "__");
- }
- return pathRel;
-}
-
/**
* @brief Collects name collisions as output/input pairs
* @return True if there were collisions