I use CMake to configure and generate makefiles for a Microsoft MPI project that I build and run from Visual Studio 2017. In order to run the project, I need to modify the VS solution configuration settings. Under Configuration Settings->Debugging, I want to specify "Command" and "Command Arguments" from the CMakeLists.txt. I can do this manually but I want to set it up from the CMakeLists.txt. Are there commands to do this?
2 Answers
CMake 3.12 introduced two new target properties for that purpose: VS_DEBUGGER_COMMAND and VS_DEBUGGER_COMMAND_ARGUMENTS. Set these properties in the following way:
set_target_properties(targetName PROPERTIES VS_DEBUGGER_COMMAND "debug_command" VS_DEBUGGER_COMMAND_ARGUMENTS "debug_arguments") 1 Comment
ixSci
12 introduced only the first one, and 13 the second one.
for anyone look for a solution on visual studio code with cmake extension, here is a solution:
change program field in launch.json to ${command:cmake.launchTargetPath},
ref: link