Add generator-agnostic DEBUGGER_WORKING_DIRECTORY target property
Generalize the `VS_DEBUGGER_WORKING_DIRECTORY` property. Issue: #16478
This commit is contained in:
parent
200efab4d4
commit
9ed178f9d8
@ -155,6 +155,7 @@ syn keyword cmakeProperty contained
|
||||
\ C_STANDARD_REQUIRED
|
||||
\ DEBUG_CONFIGURATIONS
|
||||
\ DEBUG_POSTFIX
|
||||
\ DEBUGGER_WORKING_DIRECTORY
|
||||
\ DEFINE_SYMBOL
|
||||
\ DEFINITIONS
|
||||
\ DEPENDS
|
||||
@ -1140,6 +1141,7 @@ syn keyword cmakeVariable contained
|
||||
\ CMAKE_C_VISIBILITY_PRESET
|
||||
\ CMAKE_DEBUG_POSTFIX
|
||||
\ CMAKE_DEBUG_TARGET_PROPERTIES
|
||||
\ CMAKE_DEBUGGER_WORKING_DIRECTORY
|
||||
\ CMAKE_DEFAULT_BUILD_TYPE
|
||||
\ CMAKE_DEFAULT_CONFIGS
|
||||
\ CMAKE_DEPENDS_IN_PROJECT_ONLY
|
||||
|
@ -204,6 +204,7 @@ Properties on Targets
|
||||
/prop_tgt/CXX_STANDARD
|
||||
/prop_tgt/CXX_STANDARD_REQUIRED
|
||||
/prop_tgt/DEBUG_POSTFIX
|
||||
/prop_tgt/DEBUGGER_WORKING_DIRECTORY
|
||||
/prop_tgt/DEFINE_SYMBOL
|
||||
/prop_tgt/DEPLOYMENT_ADDITIONAL_FILES
|
||||
/prop_tgt/DEPLOYMENT_REMOTE_DIRECTORY
|
||||
|
@ -434,6 +434,7 @@ Variables that Control the Build
|
||||
/variable/CMAKE_CXX_MODULE_STD
|
||||
/variable/CMAKE_CXX_SCAN_FOR_MODULES
|
||||
/variable/CMAKE_DEBUG_POSTFIX
|
||||
/variable/CMAKE_DEBUGGER_WORKING_DIRECTORY
|
||||
/variable/CMAKE_DEFAULT_BUILD_TYPE
|
||||
/variable/CMAKE_DEFAULT_CONFIGS
|
||||
/variable/CMAKE_DEPENDS_USE_COMPILER
|
||||
|
11
Help/prop_tgt/DEBUGGER_WORKING_DIRECTORY.rst
Normal file
11
Help/prop_tgt/DEBUGGER_WORKING_DIRECTORY.rst
Normal file
@ -0,0 +1,11 @@
|
||||
DEBUGGER_WORKING_DIRECTORY
|
||||
--------------------------
|
||||
|
||||
.. versionadded:: 3.32
|
||||
|
||||
Sets the local debugger working directory for C++ targets.
|
||||
The property value may use
|
||||
:manual:`generator expressions <cmake-generator-expressions(7)>`.
|
||||
This property is initialized by the value of the variable
|
||||
:variable:`CMAKE_DEBUGGER_WORKING_DIRECTORY` if it is set when a target is
|
||||
created.
|
9
Help/release/dev/debugger-working-directory.rst
Normal file
9
Help/release/dev/debugger-working-directory.rst
Normal file
@ -0,0 +1,9 @@
|
||||
debugger-working-directory
|
||||
--------------------------
|
||||
|
||||
* The :variable:`CMAKE_DEBUGGER_WORKING_DIRECTORY` was added to
|
||||
initialize the corresponding target property.
|
||||
|
||||
* The :prop_tgt:`DEBUGGER_WORKING_DIRECTORY` target property was added
|
||||
to tell generators what debugger working directory should be set for
|
||||
the target.
|
8
Help/variable/CMAKE_DEBUGGER_WORKING_DIRECTORY.rst
Normal file
8
Help/variable/CMAKE_DEBUGGER_WORKING_DIRECTORY.rst
Normal file
@ -0,0 +1,8 @@
|
||||
CMAKE_DEBUGGER_WORKING_DIRECTORY
|
||||
--------------------------------
|
||||
|
||||
.. versionadded:: 3.32
|
||||
|
||||
This variable is used to initialize the :prop_tgt:`DEBUGGER_WORKING_DIRECTORY`
|
||||
property on each target as it is created. See that target property
|
||||
for additional information.
|
@ -3499,6 +3499,12 @@ void cmGlobalGenerator::AppendDirectoryForConfig(const std::string& /*unused*/,
|
||||
// configuration.
|
||||
}
|
||||
|
||||
cmValue cmGlobalGenerator::GetDebuggerWorkingDirectory(
|
||||
cmGeneratorTarget* gt) const
|
||||
{
|
||||
return gt->GetProperty("DEBUGGER_WORKING_DIRECTORY");
|
||||
}
|
||||
|
||||
cmGlobalGenerator::TargetDependSet const&
|
||||
cmGlobalGenerator::GetTargetDirectDepends(cmGeneratorTarget const* target)
|
||||
{
|
||||
|
@ -513,6 +513,8 @@ public:
|
||||
// Default config to use for cmake --build
|
||||
virtual std::string GetDefaultBuildConfig() const { return "Debug"; }
|
||||
|
||||
virtual cmValue GetDebuggerWorkingDirectory(cmGeneratorTarget* gt) const;
|
||||
|
||||
// Class to track a set of dependencies.
|
||||
using TargetDependSet = cmTargetDependSet;
|
||||
|
||||
|
@ -93,6 +93,16 @@ bool cmGlobalVisualStudioGenerator::InitializePlatform(cmMakefile*)
|
||||
return true;
|
||||
}
|
||||
|
||||
cmValue cmGlobalVisualStudioGenerator::GetDebuggerWorkingDirectory(
|
||||
cmGeneratorTarget* gt) const
|
||||
{
|
||||
if (cmValue ret = gt->GetProperty("VS_DEBUGGER_WORKING_DIRECTORY")) {
|
||||
return ret;
|
||||
} else {
|
||||
return cmGlobalGenerator::GetDebuggerWorkingDirectory(gt);
|
||||
}
|
||||
}
|
||||
|
||||
std::string const& cmGlobalVisualStudioGenerator::GetPlatformName() const
|
||||
{
|
||||
if (!this->GeneratorPlatform.empty()) {
|
||||
|
@ -78,6 +78,8 @@ public:
|
||||
*/
|
||||
virtual std::string GetUserMacrosRegKeyBase();
|
||||
|
||||
cmValue GetDebuggerWorkingDirectory(cmGeneratorTarget* gt) const override;
|
||||
|
||||
enum MacroName
|
||||
{
|
||||
MacroReload,
|
||||
|
@ -373,6 +373,8 @@ struct TargetProperty
|
||||
|
||||
TargetProperty const StaticTargetProperties[] = {
|
||||
/* clang-format off */
|
||||
// -- Debugger Properties
|
||||
{ "DEBUGGER_WORKING_DIRECTORY"_s, IC::ExecutableTarget },
|
||||
// Compilation properties
|
||||
{ "COMPILE_WARNING_AS_ERROR"_s, IC::CanCompileSources },
|
||||
{ "INTERPROCEDURAL_OPTIMIZATION"_s, IC::CanCompileSources },
|
||||
|
@ -3167,8 +3167,9 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions(
|
||||
}
|
||||
|
||||
if (ttype <= cmStateEnums::UTILITY) {
|
||||
if (cmValue workingDir = this->GeneratorTarget->GetProperty(
|
||||
"VS_DEBUGGER_WORKING_DIRECTORY")) {
|
||||
if (cmValue workingDir =
|
||||
this->GlobalGenerator->GetDebuggerWorkingDirectory(
|
||||
this->GeneratorTarget)) {
|
||||
std::string genWorkingDir = cmGeneratorExpression::Evaluate(
|
||||
*workingDir, this->LocalGenerator, config);
|
||||
e1.WritePlatformConfigTag("LocalDebuggerWorkingDirectory", cond,
|
||||
|
Loading…
Reference in New Issue
Block a user