VS10Project: Expand VS_DEBUGGER_* capabilities

This adds VS_DEBUGGER_COMMAND_ARGUMENTS and VS_DEBUGGER_ENVIRONMENT as
well as allowing VS_DEBUGGER_* to use generator expressions.
This commit is contained in:
Jon Chronopoulos 2018-06-17 17:55:27 +10:00
parent 55c3435ce9
commit 797de7a6f6
16 changed files with 142 additions and 7 deletions

View File

@ -303,8 +303,10 @@ Properties on Targets
/prop_tgt/VERSION
/prop_tgt/VISIBILITY_INLINES_HIDDEN
/prop_tgt/VS_CONFIGURATION_TYPE
/prop_tgt/VS_DEBUGGER_WORKING_DIRECTORY
/prop_tgt/VS_DEBUGGER_COMMAND
/prop_tgt/VS_DEBUGGER_COMMAND_ARGUMENTS
/prop_tgt/VS_DEBUGGER_ENVIRONMENT
/prop_tgt/VS_DEBUGGER_WORKING_DIRECTORY
/prop_tgt/VS_DESKTOP_EXTENSIONS_VERSION
/prop_tgt/VS_DOTNET_REFERENCE_refname
/prop_tgt/VS_DOTNET_REFERENCEPROP_refname_TAG_tagname

View File

@ -2,6 +2,8 @@ VS_DEBUGGER_COMMAND
-------------------
Sets the local debugger command for Visual Studio C++ targets.
The property value may use
:manual:`generator expressions <cmake-generator-expressions(7)>`.
This is defined in ``<LocalDebuggerCommand>`` in the Visual Studio
project file.

View File

@ -0,0 +1,11 @@
VS_DEBUGGER_COMMAND_ARGUMENTS
-----------------------------
Sets the local debugger command line arguments for Visual Studio C++ targets.
The property value may use
:manual:`generator expressions <cmake-generator-expressions(7)>`.
This is defined in ``<LocalDebuggerCommandArguments>`` in the Visual Studio
project file.
This property only works for Visual Studio 2010 and above;
it is ignored on other generators.

View File

@ -0,0 +1,11 @@
VS_DEBUGGER_ENVIRONMENT
-----------------------
Sets the local debugger environment for Visual Studio C++ targets.
The property value may use
:manual:`generator expressions <cmake-generator-expressions(7)>`.
This is defined in ``<LocalDebuggerEnvironment>`` in the Visual Studio
project file.
This property only works for Visual Studio 2010 and above;
it is ignored on other generators.

View File

@ -2,6 +2,8 @@ VS_DEBUGGER_WORKING_DIRECTORY
-----------------------------
Sets the local debugger working directory for Visual Studio C++ targets.
The property value may use
:manual:`generator expressions <cmake-generator-expressions(7)>`.
This is defined in ``<LocalDebuggerWorkingDirectory>`` in the Visual Studio
project file.

View File

@ -0,0 +1,14 @@
vs-debugger-improvements
------------------------
* A :prop_tgt:`VS_DEBUGGER_COMMAND_ARGUMENTS` target property was created to
set the debugging command line arguments with
:ref:`Visual Studio Generators` for VS 2010 and above.
* A :prop_tgt:`VS_DEBUGGER_ENVIRONMENT` target property was created to
set the debugging environment with
:ref:`Visual Studio Generators` for VS 2010 and above.
* :prop_tgt:`VS_DEBUGGER_COMMAND`
:prop_tgt:`VS_DEBUGGER_COMMAND_ARGUMENTS`
:prop_tgt:`VS_DEBUGGER_ENVIRONMENT`
:prop_tgt:`VS_DEBUGGER_WORKING_DIRECTORY`
target properties can use generator expressions.

View File

@ -2286,14 +2286,51 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions(
if (const char* workingDir = this->GeneratorTarget->GetProperty(
"VS_DEBUGGER_WORKING_DIRECTORY")) {
cmGeneratorExpression ge;
std::unique_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(workingDir);
std::string genWorkingDir =
cge->Evaluate(this->LocalGenerator, config);
e1.WritePlatformConfigTag("LocalDebuggerWorkingDirectory", cond,
workingDir);
genWorkingDir);
}
if (const char* environment =
this->GeneratorTarget->GetProperty("VS_DEBUGGER_ENVIRONMENT")) {
cmGeneratorExpression ge;
std::unique_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(environment);
std::string genEnvironment =
cge->Evaluate(this->LocalGenerator, config);
e1.WritePlatformConfigTag("LocalDebuggerEnvironment", cond,
genEnvironment);
}
if (const char* debuggerCommand =
this->GeneratorTarget->GetProperty("VS_DEBUGGER_COMMAND")) {
cmGeneratorExpression ge;
std::unique_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(debuggerCommand);
std::string genDebuggerCommand =
cge->Evaluate(this->LocalGenerator, config);
e1.WritePlatformConfigTag("LocalDebuggerCommand", cond,
debuggerCommand);
genDebuggerCommand);
}
if (const char* commandArguments = this->GeneratorTarget->GetProperty(
"VS_DEBUGGER_COMMAND_ARGUMENTS")) {
cmGeneratorExpression ge;
std::unique_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(commandArguments);
std::string genCommandArguments =
cge->Evaluate(this->LocalGenerator, config);
e1.WritePlatformConfigTag("LocalDebuggerCommandArguments", cond,
genCommandArguments);
}
std::string name =

