From 79ca546ed2d7d0ef546533978dfc4af4023d7194 Mon Sep 17 00:00:00 2001 From: Marian Klymov Date: Thu, 17 May 2018 00:19:56 +0300 Subject: Add generator expression support to PDB_OUTPUT_DIRECTORY target property Fixes: #16365 --- Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst | 10 ++++++++-- Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst | 3 +++ Help/release/dev/PDBDirectoryGenExpression.rst | 5 +++++ Source/cmGeneratorTarget.cxx | 15 +++++++++++++-- Tests/PDBDirectoryAndName/CMakeLists.txt | 10 ++++++++-- 5 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 Help/release/dev/PDBDirectoryGenExpression.rst diff --git a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst index 730cf57..2f667f3 100644 --- a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst +++ b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst @@ -5,8 +5,14 @@ Output directory for the MS debug symbols ``.pdb`` file generated by the linker for an executable or shared library target. This property specifies the directory into which the MS debug symbols -will be placed by the linker. This property is initialized by the -value of the :variable:`CMAKE_PDB_OUTPUT_DIRECTORY` variable if it is +will be placed by the linker. The property value may use +:manual:`generator expressions `. +Multi-configuration generators append a per-configuration +subdirectory to the specified directory unless a generator expression +is used. + +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` diff --git a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst index 6037fa0..77fda90 100644 --- a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst +++ b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst @@ -11,5 +11,8 @@ property is initialized by the value of the :variable:`CMAKE_PDB_OUTPUT_DIRECTORY_` variable if it is set when a target is created. +Contents of ``PDB_OUTPUT_DIRECTORY_`` may use +:manual:`generator expressions `. + .. |COMPILE_PDB_XXX| replace:: :prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY_` .. include:: PDB_NOTE.txt diff --git a/Help/release/dev/PDBDirectoryGenExpression.rst b/Help/release/dev/PDBDirectoryGenExpression.rst new file mode 100644 index 0000000..0b93a77 --- /dev/null +++ b/Help/release/dev/PDBDirectoryGenExpression.rst @@ -0,0 +1,5 @@ +PDBDirectoryGenExpression +------------------------- + +* The :prop_tgt:`PDB_OUTPUT_DIRECTORY` property learned to support + :manual:`generator expressions `. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 799ae95..0c99ed4 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4612,13 +4612,24 @@ bool cmGeneratorTarget::ComputePDBOutputDir(const std::string& kind, // Select an output directory. if (const char* config_outdir = this->GetProperty(configProp)) { // Use the user-specified per-configuration output directory. - out = config_outdir; + cmGeneratorExpression ge; + std::unique_ptr cge = + ge.Parse(config_outdir); + out = cge->Evaluate(this->LocalGenerator, config); // Skip per-configuration subdirectory. conf.clear(); } else if (const char* outdir = this->GetProperty(propertyName)) { // Use the user-specified output directory. - out = outdir; + cmGeneratorExpression ge; + std::unique_ptr cge = ge.Parse(outdir); + out = cge->Evaluate(this->LocalGenerator, config); + + // Skip per-configuration subdirectory if the value contained a + // generator expression. + if (out != outdir) { + conf.clear(); + } } if (out.empty()) { return false; diff --git a/Tests/PDBDirectoryAndName/CMakeLists.txt b/Tests/PDBDirectoryAndName/CMakeLists.txt index 2fb894e..6d8d6cc 100644 --- a/Tests/PDBDirectoryAndName/CMakeLists.txt +++ b/Tests/PDBDirectoryAndName/CMakeLists.txt @@ -19,7 +19,7 @@ set(my_targets "") add_library(mylibA SHARED mylibA.c) set_target_properties(mylibA PROPERTIES PDB_NAME "mylibA_Special" - PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mylibA_PDB" + PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mylibA_PDB/$" ) list(APPEND my_targets mylibA) @@ -87,7 +87,13 @@ foreach(t ${my_targets}) if(NOT pdb_dir) set(pdb_dir ${CMAKE_CURRENT_BINARY_DIR}) endif() - list(APPEND pdbs ${pdb_dir}/${CMAKE_CFG_INTDIR}/${pdb_name}.pdb) + if (pdb_dir MATCHES "\\$<.*>") + # Skip per-configuration subdirectory if the value contained + # a generator expression. + list(APPEND pdbs ${pdb_dir}/${pdb_name}.pdb) + else() + list(APPEND pdbs ${pdb_dir}/${CMAKE_CFG_INTDIR}/${pdb_name}.pdb) + endif() endforeach() add_custom_target(check_pdbs ALL VERBATIM COMMAND ${CMAKE_COMMAND} -Dconfig=$ "-Dpdbs=${pdbs}" -- cgit v0.12