I have set up a cmake project using visual studio 2019. I want to start the debug session with some command line parameters.
To achieve that, I've configured the CMakeLists.txt with the VS_DEBUGGER_COMMAND_ARGUMENTS
:
set( VS_DEBUGGER_COMMAND_ARGUMENTS "this" "is" "a" "test" )
set( VS_DEBUGGER_WORKING_DIRECTORY "." )
The first thing my C++ code do is to print out that parameters:
if (argc > 1) {
// config_file = argv[1];
for (std::size_t i = 0; i < argc; i++) {
std::cout << "argument " << i << ": " << argv[i] << std::endl;
}
}
else {
std::cout << "the value of argc is: " << argc << std::endl;
}
The problem is that when I run Debug, the output I've always see is the value of argc is 1
. I've also tried to modify the launch.vs.json
file as appears in this related question:
Adding command line arguments to project
and it doesn't work. Any ideas?