When using the cmake support in VS2022, as far as I know launch.vs.json is the place where I can add command line options for the executable I want to run.
Now, since it needs several dlls from different locations, in my case cmake uses configure_file() to create a launch.vs.json which sets PATH so that it finds the necessary dlls.
OTOH this means if a user adds some command line options to this file, they are lost as soon as cmake runs again.
What is the recommended way to do this ?
Can I include some files in launch.vs.son ?
Could the cmake presets in some way be extended so that IDEs could make use of it ?
Or is there like a user-launch.vs.json ?
Does the VS_DEBUGGER_COMMAND_ARGUMENTS target property get you close? Not ideal that you would have to embed it directly in the project, but you can probably force or override it via cmake_language(DEFER) and one of the code injection methods supported by the project() command if you needed to.
It’s more the case that for whatever reason, some user (developer) wants to debug using some special command line option, maybe because that command line option makes the executable crash.
So putting it in the CMakeLists.txt is not really nice.
Putting it in the launch.vs.json would be somewhat ok, if I wouldn’t have to configure_file() launch.vs.json in order to get the correct PATH so it can find the dlls…
Maybe I could check (in CMakeLists.txt) whether a file like mycmdlineargs.cmake exists in the source dir, and if so, read it, and configure its content into launch.vs.json ?
Then at least a user could get command line args into launch.vs.json, which would not be overwritten on the next cmake run, and the user would not have to edit a file which is in version control.
But it would require a cmake rerun to get the new command line args into launch.vs.json :-/