diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2016-12-31 12:04:38 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2017-01-10 11:49:16 (GMT) |
commit | 94c319f93309ff4cddd0280cdcbd48b50492db36 (patch) | |
tree | 0811b161a100d228ff3832516b4b92b5516bc906 | |
parent | 966be439e07131c3ff84175c1a9e3b6336908d8e (diff) | |
download | CMake-94c319f93309ff4cddd0280cdcbd48b50492db36.zip CMake-94c319f93309ff4cddd0280cdcbd48b50492db36.tar.gz CMake-94c319f93309ff4cddd0280cdcbd48b50492db36.tar.bz2 |
AUTOGEN: Generators: Use separate header lists for MOC and UIC
This is necessary for the skipMoc and skipUic lists to work properly.
-rw-r--r-- | Source/cmQtAutoGenerators.cxx | 58 | ||||
-rw-r--r-- | Source/cmQtAutoGenerators.h | 8 |
2 files changed, 50 insertions, 16 deletions
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index b323609..fac9d54 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -511,7 +511,8 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile) std::map<std::string, std::string> notIncludedMocs; std::map<std::string, std::vector<std::string> > includedUis; // collects all headers which may need to be mocced - std::set<std::string> headerFiles; + std::set<std::string> headerFilesMoc; + std::set<std::string> headerFilesUic; // Parse sources { @@ -527,14 +528,16 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile) return false; } // Find additional headers - this->SearchHeadersForCppFile(absFilename, headerExtensions, - headerFiles); + this->SearchHeadersForSourceFile(absFilename, headerExtensions, + headerFilesMoc, headerFilesUic); } } // Parse headers - headerFiles.insert(this->Headers.begin(), this->Headers.end()); - this->ParseHeaders(headerFiles, includedMocs, notIncludedMocs, includedUis); + headerFilesMoc.insert(this->Headers.begin(), this->Headers.end()); + headerFilesUic.insert(this->Headers.begin(), this->Headers.end()); + this->ParseHeaders(headerFilesMoc, headerFilesUic, includedMocs, + notIncludedMocs, includedUis); // Generate files if (!this->MocExecutable.empty()) { @@ -847,10 +850,10 @@ bool cmQtAutoGenerators::ParseContentForMoc( return true; } -void cmQtAutoGenerators::SearchHeadersForCppFile( +void cmQtAutoGenerators::SearchHeadersForSourceFile( const std::string& absFilename, const std::vector<std::string>& headerExtensions, - std::set<std::string>& absHeaders) + std::set<std::string>& absHeadersMoc, std::set<std::string>& absHeadersUic) { // search for header files and private header files we may need to moc: const std::string basename = @@ -859,37 +862,64 @@ void cmQtAutoGenerators::SearchHeadersForCppFile( cmsys::SystemTools::GetRealPath(absFilename)) + '/'; + // Search for regular header for (std::vector<std::string>::const_iterator ext = headerExtensions.begin(); ext != headerExtensions.end(); ++ext) { const std::string headerName = absPath + basename + "." + (*ext); if (cmsys::SystemTools::FileExists(headerName.c_str())) { - absHeaders.insert(headerName); + // Moc headers + if (!this->MocExecutable.empty() && + !ListContains(this->SkipMoc, absFilename)) { + absHeadersMoc.insert(headerName); + } + // Uic headers + if (!this->UicExecutable.empty() && + !ListContains(this->SkipUic, absFilename)) { + 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 privateHeaderName = absPath + basename + "_p." + (*ext); if (cmsys::SystemTools::FileExists(privateHeaderName.c_str())) { - absHeaders.insert(privateHeaderName); + // Moc headers + if (!this->MocExecutable.empty() && + !ListContains(this->SkipMoc, absFilename)) { + absHeadersMoc.insert(privateHeaderName); + } + // Uic headers + if (!this->UicExecutable.empty() && + !ListContains(this->SkipUic, absFilename)) { + absHeadersUic.insert(privateHeaderName); + } break; } } } void cmQtAutoGenerators::ParseHeaders( - const std::set<std::string>& absHeaders, + const std::set<std::string>& absHeadersMoc, + const std::set<std::string>& absHeadersUic, const std::map<std::string, std::string>& includedMocs, std::map<std::string, std::string>& notIncludedMocs, std::map<std::string, std::vector<std::string> >& includedUis) { - for (std::set<std::string>::const_iterator hIt = absHeaders.begin(); - hIt != absHeaders.end(); ++hIt) { + // Merged header files list to read files only once + std::set<std::string> headerFiles; + headerFiles.insert(absHeadersMoc.begin(), absHeadersMoc.end()); + headerFiles.insert(absHeadersUic.begin(), absHeadersUic.end()); + + for (std::set<std::string>::const_iterator hIt = headerFiles.begin(); + hIt != headerFiles.end(); ++hIt) { const std::string& headerName = *hIt; const std::string contents = ReadAll(headerName); // Parse header content for MOC if (!this->MocExecutable.empty() && + (absHeadersMoc.find(headerName) != absHeadersMoc.end()) && (includedMocs.find(headerName) == includedMocs.end())) { if (ListContains(this->SkipMoc, headerName)) { // Skip @@ -916,7 +946,9 @@ void cmQtAutoGenerators::ParseHeaders( } // Parse header content for UIC - this->ParseContentForUic(headerName, contents, includedUis); + if (absHeadersUic.find(headerName) != absHeadersUic.end()) { + this->ParseContentForUic(headerName, contents, includedUis); + } } } diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index dac23d9..1036cb7 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -55,13 +55,15 @@ private: std::map<std::string, std::string>& includedMocs, std::map<std::string, std::vector<std::string> >& includedUis, bool relaxed); - void SearchHeadersForCppFile( + void SearchHeadersForSourceFile( const std::string& absFilename, const std::vector<std::string>& headerExtensions, - std::set<std::string>& absHeaders); + std::set<std::string>& absHeadersMoc, + std::set<std::string>& absHeadersUic); void ParseHeaders( - const std::set<std::string>& absHeaders, + const std::set<std::string>& absHeadersMoc, + const std::set<std::string>& absHeadersUic, const std::map<std::string, std::string>& includedMocs, std::map<std::string, std::string>& notIncludedMocs, std::map<std::string, std::vector<std::string> >& includedUis); |