VSCode + cmake + windows 10 -> cmake not in path

Viewed 9620

I am new to VS Code and CMake in general. I come from 14 years of using Visual Studio and solution files. Now the industry wants me to be cross platform and do things in Linux. Well, I don't want to be a deprecated old man.

I downloaded VSCode and installed the cmake and cmake tools extensions. I created a folder, opened workspace, ctrl+shift+p and chose to configure, then chose VC++ as my compiler.

When I type cmake on the command line inside or outside of VS Code, it is not a recognized command. However, I can build with ctrl+shift+p cmake->Build.

How do I get cmake on the command line and use it as 'vector-of-bool' does in his video? https://www.youtube.com/watch?v=abuCXC3t6eQ

Where is the cmake executable it is currently using and should I just add that to the path?

I am on Windows 10 and had Visual Studio 2019 installed previous to trying the VSCode + cmake tools.

2 Answers

Visual Studio 16 2019 already includes a CMake installation in C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe. So my guess is that you are using this version inside VSCode.

To run an explicitely installed CMake you should download a CMake suitable for your platform from https://cmake.org/download install it and add the bin folder of the installation directory to your PATH variable, e.g. set PATH=C:\Program Files\CMake\bin;%PATH% on Windows.

After doing so you can easily use CMake from the command line.

If you are using vector-of-bool's (now Microsoft's) cmake tools then you do not need to use the command line for building.

ctrl + shift + p => cmake: build target will build everything for you.

To use cmake from command line, you need to add the cmake binary directory to system path. Most probably, C:\Program Files\CMake\bin.

Related