View File

@ -7,6 +7,8 @@ run_cmake(VsTargetsFileReferences)
run_cmake(VsCustomProps)
run_cmake(VsDebuggerWorkingDir)
run_cmake(VsDebuggerCommand)
run_cmake(VsDebuggerCommandArguments)
run_cmake(VsDebuggerEnvironment)
run_cmake(VsCSharpCustomTags)
run_cmake(VsCSharpReferenceProps)
run_cmake(VsCSharpWithoutSources)

View File

@ -9,7 +9,7 @@ set(debuggerCommandSet FALSE)
file(STRINGS "${vcProjectFile}" lines)
foreach(line IN LISTS lines)
if(line MATCHES "^ *<LocalDebuggerCommand[^>]*>([^<>]+)</LocalDebuggerCommand>$")
if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-command")
if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-command foo")
message(STATUS "foo.vcxproj has debugger command set")
set(debuggerCommandSet TRUE)
endif()

View File

@ -2,4 +2,4 @@ enable_language(CXX)
add_library(foo foo.cpp)
set_target_properties(foo PROPERTIES
VS_DEBUGGER_COMMAND "my-debugger-command")
VS_DEBUGGER_COMMAND "my-debugger-command $<TARGET_PROPERTY:foo,NAME>")

View File

@ -0,0 +1,22 @@
set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj")
if(NOT EXISTS "${vcProjectFile}")
set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
return()
endif()
set(debuggerCommandArgumentsSet FALSE)
file(STRINGS "${vcProjectFile}" lines)
foreach(line IN LISTS lines)
if(line MATCHES "^ *<LocalDebuggerCommandArguments[^>]*>([^<>]+)</LocalDebuggerCommandArguments>$")
if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-command-arguments foo")
message(STATUS "foo.vcxproj has debugger command arguments set")
set(debuggerCommandArgumentsSet TRUE)
endif()
endif()
endforeach()
if(NOT debuggerCommandArgumentsSet)
set(RunCMake_TEST_FAILED "LocalDebuggerCommandArguments not found or not set correctly.")
return()
endif()

View File

@ -0,0 +1,5 @@
enable_language(CXX)
add_library(foo foo.cpp)
set_target_properties(foo PROPERTIES
VS_DEBUGGER_COMMAND_ARGUMENTS "my-debugger-command-arguments $<TARGET_PROPERTY:foo,NAME>")

View File

@ -0,0 +1,22 @@
set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj")
if(NOT EXISTS "${vcProjectFile}")
set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
return()
endif()
set(debuggerEnvironmentSet FALSE)
file(STRINGS "${vcProjectFile}" lines)
foreach(line IN LISTS lines)
if(line MATCHES "^ *<LocalDebuggerEnvironment[^>]*>([^<>]+)</LocalDebuggerEnvironment>$")
if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-environment foo")
message(STATUS "foo.vcxproj has debugger environment set")
set(debuggerEnvironmentSet TRUE)
endif()
endif()
endforeach()
if(NOT debuggerEnvironmentSet)
set(RunCMake_TEST_FAILED "LocalDebuggerEnvironment not found or not set correctly.")
return()
endif()

View File

@ -0,0 +1,5 @@
enable_language(CXX)
add_library(foo foo.cpp)
set_target_properties(foo PROPERTIES
VS_DEBUGGER_ENVIRONMENT "my-debugger-environment $<TARGET_PROPERTY:foo,NAME>")

View File

@ -9,7 +9,7 @@ set(debuggerWorkDirSet FALSE)
file(STRINGS "${vcProjectFile}" lines)
foreach(line IN LISTS lines)
if(line MATCHES "^ *<LocalDebuggerWorkingDirectory[^>]*>([^<>]+)</LocalDebuggerWorkingDirectory>$")
if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-directory")
if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-directory foo")
message(STATUS "foo.vcxproj has debugger working dir set")
set(debuggerWorkDirSet TRUE)
endif()

View File

@ -2,4 +2,4 @@ enable_language(CXX)
add_library(foo foo.cpp)
set_target_properties(foo PROPERTIES
VS_DEBUGGER_WORKING_DIRECTORY "my-debugger-directory")
VS_DEBUGGER_WORKING_DIRECTORY "my-debugger-directory $<TARGET_PROPERTY:foo,NAME>")