diff options
16 files changed, 142 insertions, 7 deletions
diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index db900e8..03a6a27 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -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 diff --git a/Help/prop_tgt/VS_DEBUGGER_COMMAND.rst b/Help/prop_tgt/VS_DEBUGGER_COMMAND.rst index f898750..ba5fd0a 100644 --- a/Help/prop_tgt/VS_DEBUGGER_COMMAND.rst +++ b/Help/prop_tgt/VS_DEBUGGER_COMMAND.rst @@ -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. diff --git a/Help/prop_tgt/VS_DEBUGGER_COMMAND_ARGUMENTS.rst b/Help/prop_tgt/VS_DEBUGGER_COMMAND_ARGUMENTS.rst new file mode 100644 index 0000000..06ef5d5 --- /dev/null +++ b/Help/prop_tgt/VS_DEBUGGER_COMMAND_ARGUMENTS.rst @@ -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. diff --git a/Help/prop_tgt/VS_DEBUGGER_ENVIRONMENT.rst b/Help/prop_tgt/VS_DEBUGGER_ENVIRONMENT.rst new file mode 100644 index 0000000..f55ac7b --- /dev/null +++ b/Help/prop_tgt/VS_DEBUGGER_ENVIRONMENT.rst @@ -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. diff --git a/Help/prop_tgt/VS_DEBUGGER_WORKING_DIRECTORY.rst b/Help/prop_tgt/VS_DEBUGGER_WORKING_DIRECTORY.rst index fb0389e..008bbf6 100644 --- a/Help/prop_tgt/VS_DEBUGGER_WORKING_DIRECTORY.rst +++ b/Help/prop_tgt/VS_DEBUGGER_WORKING_DIRECTORY.rst @@ -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. diff --git a/Help/release/dev/vs-debugger-improvements.rst b/Help/release/dev/vs-debugger-improvements.rst new file mode 100644 index 0000000..f1944bb --- /dev/null +++ b/Help/release/dev/vs-debugger-improvements.rst @@ -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. diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index f934178..129abdf 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -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 = diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index 0d178ce..d50de3d 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -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) diff --git a/Tests/RunCMake/VS10Project/VsDebuggerCommand-check.cmake b/Tests/RunCMake/VS10Project/VsDebuggerCommand-check.cmake index 0ded780..440f9f2 100644 --- a/Tests/RunCMake/VS10Project/VsDebuggerCommand-check.cmake +++ b/Tests/RunCMake/VS10Project/VsDebuggerCommand-check.cmake @@ -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() diff --git a/Tests/RunCMake/VS10Project/VsDebuggerCommand.cmake b/Tests/RunCMake/VS10Project/VsDebuggerCommand.cmake index e29adc4..5dcb6d1 100644 --- a/Tests/RunCMake/VS10Project/VsDebuggerCommand.cmake +++ b/Tests/RunCMake/VS10Project/VsDebuggerCommand.cmake @@ -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>") diff --git a/Tests/RunCMake/VS10Project/VsDebuggerCommandArguments-check.cmake b/Tests/RunCMake/VS10Project/VsDebuggerCommandArguments-check.cmake new file mode 100644 index 0000000..b2e0a43 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsDebuggerCommandArguments-check.cmake @@ -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() diff --git a/Tests/RunCMake/VS10Project/VsDebuggerCommandArguments.cmake b/Tests/RunCMake/VS10Project/VsDebuggerCommandArguments.cmake new file mode 100644 index 0000000..aa87cdc --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsDebuggerCommandArguments.cmake @@ -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>") diff --git a/Tests/RunCMake/VS10Project/VsDebuggerEnvironment-check.cmake b/Tests/RunCMake/VS10Project/VsDebuggerEnvironment-check.cmake new file mode 100644 index 0000000..2427ad4 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsDebuggerEnvironment-check.cmake @@ -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() diff --git a/Tests/RunCMake/VS10Project/VsDebuggerEnvironment.cmake b/Tests/RunCMake/VS10Project/VsDebuggerEnvironment.cmake new file mode 100644 index 0000000..d5bec4c --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsDebuggerEnvironment.cmake @@ -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>") diff --git a/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir-check.cmake b/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir-check.cmake index 637c68c..6a142f8 100644 --- a/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir-check.cmake +++ b/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir-check.cmake @@ -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() diff --git a/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir.cmake b/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir.cmake index a277c65..36daed0 100644 --- a/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir.cmake +++ b/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir.cmake @@ -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>") |