From 174bf35fbbcb22636e538323c168ecbc33a7cb39 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Fri, 2 Dec 2011 20:38:14 +0100 Subject: [PATCH] automoc: move the code for finding headers into separate function Alex --- Source/cmQtAutomoc.cxx | 50 ++++++++++++++++++++++++++---------------- Source/cmQtAutomoc.h | 8 +++++-- 2 files changed, 37 insertions(+), 21 deletions(-) diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index bb81dd348..3ff047740 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -469,6 +469,23 @@ bool cmQtAutomoc::RunAutomocQt4() std::vector sourceFiles; cmSystemTools::ExpandListArgument(this->Sources, sourceFiles); + std::list headerExtensions; + headerExtensions.push_back(".h"); + headerExtensions.push_back(".hpp"); + headerExtensions.push_back(".hxx"); +#if defined(_WIN32) + // not case sensitive, don't add ".H" +#elif defined(__APPLE__) + // detect case-sensitive filesystem + long caseSensitive = pathconf(this->Srcdir.c_str(), _PC_CASE_SENSITIVE); + if (caseSensitive == 1) + { + headerExtensions.push_back(".H"); + } +#else + headerExtensions.push_back(".H"); +#endif + for (std::vector::const_iterator it = sourceFiles.begin(); it != sourceFiles.end(); ++it) @@ -478,7 +495,8 @@ bool cmQtAutomoc::RunAutomocQt4() { std::cout << "AUTOMOC: Checking " << absFilename << std::endl; } - this->ParseCppFile(absFilename, includedMocs, headerFiles); + this->ParseCppFile(absFilename, headerExtensions, includedMocs); + this->SearchHeadersForCppFile(absFilename, headerExtensions, headerFiles); } std::vector headerFilesVec; @@ -559,28 +577,12 @@ bool cmQtAutomoc::RunAutomocQt4() void cmQtAutomoc::ParseCppFile(const std::string& absFilename, - std::map& includedMocs, - std::set& absHeaders) + const std::list& headerExtensions, + std::map& includedMocs) { cmsys::RegularExpression mocIncludeRegExp( "[\n][ \t]*#[ \t]*include[ \t]+" "[\"<](([^ \">]+/)?moc_[^ \">/]+\\.cpp|[^ \">]+\\.moc)[\">]"); - std::list headerExtensions; - headerExtensions.push_back(".h"); - headerExtensions.push_back(".hpp"); - headerExtensions.push_back(".hxx"); -#if defined(_WIN32) - // not case sensitive, don't add ".H" -#elif defined(__APPLE__) - // detect case-sensitive filesystem - long caseSensitive = pathconf(this->Srcdir.c_str(), _PC_CASE_SENSITIVE); - if (caseSensitive == 1) - { - headerExtensions.push_back(".H"); - } -#else - headerExtensions.push_back(".H"); -#endif const std::string contentsString = this->ReadAll(absFilename); if (contentsString.empty()) @@ -771,9 +773,19 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, } } +} + + +void cmQtAutomoc::SearchHeadersForCppFile(const std::string& absFilename, + const std::list& headerExtensions, + std::set& absHeaders) +{ // search for header files and private header files we may need to moc: const std::string basename = cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename); + const std::string absPath = cmsys::SystemTools::GetFilenamePath( + cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/'; + for(std::list::const_iterator ext = headerExtensions.begin(); ext != headerExtensions.end(); ++ext) diff --git a/Source/cmQtAutomoc.h b/Source/cmQtAutomoc.h index c3550a42d..d8f65a943 100644 --- a/Source/cmQtAutomoc.h +++ b/Source/cmQtAutomoc.h @@ -39,8 +39,12 @@ private: bool GenerateMoc(const std::string& sourceFile, const std::string& mocFileName); void ParseCppFile(const std::string& absFilename, - std::map& includedMocs, - std::set& absHeaders); + const std::list& headerExtensions, + std::map& includedMocs); + void SearchHeadersForCppFile(const std::string& absFilename, + const std::list& headerExtensions, + std::set& absHeaders); + void ParseHeaders(const std::set& absHeaders, const std::map& includedMocs, std::map& notIncludedMocs);