summaryrefslogtreecommitdiffstats
path: root/Source/cmQtAutoGenInitializer.cxx
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2019-02-19 14:49:09 (GMT)
committerBrad King <brad.king@kitware.com>2019-02-25 13:20:19 (GMT)
commit747463d1b36a8bea31764db88ed4d9677b76f27f (patch)
tree1932fe24175f8ee70640561da78cda4b5579b807 /Source/cmQtAutoGenInitializer.cxx
parent16c687825daef4008d52b9b68bfa603ba493ac03 (diff)
downloadCMake-747463d1b36a8bea31764db88ed4d9677b76f27f.zip
CMake-747463d1b36a8bea31764db88ed4d9677b76f27f.tar.gz
CMake-747463d1b36a8bea31764db88ed4d9677b76f27f.tar.bz2
Autogen: Move additional source header search to configuration stage
The computation of additional source headers and and private headers for AUTOGEN is moved from the _autogen target to the configuration stage. This makes them available for _autogen target dependency computations. Closes: #18949
Diffstat (limited to 'Source/cmQtAutoGenInitializer.cxx')
-rw-r--r--Source/cmQtAutoGenInitializer.cxx61
1 files changed, 61 insertions, 0 deletions
diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx
index 239426c..2fb6fdf 100644
--- a/Source/cmQtAutoGenInitializer.cxx
+++ b/Source/cmQtAutoGenInitializer.cxx
@@ -704,6 +704,67 @@ bool cmQtAutoGenInitializer::InitScanFiles()
// mocs_compilation.cpp source acknowledged by this target.
this->Target->ClearSourcesCache();
+ // For source files find additional headers and private headers
+ if (this->MocOrUicEnabled()) {
+ std::vector<MUFileHandle> extraHeaders;
+ extraHeaders.reserve(this->AutogenTarget.Sources.size() * 2);
+ // Header search suffixes and extensions
+ std::array<std::string, 2> const suffixes{ { "", "_p" } };
+ auto const& exts = makefile->GetCMakeInstance()->GetHeaderExtensions();
+ // Scan through sources
+ for (auto const& pair : this->AutogenTarget.Sources) {
+ MUFile const& muf = *pair.second;
+ if (muf.MocIt || muf.UicIt) {
+ // Search for the default header file and a private header
+ std::string const& realPath = muf.RealPath;
+ std::string basePath = cmQtAutoGen::SubDirPrefix(realPath);
+ basePath += cmSystemTools::GetFilenameWithoutLastExtension(realPath);
+ for (auto const& suffix : suffixes) {
+ std::string const suffixedPath = basePath + suffix;
+ for (auto const& ext : exts) {
+ std::string fullPath = suffixedPath;
+ fullPath += '.';
+ fullPath += ext;
+
+ auto constexpr locationKind = cmSourceFileLocationKind::Known;
+ cmSourceFile* sf = makefile->GetSource(fullPath, locationKind);
+ if (sf != nullptr) {
+ // Check if we know about this header already
+ if (this->AutogenTarget.Headers.find(sf) !=
+ this->AutogenTarget.Headers.end()) {
+ continue;
+ }
+ // We only accept not-GENERATED files that do exist.
+ if (!sf->GetIsGenerated() &&
+ !cmSystemTools::FileExists(fullPath)) {
+ continue;
+ }
+ } else if (cmSystemTools::FileExists(fullPath)) {
+ // Create a new source file for the existing file
+ sf = makefile->CreateSource(fullPath, false, locationKind);
+ }
+
+ if (sf != nullptr) {
+ auto eMuf = makeMUFile(sf, fullPath, true);
+ // Ony process moc/uic when the parent is processed as well
+ if (!muf.MocIt) {
+ eMuf->MocIt = false;
+ }
+ if (!muf.UicIt) {
+ eMuf->UicIt = false;
+ }
+ extraHeaders.emplace_back(std::move(eMuf));
+ }
+ }
+ }
+ }
+ }
+ // Move generated files to main headers list
+ for (auto& eMuf : extraHeaders) {
+ addMUFile(std::move(eMuf), true);
+ }
+ }
+
// Scan through all source files in the makefile to extract moc and uic
// parameters. Historically we support non target source file parameters.
// The reason is that their file names might be discovered from source files