mirror of
https://github.com/Kitware/CMake.git
synced 2026-03-09 01:09:30 -05:00
AUTOUIC: Fix internal paths of generated ui_foo.h files
For every file foo.ui we generate a ui_foo.h file in
${target}_autogen/include or ${target}_autogen/include_$<CONFIG> in the
multi-config case. Even .ui files in subdirectories are handled this
way. That means, .ui files with the same base name will conflict in a
target.
However, for .ui files in subdirectories we added generated sources with
the nonexistent path ${target}_autogen/include/subdir/ui_foo.h. This
patch fixes that.
Also, CMake will now yield an error if a target has multiple .ui files
with the same base name.
Fixes #23523
This commit is contained in:
committed by
Joerg Bornemann
parent
c97fd9f065
commit
10668f26c9
@@ -906,6 +906,7 @@ bool cmQtAutoGenInitializer::InitScanFiles()
|
|||||||
// The reason is that their file names might be discovered from source files
|
// The reason is that their file names might be discovered from source files
|
||||||
// at generation time.
|
// at generation time.
|
||||||
if (this->MocOrUicEnabled()) {
|
if (this->MocOrUicEnabled()) {
|
||||||
|
std::unordered_set<std::string> addedFiles;
|
||||||
for (const auto& sf : this->Makefile->GetSourceFiles()) {
|
for (const auto& sf : this->Makefile->GetSourceFiles()) {
|
||||||
// sf->GetExtension() is only valid after sf->ResolveFullPath() ...
|
// sf->GetExtension() is only valid after sf->ResolveFullPath() ...
|
||||||
// Since we're iterating over source files that might be not in the
|
// Since we're iterating over source files that might be not in the
|
||||||
@@ -947,25 +948,28 @@ bool cmQtAutoGenInitializer::InitScanFiles()
|
|||||||
cmExpandedList(uicOpts));
|
cmExpandedList(uicOpts));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto uiHeaderRelativePath = cmSystemTools::RelativePath(
|
auto uiHeaderFileName = cmStrCat(
|
||||||
this->LocalGen->GetCurrentSourceDirectory(),
|
"ui_"_s, cmSystemTools::GetFilenameWithoutLastExtension(fullPath),
|
||||||
cmSystemTools::GetFilenamePath(fullPath));
|
".h"_s);
|
||||||
|
|
||||||
// Avoid creating a path containing adjacent slashes
|
// .ui files with the same base name will conflict. Yield an error.
|
||||||
if (!uiHeaderRelativePath.empty() &&
|
{
|
||||||
uiHeaderRelativePath.back() != '/') {
|
auto insertResult = addedFiles.insert(uiHeaderFileName);
|
||||||
uiHeaderRelativePath += '/';
|
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(), "."));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto uiHeaderFilePath = cmStrCat(
|
|
||||||
'/', uiHeaderRelativePath, "ui_"_s,
|
|
||||||
cmSystemTools::GetFilenameWithoutLastExtension(fullPath), ".h"_s);
|
|
||||||
|
|
||||||
ConfigString uiHeader;
|
ConfigString uiHeader;
|
||||||
std::string uiHeaderGenex;
|
std::string uiHeaderGenex;
|
||||||
this->ConfigFileNamesAndGenex(
|
this->ConfigFileNamesAndGenex(
|
||||||
uiHeader, uiHeaderGenex, cmStrCat(this->Dir.Build, "/include"_s),
|
uiHeader, uiHeaderGenex, cmStrCat(this->Dir.Build, "/include"_s),
|
||||||
uiHeaderFilePath);
|
cmStrCat("/"_s, uiHeaderFileName));
|
||||||
|
|
||||||
this->Uic.UiHeaders.emplace_back(
|
this->Uic.UiHeaders.emplace_back(
|
||||||
std::make_pair(uiHeader, uiHeaderGenex));
|
std::make_pair(uiHeader, uiHeaderGenex));
|
||||||
|
|||||||
Reference in New Issue
Block a user