vscode-cmake-tools: CXX Variable not set

Brief Issue Summary

Visual Studio Code Version: 1.62.2 OS Version: Linux x64 5.13.19-2-MANJARO Extension Version: 1.9.1 (Latest?)

CXX variable is not set when I try to scan active kits.

Screenshot from 2021-11-15 14-41-33

As you can see, I set my kit to a compiler that is not a defaulted system one (my default gcc/g++ compiler is gcc-11)

Then, if I generate my project, cmake give me this output:

[proc] Executing command: /usr/bin/cmake --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER:FILEPATH=/bin/x86_64-pc-linux-gnu-gcc-10.3.0 -H/home/pablo/personal/cppStuff/fileBin -B/home/pablo/personal/cppStuff/fileBin/build -G "Unix Makefiles"
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The C compiler identification is GNU 10.3.0
[cmake] -- The CXX compiler identification is GNU 11.1.0

As you can see, the variable CMAKE_C_COMPILER is set, but not the CMAKE_CXX_COMPILER one.

If I try on a Debian OS, both variables are set when I scan for Active kits thumb-Clipboard - November 15, 2021 1_50 PM

So to solve this “problem” I modified the file ${HOME}/.local/share/CMakeTools/cmake-tools-kits.json and added manually all CXX variables.

For example: Generated by automated searching kits:

{
    "name": "Clang 12.0.1 x86_64-pc-linux-gnu",
    "compilers": {
      "C": "/bin/clang-12"
    }
  }

CXX Variable is not set, so I added a new entry:

{
    "name": "Clang 12",
    "compilers": {
      "C": "/bin/clang",
      "CXX": "/bin/clang++"
    }
  }

This happens with al compilers, and versions. CXX variable should not be added too automatically?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 17 (8 by maintainers)

Most upvoted comments

So it sounds like our scanning logic isn’t going to pair the C/CXX compilers the way you want by default. In this case, you can create your own Kits file and configure it the way you want.

Documentation: https://github.com/microsoft/vscode-cmake-tools/blob/main/docs/kits.md#project-kits

It sounds not good. Arch Linux frequently updates the compiler and I have to modify the configure each time 😦