From 163e8018098699b15f7aef9ded444aa72de49701 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20St=C3=BCrmer?= Date: Wed, 30 Nov 2016 17:20:31 +0100 Subject: VS: Add target property VS_DEBUGGER_WORKING_DIRECTORY --- Help/manual/cmake-properties.7.rst | 1 + Help/prop_tgt/VS_DEBUGGER_WORKING_DIRECTORY.rst | 6 ++++++ Help/release/dev/vs-debugger-config.rst | 6 ++++++ Source/cmVisualStudio10TargetGenerator.cxx | 8 ++++++++ Tests/RunCMake/VS10Project/RunCMakeTest.cmake | 1 + .../VS10Project/VsDebuggerWorkingDir-check.cmake | 22 ++++++++++++++++++++++ .../VS10Project/VsDebuggerWorkingDir.cmake | 5 +++++ 7 files changed, 49 insertions(+) create mode 100644 Help/prop_tgt/VS_DEBUGGER_WORKING_DIRECTORY.rst create mode 100644 Help/release/dev/vs-debugger-config.rst create mode 100644 Tests/RunCMake/VS10Project/VsDebuggerWorkingDir-check.cmake create mode 100644 Tests/RunCMake/VS10Project/VsDebuggerWorkingDir.cmake diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index b365fdf..e55524c 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -269,6 +269,7 @@ 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_DESKTOP_EXTENSIONS_VERSION /prop_tgt/VS_DOTNET_REFERENCES /prop_tgt/VS_DOTNET_TARGET_FRAMEWORK_VERSION diff --git a/Help/prop_tgt/VS_DEBUGGER_WORKING_DIRECTORY.rst b/Help/prop_tgt/VS_DEBUGGER_WORKING_DIRECTORY.rst new file mode 100644 index 0000000..0af85cb --- /dev/null +++ b/Help/prop_tgt/VS_DEBUGGER_WORKING_DIRECTORY.rst @@ -0,0 +1,6 @@ +VS_DEBUGGER_WORKING_DIRECTORY +----------------------------- + +Sets the local debugger working directory for Visual Studio C++ targets. +This is defined in ```` in the Visual Studio +project file. diff --git a/Help/release/dev/vs-debugger-config.rst b/Help/release/dev/vs-debugger-config.rst new file mode 100644 index 0000000..58873a5 --- /dev/null +++ b/Help/release/dev/vs-debugger-config.rst @@ -0,0 +1,6 @@ +vs-debugger-configuration +------------------------- + +* For the :ref:`Visual Studio Generators` for VS 2010 and above + the working directory for debugging can be set using a new + :prop_tgt:`VS_DEBUGGER_WORKING_DIRECTORY` target property. diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 5b99007..3632663 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1569,6 +1569,14 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions() *this->BuildFileStream << cmVS10EscapeXML(intermediateDir) << "\n"; + if (const char* workingDir = this->GeneratorTarget->GetProperty( + "VS_DEBUGGER_WORKING_DIRECTORY")) { + this->WritePlatformConfigTag("LocalDebuggerWorkingDirectory", + config->c_str(), 3); + *this->BuildFileStream << cmVS10EscapeXML(workingDir) + << "\n"; + } + std::string name = cmSystemTools::GetFilenameWithoutLastExtension(targetNameFull); this->WritePlatformConfigTag("TargetName", config->c_str(), 3); diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index d913af7..bc1ec97 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -2,3 +2,4 @@ include(RunCMake) run_cmake(VsConfigurationType) run_cmake(VsTargetsFileReferences) run_cmake(VsCustomProps) +run_cmake(VsDebuggerWorkingDir) diff --git a/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir-check.cmake b/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir-check.cmake new file mode 100644 index 0000000..637c68c --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir-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(debuggerWorkDirSet FALSE) + +file(STRINGS "${vcProjectFile}" lines) +foreach(line IN LISTS lines) + if(line MATCHES "^ *]*>([^<>]+)$") + if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-directory") + message(STATUS "foo.vcxproj has debugger working dir set") + set(debuggerWorkDirSet TRUE) + endif() + endif() +endforeach() + +if(NOT debuggerWorkDirSet) + set(RunCMake_TEST_FAILED "LocalDebuggerWorkingDirectory not found or not set correctly.") + return() +endif() diff --git a/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir.cmake b/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir.cmake new file mode 100644 index 0000000..a277c65 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir.cmake @@ -0,0 +1,5 @@ +enable_language(CXX) +add_library(foo foo.cpp) + +set_target_properties(foo PROPERTIES + VS_DEBUGGER_WORKING_DIRECTORY "my-debugger-directory") -- cgit v0.12