Merge topic 'VS_DEBUGGER_WORKING_DIRECTORY'

163e8018 VS: Add target property VS_DEBUGGER_WORKING_DIRECTORY
This commit is contained in:
Brad King 2016-12-01 08:50:30 -05:00 committed by CMake Topic Stage
commit 75f2a1e459
7 changed files with 49 additions and 0 deletions

View File

@ -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

View File

@ -0,0 +1,6 @@
VS_DEBUGGER_WORKING_DIRECTORY
-----------------------------
Sets the local debugger working directory for Visual Studio C++ targets.
This is defined in ``<LocalDebuggerWorkingDirectory>`` in the Visual Studio
project file.

View File

@ -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.

View File

@ -1569,6 +1569,14 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions()
*this->BuildFileStream << cmVS10EscapeXML(intermediateDir)
<< "</IntDir>\n";
if (const char* workingDir = this->GeneratorTarget->GetProperty(
"VS_DEBUGGER_WORKING_DIRECTORY")) {
this->WritePlatformConfigTag("LocalDebuggerWorkingDirectory",
config->c_str(), 3);
*this->BuildFileStream << cmVS10EscapeXML(workingDir)
<< "</LocalDebuggerWorkingDirectory>\n";
}
std::string name =
cmSystemTools::GetFilenameWithoutLastExtension(targetNameFull);
this->WritePlatformConfigTag("TargetName", config->c_str(), 3);

View File

@ -2,3 +2,4 @@ include(RunCMake)
run_cmake(VsConfigurationType)
run_cmake(VsTargetsFileReferences)
run_cmake(VsCustomProps)
run_cmake(VsDebuggerWorkingDir)

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(debuggerWorkDirSet FALSE)
file(STRINGS "${vcProjectFile}" lines)
foreach(line IN LISTS lines)
if(line MATCHES "^ *<LocalDebuggerWorkingDirectory[^>]*>([^<>]+)</LocalDebuggerWorkingDirectory>$")
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()

View File

@ -0,0 +1,5 @@
enable_language(CXX)
add_library(foo foo.cpp)
set_target_properties(foo PROPERTIES
VS_DEBUGGER_WORKING_DIRECTORY "my-debugger-directory")