summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-02-26 14:38:51 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2014-02-26 14:38:51 (GMT)
commit6223621e9a4bfc7bbf91037183c725c4300db397 (patch)
tree97ed8192c19a5b81048300a4912ffaeff09b4527 /Source
parent5cad466daefa64578d4e4ca0394db983ab40bba4 (diff)
parentfba51b096e2d8ec281653aa05720c11dc9b9bfe6 (diff)
downloadCMake-6223621e9a4bfc7bbf91037183c725c4300db397.zip
CMake-6223621e9a4bfc7bbf91037183c725c4300db397.tar.gz
CMake-6223621e9a4bfc7bbf91037183c725c4300db397.tar.bz2
Merge topic 'msvc-compiler-pdb-files'
fba51b09 MSVC: Add properties to configure compiler PDB files (#14762) 3737860a cmTarget: Add per-config compilation info 718a9532 cmTarget: Refactor ComputePDBOutputDir interface aae5184c Help: Refactor PDB_NAME and PDB_OUTPUT_DIRECTORY docs b4aac0ca Makefile: Fix per-config linker PDB output directory
Diffstat (limited to 'Source')
-rw-r--r--Source/cmLocalGenerator.cxx7
-rw-r--r--Source/cmLocalGenerator.h1
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx13
-rw-r--r--Source/cmMakefileExecutableTargetGenerator.cxx6
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx6
-rw-r--r--Source/cmMakefileTargetGenerator.cxx17
-rw-r--r--Source/cmNinjaTargetGenerator.cxx16
-rw-r--r--Source/cmTarget.cxx113
-rw-r--r--Source/cmTarget.h23
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx11
10 files changed, 202 insertions, 11 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index aca195c..4266dd0 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -901,6 +901,13 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable,
return replaceValues.TargetPDB;
}
}
+ if(replaceValues.TargetCompilePDB)
+ {
+ if(variable == "TARGET_COMPILE_PDB")
+ {
+ return replaceValues.TargetCompilePDB;
+ }
+ }
if(replaceValues.DependencyFile )
{
if(variable == "DEP_FILE")
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 9764813..0f7fd25 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -245,6 +245,7 @@ public:
}
cmTarget* CMTarget;
const char* TargetPDB;
+ const char* TargetCompilePDB;
const char* TargetVersionMajor;
const char* TargetVersionMinor;
const char* Language;
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 212b06b..ce24d8d 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -660,7 +660,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
switch(target.GetType())
{
case cmTarget::OBJECT_LIBRARY:
- targetBuilds = false; // TODO: PDB for object library?
+ targetBuilds = false; // no manifest tool for object library
case cmTarget::STATIC_LIBRARY:
projectType = "typeStaticLibrary";
configType = "4";
@@ -846,6 +846,17 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
targetOptions.OutputFlagMap(fout, "\t\t\t\t");
targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n", "CXX");
fout << "\t\t\t\tObjectFile=\"$(IntDir)\\\"\n";
+ if(target.GetType() <= cmTarget::OBJECT_LIBRARY)
+ {
+ // Specify the compiler program database file if configured.
+ std::string pdb = target.GetCompilePDBPath(configName);
+ if(!pdb.empty())
+ {
+ fout << "\t\t\t\tProgramDataBaseFileName=\""
+ << this->ConvertToXMLOutputPathSingle(pdb.c_str())
+ << "\"\n";
+ }
+ }
fout << "/>\n"; // end of <Tool Name=VCCLCompilerTool
tool = "VCCustomBuildTool";
if(this->FortranProject)
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index 69b8092..03fdda2 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -129,7 +129,11 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
}
}
- std::string pdbOutputPath = this->Target->GetPDBDirectory();
+ std::string compilePdbOutputPath =
+ this->Target->GetCompilePDBDirectory(this->ConfigName);
+ cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str());
+
+ std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName);
cmSystemTools::MakeDirectory(pdbOutputPath.c_str());
pdbOutputPath += "/";
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index d6a0cd4..807aca8 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -321,7 +321,11 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
}
}
- std::string pdbOutputPath = this->Target->GetPDBDirectory();
+ std::string compilePdbOutputPath =
+ this->Target->GetCompilePDBDirectory(this->ConfigName);
+ cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str());
+
+ std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName);
cmSystemTools::MakeDirectory(pdbOutputPath.c_str());
pdbOutputPath += "/";
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 5a841ed..e8a9fd1 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -624,9 +624,11 @@ cmMakefileTargetGenerator
std::string targetOutPathReal;
std::string targetOutPathPDB;
+ std::string targetOutPathCompilePDB;
{
std::string targetFullPathReal;
std::string targetFullPathPDB;
+ std::string targetFullPathCompilePDB;
if(this->Target->GetType() == cmTarget::EXECUTABLE ||
this->Target->GetType() == cmTarget::STATIC_LIBRARY ||
this->Target->GetType() == cmTarget::SHARED_LIBRARY ||
@@ -638,12 +640,26 @@ cmMakefileTargetGenerator
targetFullPathPDB += "/";
targetFullPathPDB += this->Target->GetPDBName(this->ConfigName);
}
+ if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY)
+ {
+ targetFullPathCompilePDB =
+ this->Target->GetCompilePDBPath(this->ConfigName);
+ if(targetFullPathCompilePDB.empty())
+ {
+ targetFullPathCompilePDB = this->Target->GetSupportDirectory() + "/";
+ }
+ }
+
targetOutPathReal = this->Convert(targetFullPathReal.c_str(),
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::SHELL);
targetOutPathPDB =
this->Convert(targetFullPathPDB.c_str(),cmLocalGenerator::NONE,
cmLocalGenerator::SHELL);
+ targetOutPathCompilePDB =
+ this->Convert(targetFullPathCompilePDB.c_str(),
+ cmLocalGenerator::START_OUTPUT,
+ cmLocalGenerator::SHELL);
}
cmLocalGenerator::RuleVariables vars;
vars.RuleLauncher = "RULE_LAUNCH_COMPILE";
@@ -651,6 +667,7 @@ cmMakefileTargetGenerator
vars.Language = lang;
vars.Target = targetOutPathReal.c_str();
vars.TargetPDB = targetOutPathPDB.c_str();
+ vars.TargetCompilePDB = targetOutPathCompilePDB.c_str();
vars.Source = sourceFile.c_str();
std::string shellObj =
this->Convert(obj.c_str(),
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 5f6fc2d..00b0441 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -320,6 +320,7 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const
mf->GetDefinition("MSVC_CXX_ARCHITECTURE_ID"))
{
std::string pdbPath;
+ std::string compilePdbPath;
if(this->Target->GetType() == cmTarget::EXECUTABLE ||
this->Target->GetType() == cmTarget::STATIC_LIBRARY ||
this->Target->GetType() == cmTarget::SHARED_LIBRARY ||
@@ -329,11 +330,25 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const
pdbPath += "/";
pdbPath += this->Target->GetPDBName(this->GetConfigName());
}
+ if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY)
+ {
+ compilePdbPath = this->Target->GetCompilePDBPath(this->GetConfigName());
+ if(compilePdbPath.empty())
+ {
+ compilePdbPath = this->Target->GetSupportDirectory() + "/";
+ }
+ }
vars["TARGET_PDB"] = this->GetLocalGenerator()->ConvertToOutputFormat(
ConvertToNinjaPath(pdbPath.c_str()).c_str(),
cmLocalGenerator::SHELL);
+ vars["TARGET_COMPILE_PDB"] =
+ this->GetLocalGenerator()->ConvertToOutputFormat(
+ ConvertToNinjaPath(compilePdbPath.c_str()).c_str(),
+ cmLocalGenerator::SHELL);
+
EnsureParentDirectoryExists(pdbPath);
+ EnsureParentDirectoryExists(compilePdbPath);
return true;
}
return false;
@@ -362,6 +377,7 @@ cmNinjaTargetGenerator
vars.Object = "$out";
vars.Defines = "$DEFINES";
vars.TargetPDB = "$TARGET_PDB";
+ vars.TargetCompilePDB = "$TARGET_COMPILE_PDB";
vars.ObjectDir = "$OBJECT_DIR";
cmMakefile* mf = this->GetMakefile();
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 7df2928..1c2b27a 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -71,6 +71,12 @@ struct cmTarget::ImportInfo
cmTarget::LinkInterface LinkInterface;
};
+//----------------------------------------------------------------------------
+struct cmTarget::CompileInfo
+{
+ std::string CompilePdbDir;
+};
+
struct TargetConfigPair : public std::pair<cmTarget const* , std::string> {
TargetConfigPair(cmTarget const* tgt, const std::string &config)
: std::pair<cmTarget const* , std::string>(tgt, config) {}
@@ -119,6 +125,9 @@ public:
ImportInfoMapType;
ImportInfoMapType ImportInfoMap;
+ typedef std::map<std::string, cmTarget::CompileInfo> CompileInfoMapType;
+ CompileInfoMapType CompileInfoMap;
+
// Cache link implementation computation from each configuration.
typedef std::map<TargetConfigPair,
cmTarget::LinkImplementation> LinkImplMapType;
@@ -270,6 +279,7 @@ void cmTarget::SetMakefile(cmMakefile* mf)
this->SetPropertyDefault("LIBRARY_OUTPUT_DIRECTORY", 0);
this->SetPropertyDefault("RUNTIME_OUTPUT_DIRECTORY", 0);
this->SetPropertyDefault("PDB_OUTPUT_DIRECTORY", 0);
+ this->SetPropertyDefault("COMPILE_PDB_OUTPUT_DIRECTORY", 0);
this->SetPropertyDefault("Fortran_FORMAT", 0);
this->SetPropertyDefault("Fortran_MODULE_DIRECTORY", 0);
this->SetPropertyDefault("GNUtoMS", 0);
@@ -298,6 +308,7 @@ void cmTarget::SetMakefile(cmMakefile* mf)
"LIBRARY_OUTPUT_DIRECTORY_",
"RUNTIME_OUTPUT_DIRECTORY_",
"PDB_OUTPUT_DIRECTORY_",
+ "COMPILE_PDB_OUTPUT_DIRECTORY_",
"MAP_IMPORTED_CONFIG_",
0};
for(std::vector<std::string>::iterator ci = configNames.begin();
@@ -2361,7 +2372,7 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo(const char* config) const
OutputInfo info;
this->ComputeOutputDir(config, false, info.OutDir);
this->ComputeOutputDir(config, true, info.ImpDir);
- if(!this->ComputePDBOutputDir(config, info.PdbDir))
+ if(!this->ComputePDBOutputDir("PDB", config, info.PdbDir))
{
info.PdbDir = info.OutDir;
}
@@ -2372,6 +2383,45 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo(const char* config) const
}
//----------------------------------------------------------------------------
+cmTarget::CompileInfo const* cmTarget::GetCompileInfo(const char* config) const
+{
+ // There is no compile information for imported targets.
+ if(this->IsImported())
+ {
+ return 0;
+ }
+
+ if(this->GetType() > cmTarget::OBJECT_LIBRARY)
+ {
+ std::string msg = "cmTarget::GetCompileInfo called for ";
+ msg += this->GetName();
+ msg += " which has type ";
+ msg += cmTarget::GetTargetTypeName(this->GetType());
+ this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg);
+ abort();
+ return 0;
+ }
+
+ // Lookup/compute/cache the compile information for this configuration.
+ std::string config_upper;
+ if(config && *config)
+ {
+ config_upper = cmSystemTools::UpperCase(config);
+ }
+ typedef cmTargetInternals::CompileInfoMapType CompileInfoMapType;
+ CompileInfoMapType::const_iterator i =
+ this->Internal->CompileInfoMap.find(config_upper);
+ if(i == this->Internal->CompileInfoMap.end())
+ {
+ CompileInfo info;
+ this->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir);
+ CompileInfoMapType::value_type entry(config_upper, info);
+ i = this->Internal->CompileInfoMap.insert(entry).first;
+ }
+ return &i->second;
+}
+
+//----------------------------------------------------------------------------
std::string cmTarget::GetDirectory(const char* config, bool implib) const
{
if (this->IsImported())
@@ -2401,6 +2451,16 @@ std::string cmTarget::GetPDBDirectory(const char* config) const
}
//----------------------------------------------------------------------------
+std::string cmTarget::GetCompilePDBDirectory(const char* config) const
+{
+ if(CompileInfo const* info = this->GetCompileInfo(config))
+ {
+ return info->CompilePdbDir;
+ }
+ return "";
+}
+
+//----------------------------------------------------------------------------
const char* cmTarget::GetLocation(const char* config) const
{
if (this->IsImported())
@@ -3061,6 +3121,49 @@ std::string cmTarget::GetPDBName(const char* config) const
}
//----------------------------------------------------------------------------
+std::string cmTarget::GetCompilePDBName(const char* config) const
+{
+ std::string prefix;
+ std::string base;
+ std::string suffix;
+ this->GetFullNameInternal(config, false, prefix, base, suffix);
+
+ // Check for a per-configuration output directory target property.
+ std::string configUpper = cmSystemTools::UpperCase(config? config : "");
+ std::string configProp = "COMPILE_PDB_NAME_";
+ configProp += configUpper;
+ const char* config_name = this->GetProperty(configProp.c_str());
+ if(config_name && *config_name)
+ {
+ return prefix + config_name + ".pdb";
+ }
+
+ const char* name = this->GetProperty("COMPILE_PDB_NAME");
+ if(name && *name)
+ {
+ return prefix + name + ".pdb";
+ }
+
+ return "";
+}
+
+//----------------------------------------------------------------------------
+std::string cmTarget::GetCompilePDBPath(const char* config) const
+{
+ std::string dir = this->GetCompilePDBDirectory(config);
+ std::string name = this->GetCompilePDBName(config);
+ if(dir.empty() && !name.empty())
+ {
+ dir = this->GetPDBDirectory(config);
+ }
+ if(!dir.empty())
+ {
+ dir += "/";
+ }
+ return dir + name;
+}
+
+//----------------------------------------------------------------------------
bool cmTarget::HasSOName(const char* config) const
{
// soname is supported only for shared libraries and modules,
@@ -4005,13 +4108,13 @@ bool cmTarget::ComputeOutputDir(const char* config,
}
//----------------------------------------------------------------------------
-bool cmTarget::ComputePDBOutputDir(const char* config, std::string& out) const
+bool cmTarget::ComputePDBOutputDir(const char* kind, const char* config,
+ std::string& out) const
{
// Look for a target property defining the target output directory
// based on the target type.
- std::string targetTypeName = "PDB";
const char* propertyName = 0;
- std::string propertyNameStr = targetTypeName;
+ std::string propertyNameStr = kind;
if(!propertyNameStr.empty())
{
propertyNameStr += "_OUTPUT_DIRECTORY";
@@ -4021,7 +4124,7 @@ bool cmTarget::ComputePDBOutputDir(const char* config, std::string& out) const
// Check for a per-configuration output directory target property.
std::string configUpper = cmSystemTools::UpperCase(config? config : "");
const char* configProp = 0;
- std::string configPropStr = targetTypeName;
+ std::string configPropStr = kind;
if(!configPropStr.empty())
{
configPropStr += "_OUTPUT_DIRECTORY_";
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 5dec9e2..471ea94 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -320,7 +320,13 @@ public:
If the configuration name is given then the generator will add its
subdirectory for that configuration. Otherwise just the canonical
pdb output directory is given. */
- std::string GetPDBDirectory(const char* config = 0) const;
+ std::string GetPDBDirectory(const char* config) const;
+
+ /** Get the directory in which to place the target compiler .pdb file.
+ If the configuration name is given then the generator will add its
+ subdirectory for that configuration. Otherwise just the canonical
+ compiler pdb output directory is given. */
+ std::string GetCompilePDBDirectory(const char* config = 0) const;
/** Get the location of the target in the build tree for the given
configuration. This location is suitable for use as the LOCATION
@@ -350,7 +356,13 @@ public:
const char* config=0, bool implib = false) const;
/** Get the name of the pdb file for the target. */
- std::string GetPDBName(const char* config=0) const;
+ std::string GetPDBName(const char* config) const;
+
+ /** Get the name of the compiler pdb file for the target. */
+ std::string GetCompilePDBName(const char* config=0) const;
+
+ /** Get the path for the MSVC /Fd option for this target. */
+ std::string GetCompilePDBPath(const char* config=0) const;
/** Whether this library has soname enabled and platform supports it. */
bool HasSOName(const char* config) const;
@@ -685,7 +697,8 @@ private:
OutputInfo const* GetOutputInfo(const char* config) const;
bool
ComputeOutputDir(const char* config, bool implib, std::string& out) const;
- bool ComputePDBOutputDir(const char* config, std::string& out) const;
+ bool ComputePDBOutputDir(const char* kind, const char* config,
+ std::string& out) const;
// Cache import information from properties for each configuration.
struct ImportInfo;
@@ -694,6 +707,10 @@ private:
void ComputeImportInfo(std::string const& desired_config, ImportInfo& info,
cmTarget const* head) const;
+ // Cache target compile paths for each configuration.
+ struct CompileInfo;
+ CompileInfo const* GetCompileInfo(const char* config) const;
+
mutable cmTargetLinkInformationMap LinkInformation;
void CheckPropertyCompatibility(cmComputeLinkInformation *info,
const char* config) const;
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index d760b3f..2d21a3d 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -1427,6 +1427,17 @@ void cmVisualStudio10TargetGenerator::WriteClOptions(
clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
"\n", "CXX");
this->WriteString("<ObjectFileName>$(IntDir)</ObjectFileName>\n", 3);
+
+ // Specify the compiler program database file if configured.
+ std::string pdb = this->Target->GetCompilePDBPath(configName.c_str());
+ if(!pdb.empty())
+ {
+ this->ConvertToWindowsSlash(pdb);
+ this->WriteString("<ProgramDataBaseFileName>", 3);
+ *this->BuildFileStream << cmVS10EscapeXML(pdb)
+ << "</ProgramDataBaseFileName>\n";
+ }
+
this->WriteString("</ClCompile>\n", 2);
}