summaryrefslogtreecommitdiffstats
path: root/Source/cmNinjaNormalTargetGenerator.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmNinjaNormalTargetGenerator.cxx')
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx33
1 files changed, 26 insertions, 7 deletions
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 2bad32c..cf2b427 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -47,8 +47,7 @@ cmNinjaNormalTargetGenerator(cmTarget* target)
{
// on Windows the output dir is already needed at compile time
// ensure the directory exists (OutDir test)
- std::string outpath = target->GetDirectory(this->GetConfigName());
- cmSystemTools::MakeDirectory(outpath.c_str());
+ EnsureDirectoryExists(target->GetDirectory(this->GetConfigName()));
}
}
@@ -56,6 +55,21 @@ cmNinjaNormalTargetGenerator::~cmNinjaNormalTargetGenerator()
{
}
+void
+cmNinjaNormalTargetGenerator
+::EnsureDirectoryExists(const std::string& dir)
+{
+ cmSystemTools::MakeDirectory(dir.c_str());
+}
+
+void
+cmNinjaNormalTargetGenerator
+::EnsureParentDirectoryExists(const std::string& path)
+{
+ EnsureDirectoryExists(cmSystemTools::GetParentDirectory(path.c_str()));
+}
+
+
void cmNinjaNormalTargetGenerator::Generate()
{
if (!this->TargetLinkLanguage) {
@@ -380,13 +394,18 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
}
}
+ std::string path;
if (!this->TargetNameImport.empty()) {
- vars["TARGET_IMPLIB"] = this->GetLocalGenerator()->ConvertToOutputFormat(
- targetOutputImplib.c_str(), cmLocalGenerator::SHELL);
+ path = this->GetLocalGenerator()->ConvertToOutputFormat(
+ targetOutputImplib.c_str(), cmLocalGenerator::SHELL);
+ vars["TARGET_IMPLIB"] = path;
+ EnsureParentDirectoryExists(path);
}
- vars["TARGET_PDB"] = this->GetLocalGenerator()->ConvertToOutputFormat(
- this->GetTargetPDB().c_str(), cmLocalGenerator::SHELL);
+ path = this->GetLocalGenerator()->ConvertToOutputFormat(
+ this->GetTargetPDB().c_str(), cmLocalGenerator::SHELL);
+ vars["TARGET_PDB"] = path;
+ EnsureParentDirectoryExists(path);
std::vector<cmCustomCommand> *cmdLists[3] = {
&this->GetTarget()->GetPreBuildCommands(),
@@ -413,7 +432,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
// If we have any PRE_LINK commands, we need to go back to HOME_OUTPUT for
// the link commands.
if (!preLinkCmdLines.empty()) {
- std::string path = this->GetLocalGenerator()->ConvertToOutputFormat(
+ path = this->GetLocalGenerator()->ConvertToOutputFormat(
this->GetMakefile()->GetHomeOutputDirectory(),
cmLocalGenerator::SHELL);
preLinkCmdLines.push_back("cd " + path);