Autogen: Use integers instead of strings for the Qt version

This commit is contained in:
Sebastian Holtermann 2017-11-19 12:44:21 +01:00
parent be11a85286
commit 4043463179
4 changed files with 9 additions and 17 deletions

View File

@ -12,7 +12,6 @@ set(AM_HEADERS @_headers@)
set(AM_SETTINGS_FILE @_settings_file@)
# Qt environment
set(AM_QT_VERSION_MAJOR @_qt_version_major@)
set(AM_QT_VERSION_MINOR @_qt_version_minor@)
set(AM_QT_MOC_EXECUTABLE @_qt_moc_executable@)
set(AM_QT_UIC_EXECUTABLE @_qt_uic_executable@)
# MOC settings

View File

@ -899,10 +899,9 @@ void cmQtAutoGeneratorInitializer::SetupCustomTargets()
AddDefinitionEscaped(makefile, "_multi_config",
cmQtAutoGen::MultiConfigName(this->MultiConfig));
AddDefinitionEscaped(makefile, "_build_dir", this->DirBuild);
AddDefinitionEscaped(makefile, "_qt_version_major", this->QtVersionMajor);
AddDefinitionEscaped(makefile, "_qt_version_minor", this->QtVersionMinor);
if (this->MocEnabled || this->UicEnabled) {
AddDefinitionEscaped(makefile, "_qt_version_major", this->QtVersionMajor);
AddDefinitionEscaped(makefile, "_settings_file",
this->AutogenSettingsFile);
AddDefinitionEscaped(makefile, "_sources", this->Sources);

View File

@ -49,6 +49,7 @@ static bool ListContains(std::vector<std::string> const& list,
cmQtAutoGeneratorMocUic::cmQtAutoGeneratorMocUic()
: MultiConfig(cmQtAutoGen::WRAP)
, IncludeProjectDirsBefore(false)
, QtVersionMajor(4)
, MocSettingsChanged(false)
, MocPredefsChanged(false)
, MocRelaxedMode(false)
@ -163,19 +164,13 @@ bool cmQtAutoGeneratorMocUic::InitInfoFile(cmMakefile* makefile)
}
// - Qt environment
this->QtMajorVersion = InfoGet("AM_QT_VERSION_MAJOR");
this->QtMinorVersion = InfoGet("AM_QT_VERSION_MINOR");
if (!cmSystemTools::StringToULong(InfoGet("AM_QT_VERSION_MAJOR"),
&this->QtVersionMajor)) {
this->QtVersionMajor = 4;
}
this->MocExecutable = InfoGet("AM_QT_MOC_EXECUTABLE");
this->UicExecutable = InfoGet("AM_QT_UIC_EXECUTABLE");
// Check Qt version
if ((this->QtMajorVersion != "4") && (this->QtMajorVersion != "5")) {
this->LogFileError(cmQtAutoGen::GEN, this->GetInfoFile(),
"Unsupported Qt version: " +
cmQtAutoGen::Quoted(this->QtMajorVersion));
return false;
}
// - Moc
if (this->MocEnabled()) {
this->MocSkipList = InfoGetList("AM_MOC_SKIP");
@ -203,7 +198,7 @@ bool cmQtAutoGeneratorMocUic::InitInfoFile(cmMakefile* makefile)
std::vector<std::string> const mocDependFilters =
InfoGetList("AM_MOC_DEPEND_FILTERS");
// Insert Q_PLUGIN_METADATA dependency filter
if (this->QtMajorVersion != "4") {
if (this->QtVersionMajor != 4) {
this->MocDependFilterPush("Q_PLUGIN_METADATA",
"[\n][ \t]*Q_PLUGIN_METADATA[ \t]*\\("
"[^\\)]*FILE[ \t]*\"([^\"]+)\"");
@ -1686,7 +1681,7 @@ bool cmQtAutoGeneratorMocUic::UicGenerateFile(const UicJob& uicJob)
auto optionIt = this->UicOptions.find(uicJob.SourceFile);
if (optionIt != this->UicOptions.end()) {
cmQtAutoGen::UicMergeOptions(allOpts, optionIt->second,
(this->QtMajorVersion == "5"));
(this->QtVersionMajor == 5));
}
cmd.insert(cmd.end(), allOpts.begin(), allOpts.end());
}

View File

@ -154,8 +154,7 @@ private:
std::string AutogenBuildDir;
std::string AutogenIncludeDir;
// -- Qt environment
std::string QtMajorVersion;
std::string QtMinorVersion;
unsigned long QtVersionMajor;
std::string MocExecutable;
std::string UicExecutable;
// -- File lists