Ninja:split out setting of msvc TARGET_PDB

This commit is contained in:
Peter Kümmel 2012-08-22 12:37:55 +02:00
parent 59cbc28b92
commit 4bb4787780
3 changed files with 24 additions and 25 deletions

View File

@ -468,16 +468,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
}
cmMakefile* mf = this->GetMakefile();
if (mf->GetDefinition("MSVC_C_ARCHITECTURE_ID") ||
mf->GetDefinition("MSVC_CXX_ARCHITECTURE_ID"))
{
const std::string pdbPath = this->GetTargetPDB();
vars["TARGET_PDB"] = this->GetLocalGenerator()->ConvertToOutputFormat(
ConvertToNinjaPath(pdbPath.c_str()).c_str(),
cmLocalGenerator::SHELL);
EnsureParentDirectoryExists(pdbPath);
}
else
if (!this->SetMsvcTargetPdbVariable(vars))
{
// It is common to place debug symbols at a specific place,
// so we need a plain target name in the rule available.

View File

@ -311,6 +311,21 @@ std::string cmNinjaTargetGenerator::GetTargetPDB() const
return targetFullPathPDB.c_str();
}
bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const
{
cmMakefile* mf = this->GetMakefile();
if (mf->GetDefinition("MSVC_C_ARCHITECTURE_ID") ||
mf->GetDefinition("MSVC_CXX_ARCHITECTURE_ID"))
{
const std::string pdbPath = this->GetTargetPDB();
vars["TARGET_PDB"] = this->GetLocalGenerator()->ConvertToOutputFormat(
ConvertToNinjaPath(pdbPath.c_str()).c_str(),
cmLocalGenerator::SHELL);
EnsureParentDirectoryExists(pdbPath);
return true;
}
return false;
}
void
cmNinjaTargetGenerator
@ -537,17 +552,7 @@ cmNinjaTargetGenerator
vars["DEP_FILE"] = objectFileName + ".d";;
EnsureParentDirectoryExists(objectFileName);
// TODO move to GetTargetPDB
cmMakefile* mf = this->GetMakefile();
if (mf->GetDefinition("MSVC_C_ARCHITECTURE_ID") ||
mf->GetDefinition("MSVC_CXX_ARCHITECTURE_ID"))
{
const std::string pdbPath = this->GetTargetPDB();
vars["TARGET_PDB"] = this->GetLocalGenerator()->ConvertToOutputFormat(
ConvertToNinjaPath(pdbPath.c_str()).c_str(),
cmLocalGenerator::SHELL);
EnsureParentDirectoryExists(pdbPath);
}
this->SetMsvcTargetPdbVariable(vars);
if(this->Makefile->IsOn("CMAKE_EXPORT_COMPILE_COMMANDS"))
{
@ -643,14 +648,14 @@ cmNinjaTargetGenerator
void
cmNinjaTargetGenerator
::EnsureDirectoryExists(const std::string& dir)
::EnsureDirectoryExists(const std::string& dir) const
{
cmSystemTools::MakeDirectory(dir.c_str());
}
void
cmNinjaTargetGenerator
::EnsureParentDirectoryExists(const std::string& path)
::EnsureParentDirectoryExists(const std::string& path) const
{
EnsureDirectoryExists(cmSystemTools::GetParentDirectory(path.c_str()));
}

View File

@ -44,6 +44,9 @@ public:
std::string GetTargetName() const;
protected:
bool SetMsvcTargetPdbVariable(cmNinjaVars&) const;
cmGeneratedFileStream& GetBuildFileStream() const;
cmGeneratedFileStream& GetRulesFileStream() const;
@ -112,8 +115,8 @@ protected:
// Helper to add flag for windows .def file.
void AddModuleDefinitionFlag(std::string& flags);
void EnsureDirectoryExists(const std::string& dir);
void EnsureParentDirectoryExists(const std::string& path);
void EnsureDirectoryExists(const std::string& dir) const;
void EnsureParentDirectoryExists(const std::string& path) const;
// write rules for Mac OS X Application Bundle content.
struct MacOSXContentGeneratorType :