diff options
author | Brad King <brad.king@kitware.com> | 2017-04-21 12:42:38 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2017-04-21 12:43:43 (GMT) |
commit | 2b7aecba1663f86148b8c2f1033cfcbd87453ad3 (patch) | |
tree | d13754063e6795fcbab8f492dbf69fe7dcdf36a2 /Source/cmQtAutoGeneratorInitializer.cxx | |
parent | 1b0c7bca5ede6eb3965cb23471c6530a08d0d2d5 (diff) | |
parent | 0903531964cff8888dd1cbf2a9c82ac6bb9a522f (diff) | |
download | CMake-2b7aecba1663f86148b8c2f1033cfcbd87453ad3.zip CMake-2b7aecba1663f86148b8c2f1033cfcbd87453ad3.tar.gz CMake-2b7aecba1663f86148b8c2f1033cfcbd87453ad3.tar.bz2 |
Merge topic 'autogen-fixes'
09035319 Autogen: Pass explicit predefines header to moc if possible
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !671
Diffstat (limited to 'Source/cmQtAutoGeneratorInitializer.cxx')
-rw-r--r-- | Source/cmQtAutoGeneratorInitializer.cxx | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx index 82de9a2..239b18d 100644 --- a/Source/cmQtAutoGeneratorInitializer.cxx +++ b/Source/cmQtAutoGeneratorInitializer.cxx @@ -96,6 +96,41 @@ static std::string GetQtMajorVersion(cmGeneratorTarget const* target) return qtMajorVersion; } +static std::string GetQtMinorVersion(cmGeneratorTarget const* target, + const std::string& qtMajorVersion) +{ + cmMakefile* makefile = target->Target->GetMakefile(); + std::string qtMinorVersion; + if (qtMajorVersion == "5") { + qtMinorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MINOR"); + } + if (qtMinorVersion.empty()) { + qtMinorVersion = makefile->GetSafeDefinition("QT_VERSION_MINOR"); + } + + const char* targetQtVersion = + target->GetLinkInterfaceDependentStringProperty("QT_MINOR_VERSION", ""); + if (targetQtVersion != CM_NULLPTR) { + qtMinorVersion = targetQtVersion; + } + return qtMinorVersion; +} + +static bool QtVersionGreaterOrEqual(const std::string& major, + const std::string& minor, + unsigned long requestMajor, + unsigned long requestMinor) +{ + unsigned long majorUL(0); + unsigned long minorUL(0); + if (cmSystemTools::StringToULong(major.c_str(), &majorUL) && + cmSystemTools::StringToULong(minor.c_str(), &minorUL)) { + return (majorUL > requestMajor) || + (majorUL == requestMajor && minorUL >= requestMinor); + } + return false; +} + static void GetCompileDefinitionsAndDirectories( cmGeneratorTarget const* target, const std::string& config, std::string& incs, std::string& defs) @@ -258,6 +293,12 @@ static void MocSetupAutoTarget( AddDefinitionEscaped(makefile, "_moc_depend_filters", GetSafeProperty(target, "AUTOMOC_DEPEND_FILTERS")); + if (QtVersionGreaterOrEqual( + qtMajorVersion, GetQtMinorVersion(target, qtMajorVersion), 5, 8)) { + AddDefinitionEscaped( + makefile, "_moc_predefs_cmd", + makefile->GetSafeDefinition("CMAKE_CXX_COMPILER_PREDEFINES_COMMAND")); + } // Moc includes and compile definitions { std::string _moc_incs; |