diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2019-07-02 16:04:53 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2019-07-04 10:30:40 (GMT) |
commit | 4a9154537c12e5f47e71018a7d485530a376c6da (patch) | |
tree | 72f26082af44a633bf01370d50bc32499e3bf76c /Source/cmQtAutoGenInitializer.cxx | |
parent | 8a42cd155f00d9418fa60f995b466fff7c1afaa5 (diff) | |
download | CMake-4a9154537c12e5f47e71018a7d485530a376c6da.zip CMake-4a9154537c12e5f47e71018a7d485530a376c6da.tar.gz CMake-4a9154537c12e5f47e71018a7d485530a376c6da.tar.bz2 |
Autogen: Use cmake::IsHeader/SourceExtension for file type detection
In the QtAutogen initializer use `cmake::IsHeaderExtension` and
`cmake::IsSourceExtension` instead of `cmSystemTools::GetFileFormat` for file
type detection.
Closes: #13904
Diffstat (limited to 'Source/cmQtAutoGenInitializer.cxx')
-rw-r--r-- | Source/cmQtAutoGenInitializer.cxx | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 9985f93..83a1bc4 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -620,6 +620,7 @@ bool cmQtAutoGenInitializer::InitRcc() bool cmQtAutoGenInitializer::InitScanFiles() { cmMakefile* makefile = this->Target->Target->GetMakefile(); + cmake const* cm = makefile->GetCMakeInstance(); auto const& kw = this->GlobalInitializer->kw(); auto makeMUFile = [this, &kw](cmSourceFile* sf, std::string const& fullPath, @@ -665,25 +666,21 @@ bool cmQtAutoGenInitializer::InitScanFiles() if (!pathError.empty() || fullPath.empty()) { continue; } - std::string const& ext = sf->GetExtension(); + std::string const& extLower = + cmSystemTools::LowerCase(sf->GetExtension()); // Register files that will be scanned by moc or uic if (this->MocOrUicEnabled()) { - switch (cmSystemTools::GetFileFormat(ext)) { - case cmSystemTools::HEADER_FILE_FORMAT: - addMUFile(makeMUFile(sf, fullPath, true), true); - break; - case cmSystemTools::CXX_FILE_FORMAT: - addMUFile(makeMUFile(sf, fullPath, true), false); - break; - default: - break; + if (cm->IsHeaderExtension(extLower)) { + addMUFile(makeMUFile(sf, fullPath, true), true); + } else if (cm->IsSourceExtension(extLower)) { + addMUFile(makeMUFile(sf, fullPath, true), false); } } // Register rcc enabled files if (this->Rcc.Enabled) { - if ((ext == kw.qrc) && !sf->GetPropertyAsBool(kw.SKIP_AUTOGEN) && + if ((extLower == kw.qrc) && !sf->GetPropertyAsBool(kw.SKIP_AUTOGEN) && !sf->GetPropertyAsBool(kw.SKIP_AUTORCC)) { // Register qrc file Qrc qrc; @@ -715,7 +712,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() 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(); + auto const& exts = cm->GetHeaderExtensions(); // Scan through sources for (auto const& pair : this->AutogenTarget.Sources) { MUFile const& muf = *pair.second; @@ -784,10 +781,10 @@ bool cmQtAutoGenInitializer::InitScanFiles() if (!pathError.empty() || fullPath.empty()) { continue; } - std::string const& ext = sf->GetExtension(); + std::string const& extLower = + cmSystemTools::LowerCase(sf->GetExtension()); - auto const fileFormat = cmSystemTools::GetFileFormat(ext); - if (fileFormat == cmSystemTools::HEADER_FILE_FORMAT) { + if (cm->IsHeaderExtension(extLower)) { if (this->AutogenTarget.Headers.find(sf) == this->AutogenTarget.Headers.end()) { auto muf = makeMUFile(sf, fullPath, false); @@ -795,7 +792,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() this->AutogenTarget.Headers.emplace(sf, std::move(muf)); } } - } else if (fileFormat == cmSystemTools::CXX_FILE_FORMAT) { + } else if (cm->IsSourceExtension(extLower)) { if (this->AutogenTarget.Sources.find(sf) == this->AutogenTarget.Sources.end()) { auto muf = makeMUFile(sf, fullPath, false); @@ -803,7 +800,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() this->AutogenTarget.Sources.emplace(sf, std::move(muf)); } } - } else if (this->Uic.Enabled && (ext == kw.ui)) { + } else if (this->Uic.Enabled && (extLower == kw.ui)) { // .ui file std::string realPath = cmSystemTools::GetRealPath(fullPath); bool const skipAutogen = sf->GetPropertyAsBool(kw.SKIP_AUTOGEN); |