vscode-cmake-tools icon indicating copy to clipboard operation
vscode-cmake-tools copied to clipboard

Should use the CMake file API to get toolchain details, not assume things are in CMakeCache.txt

Open craigscott-crascit opened this issue 1 year ago • 3 comments

Brief Issue Summary

#2121 describes the problem, but it was closed without actually identifying and fixing the underlying issue. The extension is assuming that CMAKE_C_COMPILER and CMAKE_CXX_COMPILER are set as cache variables, but this isn't always the case. A toolchain file can (and generally should) set these as regular non-cache variables. When it does so, same-named cache variables won't be created and the extension fails to start debugging due to them being missing.

The appropriate place for the extension to get reliable information about the toolchain is to use the CMake file API. It can use a query for the "Toolchains" object kind, which includes the path to the selected compiler.

CMake Tools Diagnostics

No response

Debug Log

No response

Additional Information

No response

craigscott-crascit avatar Sep 30 '24 02:09 craigscott-crascit

@craigscott-crascit Thanks for the issue and the information, we will investigate this. Thanks!

gcampbell-msft avatar Sep 30 '24 10:09 gcampbell-msft

Seems I reported this same problem twice 18 months apart. At least I was consistent I guess? You probably want to close this one as a duplicate of #3027, or vice versa.

craigscott-crascit avatar Aug 20 '25 01:08 craigscott-crascit

@craigscott-crascit Thank you for your reminder. We have duplicated issue #3027 to this issue. Thank you.

yanghhhhhhh avatar Aug 20 '25 06:08 yanghhhhhhh