cmAutogen: Extract some helper methods for autogen targets.

These snippets will soon be needed from multiple methods.
This commit is contained in:
Stephen Kelly 2013-11-04 10:25:08 +01:00
parent e313d397cd
commit 20a234d1b8
1 changed files with 21 additions and 9 deletions

View File

@ -138,6 +138,24 @@ cmQtAutoGenerators::cmQtAutoGenerators()
} }
} }
static std::string getAutogenTargetName(cmTarget *target)
{
std::string autogenTargetName = target->GetName();
autogenTargetName += "_automoc";
return autogenTargetName;
}
static std::string getAutogenTargetDir(cmTarget *target)
{
cmMakefile* makefile = target->GetMakefile();
std::string targetDir = makefile->GetCurrentOutputDirectory();
targetDir += makefile->GetCMakeInstance()->GetCMakeFilesDirectory();
targetDir += "/";
targetDir += getAutogenTargetName(target);
targetDir += ".dir/";
return targetDir;
}
bool cmQtAutoGenerators::InitializeMocSourceFile(cmTarget* target) bool cmQtAutoGenerators::InitializeMocSourceFile(cmTarget* target)
{ {
cmMakefile* makefile = target->GetMakefile(); cmMakefile* makefile = target->GetMakefile();
@ -154,8 +172,7 @@ bool cmQtAutoGenerators::InitializeMocSourceFile(cmTarget* target)
if (target->GetPropertyAsBool("AUTOMOC")) if (target->GetPropertyAsBool("AUTOMOC"))
{ {
std::string automocTargetName = target->GetName(); std::string automocTargetName = getAutogenTargetName(target);
automocTargetName += "_automoc";
std::string mocCppFile = makefile->GetCurrentOutputDirectory(); std::string mocCppFile = makefile->GetCurrentOutputDirectory();
mocCppFile += "/"; mocCppFile += "/";
mocCppFile += automocTargetName; mocCppFile += automocTargetName;
@ -232,17 +249,12 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget* target)
makefile->AddDefinition("_target_qt_version", qtVersion); makefile->AddDefinition("_target_qt_version", qtVersion);
} }
// create a custom target for running generators at buildtime: // create a custom target for running generators at buildtime:
std::string autogenTargetName = targetName; std::string autogenTargetName = getAutogenTargetName(target);
autogenTargetName += "_automoc";
makefile->AddDefinition("_moc_target_name", makefile->AddDefinition("_moc_target_name",
cmLocalGenerator::EscapeForCMake(autogenTargetName.c_str()).c_str()); cmLocalGenerator::EscapeForCMake(autogenTargetName.c_str()).c_str());
std::string targetDir = makefile->GetCurrentOutputDirectory(); std::string targetDir = getAutogenTargetDir(target);
targetDir += makefile->GetCMakeInstance()->GetCMakeFilesDirectory();
targetDir += "/";
targetDir += autogenTargetName;
targetDir += ".dir/";
cmCustomCommandLine currentLine; cmCustomCommandLine currentLine;
currentLine.push_back(makefile->GetSafeDefinition("CMAKE_COMMAND")); currentLine.push_back(makefile->GetSafeDefinition("CMAKE_COMMAND"));