summaryrefslogtreecommitdiffstats
path: root/Source/cmQtAutomoc.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmQtAutomoc.cxx')
-rw-r--r--Source/cmQtAutomoc.cxx28
1 files changed, 22 insertions, 6 deletions
diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx
index 8750b64..ae63701 100644
--- a/Source/cmQtAutomoc.cxx
+++ b/Source/cmQtAutomoc.cxx
@@ -51,7 +51,7 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target)
const char* targetName = target->GetName();
// don't do anything if there is no Qt4:
std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR");
- if (qtMajorVersion != "4")
+ if (qtMajorVersion != "4" && qtMajorVersion != "5")
{
return;
}
@@ -124,9 +124,15 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target)
}
}
- std::string _moc_incs = makefile->GetProperty("INCLUDE_DIRECTORIES");
- std::string _moc_defs = makefile->GetProperty("DEFINITIONS");
- std::string _moc_compile_defs = makefile->GetProperty("COMPILE_DEFINITIONS");
+ const char* tmp = makefile->GetProperty("INCLUDE_DIRECTORIES");
+ std::string _moc_incs = (tmp!=0 ? tmp : "");
+ tmp = makefile->GetProperty("DEFINITIONS");
+ std::string _moc_defs = (tmp!=0 ? tmp : "");
+ tmp = makefile->GetProperty("COMPILE_DEFINITIONS");
+ std::string _moc_compile_defs = (tmp!=0 ? tmp : "");
+ tmp = target->GetProperty("AUTOMOC_MOC_OPTIONS");
+ std::string _moc_options = (tmp!=0 ? tmp : "");
+
// forget the variables added here afterwards again:
cmMakefile::ScopePushPop varScope(makefile);
static_cast<void>(varScope);
@@ -135,10 +141,11 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target)
makefile->AddDefinition("_moc_incs", _moc_incs.c_str());
makefile->AddDefinition("_moc_defs", _moc_defs.c_str());
makefile->AddDefinition("_moc_compile_defs", _moc_compile_defs.c_str());
+ makefile->AddDefinition("_moc_options", _moc_options.c_str());
makefile->AddDefinition("_moc_files", _moc_files.c_str());
makefile->AddDefinition("_moc_headers", _moc_headers.c_str());
- const char* cmakeRoot = makefile->GetDefinition("CMAKE_ROOT");
+ const char* cmakeRoot = makefile->GetSafeDefinition("CMAKE_ROOT");
std::string inputFile = cmakeRoot;
inputFile += "/Modules/AutomocInfo.cmake.in";
std::string outputFile = targetDir;
@@ -170,7 +177,7 @@ bool cmQtAutomoc::Run(const char* targetDirectory)
this->Init();
- if (this->QtMajorVersion == "4")
+ if (this->QtMajorVersion == "4" || this->QtMajorVersion == "5")
{
this->RunAutomocQt4();
}
@@ -226,6 +233,7 @@ bool cmQtAutomoc::ReadAutomocInfoFile(cmMakefile* makefile,
"AM_MOC_COMPILE_DEFINITIONS");
this->MocDefinitionsStr = makefile->GetSafeDefinition("AM_MOC_DEFINITIONS");
this->MocIncludesStr = makefile->GetSafeDefinition("AM_MOC_INCLUDES");
+ this->MocOptionsStr = makefile->GetSafeDefinition("AM_MOC_OPTIONS");
this->ProjectBinaryDir = makefile->GetSafeDefinition("AM_CMAKE_BINARY_DIR");
this->ProjectSourceDir = makefile->GetSafeDefinition("AM_CMAKE_SOURCE_DIR");
this->TargetName = makefile->GetSafeDefinition("AM_TARGET_NAME");
@@ -302,6 +310,8 @@ void cmQtAutomoc::Init()
}
}
+ cmSystemTools::ExpandListArgument(this->MocOptionsStr, this->MocOptions);
+
std::vector<std::string> incPaths;
cmSystemTools::ExpandListArgument(this->MocIncludesStr, incPaths);
@@ -711,6 +721,12 @@ bool cmQtAutomoc::GenerateMoc(const std::string& sourceFile,
{
command.push_back(*it);
}
+ for(std::vector<std::string>::const_iterator it=this->MocOptions.begin();
+ it != this->MocOptions.end();
+ ++it)
+ {
+ command.push_back(*it);
+ }
#ifdef _WIN32
command.push_back("-DWIN32");
#endif