Neumann-A / vcpkg-cmake-debugging

Example of to debug vcpkg portfiles or port internal s

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

vcpkg-cmake-debugging

Example for how to debug vcpkg portfiles with the VS CMake extension (currently only windows)

How does it work?

'cmake.cmakePath' is set to 'vcpkg-debug.bat' as long as no debugger is getting attached cmake is called normally. As soon as a debugger is attached vcpkg-debug.bat calls vcpkg with the correct '--x-cmake-args' to pass on the debugger info to cmake in vcpkg. The rest ist magic ;). Port being configured inside vcpkg cannot currently be debuged due to limitations of the debugger extension waiting for 'Waiting for debugger client to connect...' in stdout which never gets triggered since vcpkg/cmake writes the configure output to a file instead. microsoft/vscode-cmake-tools#3248 needs to be resolved.

What is required?

  • VSCode with CMake-Tools extension version 1.15 (preview mode)
  • CMake 3.27.0
  • vcpkg with cmake 3.27.0 internally used (deleted the CMake folders from downloads; vcpkg tends to use its own cmake version if it is available)
  • Adjust the variables, explicitly vcpkg_exe, in the batch script to your case (Yeah I could run cmake in FetchContent mode to pull vcpkg for you but ..... no ;) )
  • a breakpoint in the portfile.cmake or somewhere cmake will hit since otherwise the debugger will just instantly close again.

Troubleshooting

  • If the debugger hangs idefinetly you probably did something wrong. My best guess here is that vcpkg did not use cmake 3.27
  • If you see stdout-x64-windows-release.log: permission denied you screwed up and there is a competing vcpkg process trying to write to the same file. Just kill all vcpkg instances and retry
  • closing vs code and reopening also helps if the debugger hangs

About

Example of to debug vcpkg portfiles or port internal s

License:MIT License


Languages

Language:Batchfile 95.7%Language:CMake 4.3%