diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2017-02-22 16:40:36 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2017-02-22 20:13:48 (GMT) |
commit | 70ebf35cdaaf391138df7564a07cd205de4af971 (patch) | |
tree | d9ae65c5c8ef3d0283ef1264c74c59bc0031366b | |
parent | 2a6fd4328adfad4cae0097d6d71e571c122fc0d1 (diff) | |
download | CMake-70ebf35cdaaf391138df7564a07cd205de4af971.zip CMake-70ebf35cdaaf391138df7564a07cd205de4af971.tar.gz CMake-70ebf35cdaaf391138df7564a07cd205de4af971.tar.bz2 |
Autogen: Add AUTOMOC_DEPEND_FILTERS support
-rw-r--r-- | Modules/AutogenInfo.cmake.in | 1 | ||||
-rw-r--r-- | Source/cmQtAutoGeneratorInitializer.cxx | 2 | ||||
-rw-r--r-- | Source/cmQtAutoGenerators.cxx | 60 | ||||
-rw-r--r-- | Source/cmQtAutoGenerators.h | 1 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 1 |
5 files changed, 55 insertions, 10 deletions
diff --git a/Modules/AutogenInfo.cmake.in b/Modules/AutogenInfo.cmake.in index b647ecf..fc5024f 100644 --- a/Modules/AutogenInfo.cmake.in +++ b/Modules/AutogenInfo.cmake.in @@ -20,6 +20,7 @@ set(AM_MOC_COMPILE_DEFINITIONS @_moc_compile_defs@) set(AM_MOC_INCLUDES @_moc_incs@) set(AM_MOC_OPTIONS @_moc_options@) set(AM_MOC_RELAXED_MODE @_moc_relaxed_mode@) +set(AM_MOC_DEPEND_FILTERS @_moc_depend_filters@) # UIC settings set(AM_UIC_SKIP @_uic_skip@) set(AM_UIC_TARGET_OPTIONS @_uic_target_options@) diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx index 52112ff..de18265 100644 --- a/Source/cmQtAutoGeneratorInitializer.cxx +++ b/Source/cmQtAutoGeneratorInitializer.cxx @@ -218,6 +218,8 @@ static void MocSetupAutoTarget( AddDefinitionEscaped(makefile, "_moc_relaxed_mode", makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE") ? "TRUE" : "FALSE"); + AddDefinitionEscaped(makefile, "_moc_depend_filters", + GetSafeProperty(target, "AUTOMOC_DEPEND_FILTERS")); // Moc includes and compile definitions { diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 4463d62..e1b4f35 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -260,6 +260,32 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory, return success; } +bool cmQtAutoGenerators::MocDependFilterPush(const std::string& key, + const std::string& regExp) +{ + bool success = false; + if (!key.empty()) { + if (!regExp.empty()) { + MocDependFilter filter; + filter.key = key; + if (filter.regExp.compile(regExp)) { + this->MocDependFilters.push_back(filter); + success = true; + } else { + this->LogError("AutoMoc: Error in AUTOMOC_DEPEND_FILTERS: Compiling " + "regular expression failed.\nKey: \"" + + key + "\"\nReg. exp.: \"" + regExp + "\""); + } + } else { + this->LogError("AutoMoc: Error in AUTOMOC_DEPEND_FILTERS: Regular " + "expression is empty"); + } + } else { + this->LogError("AutoMoc: Error in AUTOMOC_DEPEND_FILTERS: Key is empty"); + } + return success; +} + bool cmQtAutoGenerators::ReadAutogenInfoFile( cmMakefile* makefile, const std::string& targetDirectory, const std::string& config) @@ -320,6 +346,30 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile( this->MocIncludePaths); cmSystemTools::ExpandListArgument( makefile->GetSafeDefinition("AM_MOC_OPTIONS"), this->MocOptions); + { + std::vector<std::string> mocDependFilters; + cmSystemTools::ExpandListArgument( + makefile->GetSafeDefinition("AM_MOC_DEPEND_FILTERS"), mocDependFilters); + // Insert Q_PLUGIN_METADATA dependency filter + if (this->QtMajorVersion != "4") { + this->MocDependFilterPush("Q_PLUGIN_METADATA", + "[\n][ \t]*Q_PLUGIN_METADATA[ \t]*\\(" + "[^\\)]*FILE[ \t]*\"([^\"]+)\""); + } + // Insert user defined dependency filters + if ((mocDependFilters.size() % 2) == 0) { + for (std::vector<std::string>::const_iterator dit = + mocDependFilters.begin(); + dit != mocDependFilters.end(); dit += 2) { + if (!this->MocDependFilterPush(*dit, *(dit + 1))) { + return false; + } + } + } else { + this->LogError("AutoMoc: Error: AUTOMOC_DEPEND_FILTERS list size is not " + "a multiple of 2"); + } + } // - Uic cmSystemTools::ExpandListArgument(makefile->GetSafeDefinition("AM_UIC_SKIP"), @@ -559,16 +609,6 @@ void cmQtAutoGenerators::Init(cmMakefile* makefile) this->MocIncludes.push_back(*it); } } - - // Insert MocDependFilter for Q_PLUGIN_METADATA - if (QtMajorVersion != "4") { - MocDependFilter filter; - filter.key = "Q_PLUGIN_METADATA"; - filter.regExp.compile("[\n][ \t]*" - "Q_PLUGIN_METADATA[ \t]*\\(" - "[^\\)]*FILE[ \t]*\"([^\"]+)\""); - this->MocDependFilters.push_back(filter); - } } bool cmQtAutoGenerators::RunAutogen() diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index c20b83c..e4b7f60 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -33,6 +33,7 @@ private: typedef std::pair<std::string, cmsys::RegularExpression> MacroFilter; // - Configuration + bool MocDependFilterPush(const std::string& key, const std::string& regExp); bool ReadAutogenInfoFile(cmMakefile* makefile, const std::string& targetDirectory, const std::string& config); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index ad3d604..0f3d91b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -245,6 +245,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, this->SetPropertyDefault("AUTOMOC", CM_NULLPTR); this->SetPropertyDefault("AUTOUIC", CM_NULLPTR); this->SetPropertyDefault("AUTORCC", CM_NULLPTR); + this->SetPropertyDefault("AUTOMOC_DEPEND_FILTERS", CM_NULLPTR); this->SetPropertyDefault("AUTOMOC_MOC_OPTIONS", CM_NULLPTR); this->SetPropertyDefault("AUTOUIC_OPTIONS", CM_NULLPTR); this->SetPropertyDefault("AUTORCC_OPTIONS", CM_NULLPTR); |