summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-07-22 11:48:29 -0400
committerBrad King <brad.king@kitware.com>2022-07-22 11:48:40 -0400
commit778aaf6fdc10fdf961b3cfbbfe770adf2a3f2873 (patch)
treec5b9fb1095fb4781468e1df0055fcbf776562341
parent9306a5ab28af6bb6dc2b933339ccc66764f44b12 (diff)
downloadcmake-778aaf6fdc10fdf961b3cfbbfe770adf2a3f2873.tar.gz
AUTOUIC: Revert "Fix internal paths of generated ui_foo.h files"
Revert commit 10668f26c9 (AUTOUIC: Fix internal paths of generated ui_foo.h files, 2022-05-21, v3.24.0-rc3~20^2). It broke some existing projects that use more than one `.ui` file of the same name. Fixes: #23759 Issue: #23523
-rw-r--r--Source/cmQtAutoGenInitializer.cxx28
1 files changed, 12 insertions, 16 deletions
diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx
index 1514a8aced..40f3ab58d1 100644
--- a/Source/cmQtAutoGenInitializer.cxx
+++ b/Source/cmQtAutoGenInitializer.cxx
@@ -909,7 +909,6 @@ bool cmQtAutoGenInitializer::InitScanFiles()
// The reason is that their file names might be discovered from source files
// at generation time.
if (this->MocOrUicEnabled()) {
- std::unordered_set<std::string> addedFiles;
for (const auto& sf : this->Makefile->GetSourceFiles()) {
// sf->GetExtension() is only valid after sf->ResolveFullPath() ...
// Since we're iterating over source files that might be not in the
@@ -951,28 +950,25 @@ bool cmQtAutoGenInitializer::InitScanFiles()
cmExpandedList(uicOpts));
}
- auto uiHeaderFileName = cmStrCat(
- "ui_"_s, cmSystemTools::GetFilenameWithoutLastExtension(fullPath),
- ".h"_s);
+ auto uiHeaderRelativePath = cmSystemTools::RelativePath(
+ this->LocalGen->GetCurrentSourceDirectory(),
+ cmSystemTools::GetFilenamePath(fullPath));
- // .ui files with the same base name will conflict. Yield an error.
- {
- auto insertResult = addedFiles.insert(uiHeaderFileName);
- if (!insertResult.second) {
- this->Makefile->IssueMessage(
- MessageType::FATAL_ERROR,
- cmStrCat("More than one .ui file with the name "_s,
- cmSystemTools::GetFilenameName(fullPath),
- " was found in the sources for target "_s,
- this->GenTarget->GetName(), "."));
- }
+ // Avoid creating a path containing adjacent slashes
+ if (!uiHeaderRelativePath.empty() &&
+ uiHeaderRelativePath.back() != '/') {
+ uiHeaderRelativePath += '/';
}
+ auto uiHeaderFilePath = cmStrCat(
+ '/', uiHeaderRelativePath, "ui_"_s,
+ cmSystemTools::GetFilenameWithoutLastExtension(fullPath), ".h"_s);
+
ConfigString uiHeader;
std::string uiHeaderGenex;
this->ConfigFileNamesAndGenex(
uiHeader, uiHeaderGenex, cmStrCat(this->Dir.Build, "/include"_s),
- cmStrCat("/"_s, uiHeaderFileName));
+ uiHeaderFilePath);
this->Uic.UiHeaders.emplace_back(
std::make_pair(uiHeader, uiHeaderGenex));