Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 685
Christopher Pisz Avatar asked May 06 '20 01:05

Christopher Pisz


People also ask

How do I add CMake path to VS Code?

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.

How do I get to CMake path?

CMake will use whatever path the running CMake executable is in. Furthermore, it may get confused if you switch paths between runs without clearing the cache. So what you have to do is simply instead of running cmake <path_to_src> from the command line, run ~/usr/cmake-path/bin/cmake <path_to_src> .


Video Answer


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.

like image 148
vre Avatar answered Oct 17 '22 05:10

vre


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.

like image 31
Roy2511 Avatar answered Oct 17 '22 05:10

Roy2511