diff options
author | Brad King <brad.king@kitware.com> | 2021-07-26 13:34:23 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-07-26 13:34:51 (GMT) |
commit | 98d813b92c26f0c93cefe21fe7768ca4f73d2d9a (patch) | |
tree | 497bf6706d28cba99d699ceaa5eaa310a33358bd /Source/cmQtAutoGenInitializer.cxx | |
parent | 2f7c4a788cde2b3df8486a34e9e67e8c84282032 (diff) | |
parent | e5ec0e52f4f15f78bb973cdb03a61ef9c707c2fa (diff) | |
download | CMake-98d813b92c26f0c93cefe21fe7768ca4f73d2d9a.zip CMake-98d813b92c26f0c93cefe21fe7768ca4f73d2d9a.tar.gz CMake-98d813b92c26f0c93cefe21fe7768ca4f73d2d9a.tar.bz2 |
Merge topic 'autouic-header-depends' into release-3.21
e5ec0e52f4 AUTOUIC: Fix generating of dependency rules for UI header files
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6380
Diffstat (limited to 'Source/cmQtAutoGenInitializer.cxx')
-rw-r--r-- | Source/cmQtAutoGenInitializer.cxx | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 4dd78e5..6cc8328 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -902,6 +902,13 @@ bool cmQtAutoGenInitializer::InitScanFiles() // The reason is that their file names might be discovered from source files // at generation time. if (this->MocOrUicEnabled()) { + std::set<std::string> uicIncludes; + auto collectUicIncludes = [&](std::unique_ptr<cmSourceFile> const& sf) { + std::string content; + FileRead(content, sf->GetFullPath()); + this->AutoUicHelpers.CollectUicIncludes(uicIncludes, content); + }; + 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 @@ -914,6 +921,10 @@ bool cmQtAutoGenInitializer::InitScanFiles() std::string const& extLower = cmSystemTools::LowerCase(sf->GetExtension()); + bool const skipAutogen = sf->GetPropertyAsBool(kw.SKIP_AUTOGEN); + bool const skipUic = + (skipAutogen || sf->GetPropertyAsBool(kw.SKIP_AUTOUIC) || + !this->Uic.Enabled); if (cm->IsAHeaderExtension(extLower)) { if (!cm::contains(this->AutogenTarget.Headers, sf.get())) { auto muf = makeMUFile(sf.get(), fullPath, {}, false); @@ -921,6 +932,9 @@ bool cmQtAutoGenInitializer::InitScanFiles() addMUHeader(std::move(muf), extLower); } } + if (!skipUic && !sf->GetIsGenerated()) { + collectUicIncludes(sf); + } } else if (cm->IsACLikeSourceExtension(extLower)) { if (!cm::contains(this->AutogenTarget.Sources, sf.get())) { auto muf = makeMUFile(sf.get(), fullPath, {}, false); @@ -928,11 +942,11 @@ bool cmQtAutoGenInitializer::InitScanFiles() addMUSource(std::move(muf)); } } + if (!skipUic && !sf->GetIsGenerated()) { + collectUicIncludes(sf); + } } else if (this->Uic.Enabled && (extLower == kw.ui)) { // .ui file - bool const skipAutogen = sf->GetPropertyAsBool(kw.SKIP_AUTOGEN); - bool const skipUic = - (skipAutogen || sf->GetPropertyAsBool(kw.SKIP_AUTOUIC)); if (!skipUic) { // Check if the .ui file has uic options std::string const uicOpts = sf->GetSafeProperty(kw.AUTOUIC_OPTIONS); @@ -942,35 +956,22 @@ bool cmQtAutoGenInitializer::InitScanFiles() this->Uic.UiFilesWithOptions.emplace_back(fullPath, cmExpandedList(uicOpts)); } - - auto uiHeaderRelativePath = cmSystemTools::RelativePath( - this->LocalGen->GetCurrentSourceDirectory(), - cmSystemTools::GetFilenamePath(fullPath)); - - // 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), - uiHeaderFilePath); - - this->Uic.UiHeaders.emplace_back( - std::make_pair(uiHeader, uiHeaderGenex)); } else { // Register skipped .ui file this->Uic.SkipUi.insert(fullPath); } } } + + for (const auto& include : uicIncludes) { + ConfigString uiHeader; + std::string uiHeaderGenex; + this->ConfigFileNamesAndGenex(uiHeader, uiHeaderGenex, + cmStrCat(this->Dir.Build, "/include"_s), + cmStrCat("/"_s, include)); + this->Uic.UiHeaders.emplace_back( + std::make_pair(uiHeader, uiHeaderGenex)); + } } // Process GENERATED sources and headers |