My project is being built using CMake. Visual Studio can open CMakeLists.txt directly, without vcxproj generation, this is very convenient.
My project also uses Qt and QML. If you open vcxproj, then the plug-in to Visual Studio - Qt VS Tool allows you to connect the debugger of QML files in your settings. And if you open CMakeLists.txt, then Qt VS Tools does not work and you have to manually connect the debugger. However, the official documentation is very laconic - about connecting the debugger there is only a short paragraph and it contains not correct information. From this document it is completely unclear how to actually connect the debugger for debugging QML.
I tried to do as Qt VS Tools does. It passes command line options to a debugged file. I tried passing the same parameters. In Visual Studio, the launch.vs.json file is responsible for launch settings under the debugger of a project built in CMake. I got it like this:
{
"version": "0.2.1",
"defaults": {},
"configurations": [
{
"type": "default",
"project": "CMakeLists.txt",
"projectTarget": "MyApp.exe (MyProj\\MyApp.exe)",
"name": "MyApp.exe (MyProj\\MyApp.exe)",
"env": "PATH = C:\\Qt\\5.13.0\\msvc2017_64\\bin; ${env.PATH}",
"args": ["-qmljsdebugger=file:MyApp.exe,block"]
}
]
}
Actually, the "args" line is responsible for connecting QML debugging: ["-qmljsdebugger = file: MyApp.exe, block"]. This line is copied from the one generated in Qt VS Tools. Only instead of the file name, the Qt VS Tool passes the GUID of the project there. Its line looks like this: -qmljsdebugger = file: {7A883E87-2CB8-3EB7-9DE4-156F3850167A}, block. CMakeLists.txt does not have any guids, so it is not clear what should be passed in the file parameter. The documentation claims to be a file name. It is not clear why Qt VS Tools passes the GUID there.
And the file build in CMake with such settings hangs at startup waiting the debugger connects to it. It is not clear how to connect the debugger to it, because the debugger is already connected to the process.
How to properly connect the Visual Studio debugger to process to debug QML files?