mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-08 14:50:10 -06:00
PDB: Always add the target per-config POSTFIX to .pdb names
Manage the POSTFIX target property in the same way as other artifacts names. Add policy CMP0202 for compatibility. Fixes: #27206
This commit is contained in:
@@ -2678,6 +2678,11 @@ In the following, the phrase "the ``tgt`` filename" means the name of the
|
||||
Full path to the linker generated program database file (.pdb)
|
||||
where ``tgt`` is the name of a target.
|
||||
|
||||
.. versionchanged:: 4.2
|
||||
The postfix, as specified by :prop_tgt:`DEBUG_POSTFIX` or
|
||||
:prop_tgt:`<CONFIG>_POSTFIX` target properties, is always included in the
|
||||
``PDB`` file name. See the policy :policy:`CMP0202`.
|
||||
|
||||
See also the :prop_tgt:`PDB_NAME` and :prop_tgt:`PDB_OUTPUT_DIRECTORY`
|
||||
target properties and their configuration specific variants
|
||||
:prop_tgt:`PDB_NAME_<CONFIG>` and :prop_tgt:`PDB_OUTPUT_DIRECTORY_<CONFIG>`.
|
||||
@@ -2689,6 +2694,11 @@ In the following, the phrase "the ``tgt`` filename" means the name of the
|
||||
Base name of the linker generated program database file (.pdb)
|
||||
where ``tgt`` is the name of a target.
|
||||
|
||||
.. versionchanged:: 4.2
|
||||
The postfix, as specified by :prop_tgt:`DEBUG_POSTFIX` or
|
||||
:prop_tgt:`<CONFIG>_POSTFIX` target properties, is always included in the
|
||||
``PDB`` base name. See the policy :policy:`CMP0202`.
|
||||
|
||||
The base name corresponds to the target PDB file name (see
|
||||
``$<TARGET_PDB_FILE_NAME:tgt>``) without prefix and suffix. For example,
|
||||
if target file name is ``base.pdb``, the base name is ``base``.
|
||||
|
||||
@@ -98,6 +98,7 @@ Policies Introduced by CMake 4.2
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
CMP0202: PDB file names always include their target's per-config POSTFIX. </policy/CMP0202>
|
||||
CMP0201: The Python::NumPy target does not depend on the Python::Module target. </policy/CMP0201>
|
||||
CMP0200: Location and configuration selection for imported targets is more consistent. </policy/CMP0200>
|
||||
CMP0199: $<CONFIG> only matches the configuration of the consumed target. </policy/CMP0199>
|
||||
|
||||
30
Help/policy/CMP0202.rst
Normal file
30
Help/policy/CMP0202.rst
Normal file
@@ -0,0 +1,30 @@
|
||||
CMP0202
|
||||
-------
|
||||
|
||||
.. versionadded:: 4.2
|
||||
|
||||
PDB file names always include their target's per-config POSTFIX.
|
||||
|
||||
Program database files (``.pdb``) are always named with their target's
|
||||
:prop_tgt:`DEBUG_POSTFIX` or :prop_tgt:`<CONFIG>_POSTFIX` target property
|
||||
value.
|
||||
|
||||
If the :prop_tgt:`PDB_NAME` target property is defined, CMake 4.1 and below
|
||||
exclude the target's per-config postfix from the program data base file name.
|
||||
Otherwise, the per-config postfix is included. This is inconsistent.
|
||||
CMake 4.2 and above prefer to always name the program database file with the
|
||||
per-config postfix regardless how the name is computed, i.e., using
|
||||
:prop_tgt:`OUTPUT_NAME`, or :prop_tgt:`PDB_NAME`, or neither. This policy
|
||||
provides compatibility with projects that have not been updated to account
|
||||
for the new behavior.
|
||||
|
||||
The ``OLD`` behavior for this policy does not use the per-config postfix in
|
||||
``.pdb`` file names if the :prop_tgt:`PDB_NAME` target property is defined.
|
||||
The ``NEW`` behavior always uses the per-config postfix in ``.pdb`` file
|
||||
names.
|
||||
|
||||
.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 4.2
|
||||
.. |WARNS_OR_DOES_NOT_WARN| replace:: does *not* warn
|
||||
.. include:: include/STANDARD_ADVICE.rst
|
||||
|
||||
.. include:: include/DEPRECATED.rst
|
||||
@@ -4334,7 +4334,11 @@ struct TargetOutputNameArtifactResultGetter<ArtifactPdbTag>
|
||||
return std::string();
|
||||
}
|
||||
|
||||
return target->GetPDBOutputName(eval->Context.Config);
|
||||
auto output = target->GetPDBOutputName(eval->Context.Config);
|
||||
|
||||
return target->GetPolicyStatusCMP0202() == cmPolicies::NEW
|
||||
? cmStrCat(output, target->GetFilePostfix(eval->Context.Config))
|
||||
: output;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -3979,9 +3979,11 @@ std::string cmGeneratorTarget::GetPDBOutputName(
|
||||
|
||||
// Now evaluate genex and update the previously-prepared map entry.
|
||||
if (outName.empty()) {
|
||||
i->second =
|
||||
this->GetOutputName(config, cmStateEnums::RuntimeBinaryArtifact) +
|
||||
this->GetFilePostfix(config);
|
||||
i->second = cmStrCat(
|
||||
this->GetOutputName(config, cmStateEnums::RuntimeBinaryArtifact),
|
||||
this->GetPolicyStatusCMP0202() != cmPolicies::NEW
|
||||
? this->GetFilePostfix(config)
|
||||
: "");
|
||||
} else {
|
||||
i->second =
|
||||
cmGeneratorExpression::Evaluate(outName, this->LocalGenerator, config);
|
||||
@@ -4004,7 +4006,11 @@ std::string cmGeneratorTarget::GetPDBName(std::string const& config) const
|
||||
|
||||
std::string base = this->GetPDBOutputName(config);
|
||||
|
||||
return parts.prefix + base + ".pdb";
|
||||
return cmStrCat(parts.prefix, base,
|
||||
this->GetPolicyStatusCMP0202() == cmPolicies::NEW
|
||||
? this->GetFilePostfix(config)
|
||||
: "",
|
||||
".pdb");
|
||||
}
|
||||
|
||||
std::string cmGeneratorTarget::GetObjectDirectory(
|
||||
|
||||
@@ -604,6 +604,9 @@ class cmMakefile;
|
||||
SELECT(POLICY, CMP0201, \
|
||||
"The Python::NumPy target does not depend on the Python::Module " \
|
||||
"target.", \
|
||||
4, 2, 0, WARN) \
|
||||
SELECT(POLICY, CMP0202, \
|
||||
"PDB file names always include their target's per-config POSTFIX.", \
|
||||
4, 2, 0, WARN)
|
||||
|
||||
#define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
|
||||
@@ -654,7 +657,8 @@ class cmMakefile;
|
||||
F(CMP0182) \
|
||||
F(CMP0195) \
|
||||
F(CMP0199) \
|
||||
F(CMP0200)
|
||||
F(CMP0200) \
|
||||
F(CMP0202)
|
||||
|
||||
#define CM_FOR_EACH_CUSTOM_COMMAND_POLICY(F) \
|
||||
F(CMP0116) \
|
||||
|
||||
@@ -92,6 +92,7 @@ else()
|
||||
endif()
|
||||
string (TOUPPER "${FIRST_CONFIG}" FIRST_CONFIG)
|
||||
|
||||
cmake_policy(SET CMP0202 OLD)
|
||||
|
||||
add_executable (exec4 empty.c)
|
||||
set_property (TARGET exec4 PROPERTY RUNTIME_OUTPUT_NAME exec4_runtime)
|
||||
@@ -141,6 +142,24 @@ check_value ("TARGET_PDB_FILE_BASE_NAME shared PDB all properties + postfix" "$<
|
||||
]])
|
||||
endif()
|
||||
|
||||
if (CMAKE_C_LINKER_SUPPORTS_PDB)
|
||||
cmake_policy(SET CMP0202 NEW)
|
||||
|
||||
add_executable (exec5 empty.c)
|
||||
set_property (TARGET exec5 PROPERTY PDB_NAME exec5_pdb)
|
||||
set_property (TARGET exec5 PROPERTY ${FIRST_CONFIG}_POSTFIX _postfix)
|
||||
add_library (shared5 SHARED empty.c)
|
||||
set_property (TARGET shared5 PROPERTY PDB_NAME shared5_pdb)
|
||||
set_property (TARGET shared5 PROPERTY ${FIRST_CONFIG}_POSTFIX _postfix)
|
||||
add_library (static5 STATIC empty.c)
|
||||
set_property (TARGET static5 PROPERTY PDB_NAME static5_pdb)
|
||||
set_property (TARGET static5 PROPERTY ${FIRST_CONFIG}_POSTFIX _postfix)
|
||||
|
||||
string (APPEND GENERATE_CONTENT [[
|
||||
check_value ("TARGET_PDB_FILE_BASE_NAME executable PDB all properties + postfix" "$<TARGET_PDB_FILE_BASE_NAME:exec5>" "exec5_pdb_postfix")
|
||||
check_value ("TARGET_PDB_FILE_BASE_NAME shared PDB all properties + postfix" "$<TARGET_PDB_FILE_BASE_NAME:shared5>" "shared5_pdb_postfix")
|
||||
]])
|
||||
endif()
|
||||
|
||||
file (GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/TARGET_FILE_BASE_NAME-generated.cmake"
|
||||
CONTENT "${GENERATE_CONTENT}" ${GENERATE_CONDITION})
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
\* CMP0195
|
||||
\* CMP0199
|
||||
\* CMP0200
|
||||
\* CMP0202
|
||||
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
|
||||
Reference in New Issue
Block a user