diff options
author | Brad King <brad.king@kitware.com> | 2017-08-21 13:02:06 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2017-08-21 13:02:09 (GMT) |
commit | ab5667b516f3a67349437b4ca662a70d1edf5913 (patch) | |
tree | b15cd4c7f84a254cd77905ea9c4976e03aae01d1 /Source | |
parent | fabb217502b027ccab3e44cae4ed7a718a6eea81 (diff) | |
parent | b3d98c6ec2c966b316ffeec257a249e8355ce005 (diff) | |
download | CMake-ab5667b516f3a67349437b4ca662a70d1edf5913.zip CMake-ab5667b516f3a67349437b4ca662a70d1edf5913.tar.gz CMake-ab5667b516f3a67349437b4ca662a70d1edf5913.tar.bz2 |
Merge topic 'autogen-macro-names'
b3d98c6e Autogen: Add release notes for AUTOMOC_MACRO_NAMES
7529d84f Autogen: Add documentation for AUTOMOC_MACRO_NAMES
05891d8f Autogen: Add test for AUTOMOC_MACRO_NAMES
93f0ba28 Autogen: Add AUTOMOC_MACRO_NAMES support
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1156
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmQtAutoGeneratorInitializer.cxx | 2 | ||||
-rw-r--r-- | Source/cmQtAutoGenerators.cxx | 28 | ||||
-rw-r--r-- | Source/cmQtAutoGenerators.h | 2 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 1 |
4 files changed, 23 insertions, 10 deletions
diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx index 7974977..6ae101f 100644 --- a/Source/cmQtAutoGeneratorInitializer.cxx +++ b/Source/cmQtAutoGeneratorInitializer.cxx @@ -380,6 +380,8 @@ static void MocSetupAutoTarget( AddDefinitionEscaped(makefile, "_moc_relaxed_mode", makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE") ? "TRUE" : "FALSE"); + AddDefinitionEscaped(makefile, "_moc_macro_names", + GetSafeProperty(target, "AUTOMOC_MACRO_NAMES")); AddDefinitionEscaped(makefile, "_moc_depend_filters", GetSafeProperty(target, "AUTOMOC_DEPEND_FILTERS")); diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 1fe07ce..65ea048 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -280,12 +280,10 @@ cmQtAutoGenerators::cmQtAutoGenerators() } // Moc macro filters - this->MocMacroFilters[0].first = "Q_OBJECT"; - this->MocMacroFilters[0].second.compile( - "[\n][ \t]*{?[ \t]*Q_OBJECT[^a-zA-Z0-9_]"); - this->MocMacroFilters[1].first = "Q_GADGET"; - this->MocMacroFilters[1].second.compile( - "[\n][ \t]*{?[ \t]*Q_GADGET[^a-zA-Z0-9_]"); + this->MocMacroFilters.push_back( + MocMacroFilter("Q_OBJECT", "[\n][ \t]*{?[ \t]*Q_OBJECT[^a-zA-Z0-9_]")); + this->MocMacroFilters.push_back( + MocMacroFilter("Q_GADGET", "[\n][ \t]*{?[ \t]*Q_GADGET[^a-zA-Z0-9_]")); // Precompile regular expressions this->MocRegExpInclude.compile( @@ -402,7 +400,6 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile( InfoGet(makefile, "AM_QT_UIC_EXECUTABLE", this->UicExecutable); InfoGet(makefile, "AM_QT_RCC_EXECUTABLE", this->RccExecutable); - InfoGet(makefile, "AM_MOC_PREDEFS_CMD", this->MocPredefsCmd); // Check Qt version if ((this->QtMajorVersion != "4") && (this->QtMajorVersion != "5")) { this->LogError("AutoGen: Error: Unsupported Qt version: " + @@ -427,6 +424,16 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile( InfoGet(makefile, "AM_MOC_OPTIONS", this->MocOptions); InfoGet(makefile, "AM_MOC_RELAXED_MODE", this->MocRelaxedMode); { + std::vector<std::string> MocMacroNames; + InfoGet(makefile, "AM_MOC_MACRO_NAMES", MocMacroNames); + for (std::vector<std::string>::const_iterator dit = + MocMacroNames.begin(); + dit != MocMacroNames.end(); ++dit) { + this->MocMacroFilters.push_back( + MocMacroFilter(*dit, "[^a-zA-Z0-9_]" + *dit + "[^a-zA-Z0-9_]")); + } + } + { std::vector<std::string> mocDependFilters; InfoGet(makefile, "AM_MOC_DEPEND_FILTERS", mocDependFilters); // Insert Q_PLUGIN_METADATA dependency filter @@ -452,6 +459,7 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile( return false; } } + InfoGet(makefile, "AM_MOC_PREDEFS_CMD", this->MocPredefsCmd); } // - Uic @@ -800,8 +808,10 @@ bool cmQtAutoGenerators::RunAutogen() bool cmQtAutoGenerators::MocRequired(const std::string& contentText, std::string* macroName) { - for (unsigned int ii = 0; ii != cmArraySize(this->MocMacroFilters); ++ii) { - MocMacroFilter& filter = this->MocMacroFilters[ii]; + for (std::vector<MocMacroFilter>::iterator fit = + this->MocMacroFilters.begin(); + fit != this->MocMacroFilters.end(); ++fit) { + MocMacroFilter& filter = *fit; // Run a simple find string operation before the expensive // regular expression check if (contentText.find(filter.first) != std::string::npos) { diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index 337aa17..ce5db4a 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -201,7 +201,7 @@ private: std::vector<std::string> MocOptions; std::vector<std::string> MocPredefsCmd; std::vector<MocDependFilter> MocDependFilters; - MocMacroFilter MocMacroFilters[2]; + std::vector<MocMacroFilter> MocMacroFilters; cmsys::RegularExpression MocRegExpInclude; // -- Uic bool UicSettingsChanged; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c1b6f97..501aebf 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -248,6 +248,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, this->SetPropertyDefault("AUTOUIC", CM_NULLPTR); this->SetPropertyDefault("AUTORCC", CM_NULLPTR); this->SetPropertyDefault("AUTOMOC_DEPEND_FILTERS", CM_NULLPTR); + this->SetPropertyDefault("AUTOMOC_MACRO_NAMES", CM_NULLPTR); this->SetPropertyDefault("AUTOMOC_MOC_OPTIONS", CM_NULLPTR); this->SetPropertyDefault("AUTOUIC_OPTIONS", CM_NULLPTR); this->SetPropertyDefault("AUTOUIC_SEARCH_PATHS", CM_NULLPTR); |