summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2017-02-14 22:42:10 (GMT)
committerSebastian Holtermann <sebholt@xwmw.org>2017-02-19 11:35:41 (GMT)
commit6ae09b7c1473836236275e553fe9ff77f48306c1 (patch)
treee4fb9f176eb9c83d3916db8f5a208c76701f52ad /Source
parent9a7c9efeea0c2c2dfa20eb46dc75359c7f787629 (diff)
downloadCMake-6ae09b7c1473836236275e553fe9ff77f48306c1.zip
CMake-6ae09b7c1473836236275e553fe9ff77f48306c1.tar.gz
CMake-6ae09b7c1473836236275e553fe9ff77f48306c1.tar.bz2
Autogen: Use nested loops instead of code duplication
Diffstat (limited to 'Source')
-rw-r--r--Source/cmQtAutoGenerators.cxx63
1 files changed, 28 insertions, 35 deletions
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index 10ecc1b..218bbc3 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -985,42 +985,35 @@ void cmQtAutoGenerators::SearchHeadersForSourceFile(
const std::vector<std::string>& headerExtensions,
std::set<std::string>& absHeadersMoc, std::set<std::string>& absHeadersUic)
{
- // search for header files and private header files we may need to moc:
- std::string basepath = cmsys::SystemTools::GetFilenamePath(
- cmsys::SystemTools::GetRealPath(absFilename));
- basepath += '/';
- basepath += cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename);
-
- // Search for regular header
- for (std::vector<std::string>::const_iterator ext = headerExtensions.begin();
- ext != headerExtensions.end(); ++ext) {
- const std::string headerName = basepath + "." + (*ext);
- if (cmsys::SystemTools::FileExists(headerName.c_str())) {
- // Moc headers
- if (!this->MocSkipTest(absFilename) && !this->MocSkipTest(headerName)) {
- absHeadersMoc.insert(headerName);
- }
- // Uic headers
- if (!this->UicSkipTest(absFilename) && !this->UicSkipTest(headerName)) {
- absHeadersUic.insert(headerName);
- }
- break;
- }
- }
- // Search for private header
- for (std::vector<std::string>::const_iterator ext = headerExtensions.begin();
- ext != headerExtensions.end(); ++ext) {
- const std::string headerName = basepath + "_p." + (*ext);
- if (cmsys::SystemTools::FileExists(headerName.c_str())) {
- // Moc headers
- if (!this->MocSkipTest(absFilename) && !this->MocSkipTest(headerName)) {
- absHeadersMoc.insert(headerName);
- }
- // Uic headers
- if (!this->UicSkipTest(absFilename) && !this->UicSkipTest(headerName)) {
- absHeadersUic.insert(headerName);
+ std::string basepaths[2];
+ {
+ std::string bpath = cmsys::SystemTools::GetFilenamePath(
+ cmsys::SystemTools::GetRealPath(absFilename));
+ bpath += '/';
+ bpath += cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename);
+
+ // search for default header files and private header files
+ basepaths[0] = (bpath + ".");
+ basepaths[1] = (bpath + "_p.");
+ }
+
+ for (const std::string* bpit = cmArrayBegin(basepaths);
+ bpit != cmArrayEnd(basepaths); ++bpit) {
+ for (std::vector<std::string>::const_iterator heit =
+ headerExtensions.begin();
+ heit != headerExtensions.end(); ++heit) {
+ const std::string hname = (*bpit) + (*heit);
+ if (cmsys::SystemTools::FileExists(hname.c_str())) {
+ // Moc headers
+ if (!this->MocSkipTest(absFilename) && !this->MocSkipTest(hname)) {
+ absHeadersMoc.insert(hname);
+ }
+ // Uic headers
+ if (!this->UicSkipTest(absFilename) && !this->UicSkipTest(hname)) {
+ absHeadersUic.insert(hname);
+ }
+ break;
}
- break;
}
}
}