Commit fba51b09 authored by Brad King's avatar Brad King
Browse files

MSVC: Add properties to configure compiler PDB files (#14762)

Since commit v2.8.12~437^2~2 (VS: Separate compiler and linker PDB files
2013-04-05) we no longer set /Fd with the PDB_NAME or PDB_OUTPUT_DIRECTORY
properties.  Those properties now exclusively handle linker PDB files.
Since STATIC libraries do not link their compiler PDB file becomes more
important.  Add new target properties "COMPILE_PDB_NAME[_<CONFIG>]" and
"COMPILE_PDB_OUTPUT_DIRECTORY[_<CONFIG>]" to specify the compiler PDB
file location and pass the value to the MSVC /Fd option.
parent 3737860a
......@@ -100,6 +100,10 @@ Properties on Targets
/prop_tgt/COMPILE_DEFINITIONS
/prop_tgt/COMPILE_FLAGS
/prop_tgt/COMPILE_OPTIONS
/prop_tgt/COMPILE_PDB_NAME
/prop_tgt/COMPILE_PDB_NAME_CONFIG
/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY
/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG
/prop_tgt/CONFIG_OUTPUT_NAME
/prop_tgt/CONFIG_POSTFIX
/prop_tgt/DEBUG_POSTFIX
......
......@@ -198,6 +198,8 @@ Variables that Control the Build
/variable/CMAKE_AUTOUIC
/variable/CMAKE_AUTOUIC_OPTIONS
/variable/CMAKE_BUILD_WITH_INSTALL_RPATH
/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY
/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG
/variable/CMAKE_CONFIG_POSTFIX
/variable/CMAKE_DEBUG_POSTFIX
/variable/CMAKE_EXE_LINKER_FLAGS_CONFIG
......
COMPILE_PDB_NAME
----------------
Output name for the MS debug symbol ``.pdb`` file generated by the
compiler while building source files.
This property specifies the base name for the debug symbols file.
If not set, the default is unspecified.
.. |PDB_XXX| replace:: :prop_tgt:`PDB_NAME`
.. include:: COMPILE_PDB_NOTE.txt
COMPILE_PDB_NAME_<CONFIG>
-------------------------
Per-configuration output name for the MS debug symbol ``.pdb`` file
generated by the compiler while building source files.
This is the configuration-specific version of :prop_tgt:`COMPILE_PDB_NAME`.
.. |PDB_XXX| replace:: :prop_tgt:`PDB_NAME_<CONFIG>`
.. include:: COMPILE_PDB_NOTE.txt
.. note::
The compiler-generated program database files are specified by the
``/Fd`` compiler flag and are not the same as linker-generated
program database files specified by the ``/pdb`` linker flag.
Use the |PDB_XXX| property to specify the latter.
This property is not implemented by the :generator:`Visual Studio 6`
generator.
COMPILE_PDB_OUTPUT_DIRECTORY
----------------------------
Output directory for the MS debug symbol ``.pdb`` file
generated by the compiler while building source files.
This property specifies the directory into which the MS debug symbols
will be placed by the compiler. This property is initialized by the
value of the :variable:`CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY` variable
if it is set when a target is created.
.. |PDB_XXX| replace:: :prop_tgt:`PDB_OUTPUT_DIRECTORY`
.. include:: COMPILE_PDB_NOTE.txt
COMPILE_PDB_OUTPUT_DIRECTORY_<CONFIG>
-------------------------------------
Per-configuration output directory for the MS debug symbol ``.pdb`` file
generated by the compiler while building source files.
This is a per-configuration version of
:prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY`,
but multi-configuration generators (VS, Xcode) do NOT append a
per-configuration subdirectory to the specified directory. This
property is initialized by the value of the
:variable:`CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_<CONFIG>` variable
if it is set when a target is created.
.. |PDB_XXX| replace:: :prop_tgt:`PDB_OUTPUT_DIRECTORY_<CONFIG>`
.. include:: COMPILE_PDB_NOTE.txt
......@@ -7,4 +7,5 @@ linker for an executable or shared library target.
This property specifies the base name for the debug symbols file.
If not set, the logical target name is used by default.
.. |COMPILE_PDB_XXX| replace:: :prop_tgt:`COMPILE_PDB_NAME`
.. include:: PDB_NOTE.txt
......@@ -6,4 +6,5 @@ generated by the linker for an executable or shared library target.
This is the configuration-specific version of :prop_tgt:`PDB_NAME`.
.. |COMPILE_PDB_XXX| replace:: :prop_tgt:`COMPILE_PDB_NAME_<CONFIG>`
.. include:: PDB_NOTE.txt
......@@ -6,7 +6,7 @@
The linker-generated program database files are specified by the
``/pdb`` linker flag and are not the same as compiler-generated
program database files specified by the ``/Fd`` compiler flag.
This property does not influence the latter.
Use the |COMPILE_PDB_XXX| property to specify the latter.
This property is not implemented by the :generator:`Visual Studio 6`
generator.
......@@ -9,4 +9,5 @@ will be placed by the linker. This property is initialized by the
value of the :variable:`CMAKE_PDB_OUTPUT_DIRECTORY` variable if it is
set when a target is created.
.. |COMPILE_PDB_XXX| replace:: :prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY`
.. include:: PDB_NOTE.txt
......@@ -11,4 +11,5 @@ property is initialized by the value of the
:variable:`CMAKE_PDB_OUTPUT_DIRECTORY_<CONFIG>` variable if it is
set when a target is created.
.. |COMPILE_PDB_XXX| replace:: :prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY_<CONFIG>`
.. include:: PDB_NOTE.txt
msvc-compiler-pdb-files
-----------------------
* New :prop_tgt:`COMPILE_PDB_NAME` and
:prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY` target properties
were introduced to specify the MSVC compiler program database
file location (``cl /Fd``). This complements the existing
:prop_tgt:`PDB_NAME` and :prop_tgt:`PDB_OUTPUT_DIRECTORY`
target properties that specify the linker program database
file location (``link /pdb``).
CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY
----------------------------------
Output directory for MS debug symbol ``.pdb`` files
generated by the compiler while building source files.
This variable is used to initialize the
:prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY` property on all the targets.
CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_<CONFIG>
-------------------------------------------
Per-configuration output directory for MS debug symbol ``.pdb`` files
generated by the compiler while building source files.
This is a per-configuration version of
:variable:`CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY`.
This variable is used to initialize the
:prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY_<CONFIG>`
property on all the targets.
......@@ -241,7 +241,7 @@ macro(__windows_compiler_msvc lang)
set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "<CMAKE_LINKER> /lib ${CMAKE_CL_NOLOGO} <LINK_FLAGS> /out:<TARGET> <OBJECTS> ")
set(CMAKE_${lang}_COMPILE_OBJECT
"<CMAKE_${lang}_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO}${_COMPILE_${lang}} <FLAGS> <DEFINES> /Fo<OBJECT> /Fd<OBJECT_DIR>/${_FS_${lang}} -c <SOURCE>${CMAKE_END_TEMP_FILE}")
"<CMAKE_${lang}_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO}${_COMPILE_${lang}} <FLAGS> <DEFINES> /Fo<OBJECT> /Fd<TARGET_COMPILE_PDB>${_FS_${lang}} -c <SOURCE>${CMAKE_END_TEMP_FILE}")
set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE
"<CMAKE_${lang}_COMPILER> > <PREPROCESSED_SOURCE> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO}${_COMPILE_${lang}} <FLAGS> <DEFINES> -E <SOURCE>${CMAKE_END_TEMP_FILE}")
set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE
......
......@@ -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")
......
......@@ -245,6 +245,7 @@ public:
}
cmTarget* CMTarget;
const char* TargetPDB;
const char* TargetCompilePDB;
const char* TargetVersionMajor;
const char* TargetVersionMinor;
const char* Language;
......
......@@ -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)
......
......@@ -129,6 +129,10 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
}
}
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 += "/";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment