summaryrefslogtreecommitdiffstats
path: root/Source/cmQtAutoGenerators.cxx
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-10-11 12:26:56 (GMT)
committerStephen Kelly <steveire@gmail.com>2013-10-24 09:50:58 (GMT)
commit85b3d6e73d1d5620229c7fc67a705fd50c8bcff0 (patch)
treefe8938859b9d1ea0c465db587e664e3908e9eb8e /Source/cmQtAutoGenerators.cxx
parentca124a15150b5f88a9dcd9edfc4f61cf473efc64 (diff)
downloadCMake-85b3d6e73d1d5620229c7fc67a705fd50c8bcff0.zip
CMake-85b3d6e73d1d5620229c7fc67a705fd50c8bcff0.tar.gz
CMake-85b3d6e73d1d5620229c7fc67a705fd50c8bcff0.tar.bz2
Extract an SetupAutoMocTarget method.
This class will soon gain methods for autouic and autorcc.
Diffstat (limited to 'Source/cmQtAutoGenerators.cxx')
-rw-r--r--Source/cmQtAutoGenerators.cxx104
1 files changed, 56 insertions, 48 deletions
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index 9016827..8d3de52 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -310,7 +310,61 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget* target)
target->AddUtility(autogenTargetName.c_str());
}
- // configure a file to get all information to automoc at buildtime:
+ std::map<std::string, std::string> configIncludes;
+ std::map<std::string, std::string> configDefines;
+
+ this->SetupAutoMocTarget(target, autogenTargetName,
+ configIncludes, configDefines);
+
+ const char* cmakeRoot = makefile->GetSafeDefinition("CMAKE_ROOT");
+ std::string inputFile = cmakeRoot;
+ inputFile += "/Modules/AutogenInfo.cmake.in";
+ std::string outputFile = targetDir;
+ outputFile += "/AutogenInfo.cmake";
+ makefile->ConfigureFile(inputFile.c_str(), outputFile.c_str(),
+ false, true, false);
+
+ if (!configDefines.empty() || !configIncludes.empty())
+ {
+ std::ofstream infoFile(outputFile.c_str(), std::ios::app);
+ if ( !infoFile )
+ {
+ std::string error = "Internal CMake error when trying to open file: ";
+ error += outputFile.c_str();
+ error += " for writing.";
+ cmSystemTools::Error(error.c_str());
+ return;
+ }
+ if (!configDefines.empty())
+ {
+ for (std::map<std::string, std::string>::iterator
+ it = configDefines.begin(), end = configDefines.end();
+ it != end; ++it)
+ {
+ infoFile << "set(AM_MOC_COMPILE_DEFINITIONS_" << it->first <<
+ " " << it->second << ")\n";
+ }
+ }
+ if (!configIncludes.empty())
+ {
+ for (std::map<std::string, std::string>::iterator
+ it = configIncludes.begin(), end = configIncludes.end();
+ it != end; ++it)
+ {
+ infoFile << "set(AM_MOC_INCLUDES_" << it->first <<
+ " " << it->second << ")\n";
+ }
+ }
+ }
+}
+
+void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget* target,
+ const std::string &autogenTargetName,
+ std::map<std::string, std::string> &configIncludes,
+ std::map<std::string, std::string> &configDefines)
+{
+ cmMakefile* makefile = target->GetMakefile();
+
std::string _moc_files;
std::string _moc_headers;
const char* sepFiles = "";
@@ -371,9 +425,6 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget* target)
makefile->AddDefinition("_moc_compile_defs",
cmLocalGenerator::EscapeForCMake(_moc_compile_defs.c_str()).c_str());
- std::map<std::string, std::string> configIncludes;
- std::map<std::string, std::string> configDefines;
-
for (std::vector<std::string>::const_iterator li = configs.begin();
li != configs.end(); ++li)
{
@@ -402,11 +453,10 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget* target)
}
}
- {
const char *qtMoc = makefile->GetSafeDefinition("QT_MOC_EXECUTABLE");
makefile->AddDefinition("_qt_moc_executable", qtMoc);
- }
+ const char *qtVersion = makefile->GetDefinition("_target_qt_version");
if (strcmp(qtVersion, "5") == 0)
{
cmTarget *qt5Moc = makefile->FindTargetToUse("Qt5::moc");
@@ -426,50 +476,8 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget* target)
"Qt 5 ", autogenTargetName.c_str());
}
}
-
- const char* cmakeRoot = makefile->GetSafeDefinition("CMAKE_ROOT");
- std::string inputFile = cmakeRoot;
- inputFile += "/Modules/AutogenInfo.cmake.in";
- std::string outputFile = targetDir;
- outputFile += "/AutogenInfo.cmake";
- makefile->ConfigureFile(inputFile.c_str(), outputFile.c_str(),
- false, true, false);
-
- if (!configDefines.empty() || !configIncludes.empty())
- {
- std::ofstream infoFile(outputFile.c_str(), std::ios::app);
- if ( !infoFile )
- {
- std::string error = "Internal CMake error when trying to open file: ";
- error += outputFile.c_str();
- error += " for writing.";
- cmSystemTools::Error(error.c_str());
- return;
- }
- if (!configDefines.empty())
- {
- for (std::map<std::string, std::string>::iterator
- it = configDefines.begin(), end = configDefines.end();
- it != end; ++it)
- {
- infoFile << "set(AM_MOC_COMPILE_DEFINITIONS_" << it->first <<
- " " << it->second << ")\n";
- }
- }
- if (!configIncludes.empty())
- {
- for (std::map<std::string, std::string>::iterator
- it = configIncludes.begin(), end = configIncludes.end();
- it != end; ++it)
- {
- infoFile << "set(AM_MOC_INCLUDES_" << it->first <<
- " " << it->second << ")\n";
- }
- }
- }
}
-
bool cmQtAutoGenerators::Run(const char* targetDirectory, const char *config)
{
bool success = true;