How does "CMake Tools" set the compiler in CMake project?

Viewed 1130

After installing CMake Tools I choose a kit for my building (I have installed only GCC 10.2.1). List of kits is in fact just "cmake-tools-kits.json" file in CMake Tools directory, where pathes to compilers are defined. The question is: how does "CMake Tools" install the compiler for building in the project? As you can see on pictures there is no mention of a compiler in "CMakeLists.txt" file. How does it work? I want to build my project with CMake Tools as well as without it.

This is how the configuration command executed by CMake Tools looks like:

[cmakefileapi-driver] /usr/bin/cmake --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Release -H/home/user2/infotecs/App1/source -B/home/user2/infotecs/App1/source/build -G "Unix Makefiles"

And this is the build command that CMake Tools executes:

[main] /usr/bin/cmake --build /home/user2/infotecs/App1/source/build --config Release --target all -j 3 --

picture1

picture2

picture3

1 Answers

The project CMakeLists.txt will not specify a kit of course, as the kit is something specific to your machine. The kits are configured, as you correctly say, in cmake-tools-kits.json. In order to use a given kit for your project, you need to activate the kit. you can do it by pressing on the bottom bar in vscode, where it says "no active kits". Once you select the kit (you seem to have one in your machine), it will be used.

"Cmake Tool" sill not install any kit though. You need to install the compiler in your machine separately, and the tool will just scan for it.

Related