<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0"></p>
<div>It turns out that the solution is to replace "$(TargetPath)" and "$(TargetDir)" with the CMake generator expressions "`$<TARGET_FILE:myApplication>`" and "`$<TARGET_FILE_DIR:myApplication>`", respectively, viz:</div>
<div><br>
</div>
<div> set_target_properties(myApplication PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "$<TARGET_FILE_DIR:myApplication>"</div>
<div> VS_DEBUGGER_COMMAND "$<TARGET_FILE:myApplication>"</div>
<div> VS_DEBUGGER_ENVIRONMENT "PATH=%PATH%;${CMAKE_PREFIX_PATH}/bin")</div>
<br>
<p></p>
<br>
<br>
<div style="color: rgb(0, 0, 0);">
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Stephen Morris<br>
<b>Sent:</b> 16 April 2019 17:36<br>
<b>To:</b> cmake@cmake.org<br>
<b>Subject:</b> Correct use of VS_DEBUGGER_WORKING_DIRECTORY etc.</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">I’m trying to use the new VS_DEBUGGER_WORKING_DIRECTORY and VS_DEBUGGER_COMMAND properties to facilitate debugging in a CMake-generated Visual Studio project file (in my case Visual Studio 2013).<br>
<br>
Everything else in my configuration works except this…<br>
<br>
I’ve noted from ‘regular’ Visual Studio project files (i.e. ones not generated from CMake that, in the “Configuration Properties/Debugging” dialog, the ‘Command’ and ‘Working Directory’ fields are populated by default with $(TargetPath) and $(TargetDir) respectively.
So in my CMakeLists.txt file, I have:<br>
<br>
set_target_properties(myApplication PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "$(TargetDir)"<br>
VS_DEBUGGER_COMMAND "$(TargetPath)"<br>
VS_DEBUGGER_ENVIRONMENT "%PATH%;C:\\Qt\\5.9.7\\msvc2013_64\\bin")<br>
<br>
[In fact I've tried this with and without the quotes around $(TargetDir) and $(TargetPath) and the result is the same each time; they're absolutely necessary around the path.]<br>
<br>
What happens is that I then build the application, go to the “Configuration Properties/Debugging” dialog and verify that it looks exactly the same as a normal project file, with $(TargetDir) and $(TargetPath) appearing exactly where they should do. It doesn't
work though; when I try to debug I get a message saying "Unable to start debugging. Check your debugger settings..."<br>
<br>
So I delete the text $(TargetDir) and $(TargetPath) from the dialog, then type them in again exactly as before: and then it works perfectly.<br>
<br>
What am I doing wrong?<br>
</div>
</span></font></div>
</div>
</div>
</body>
</html>