Is there a way to configure the Visual Studio 2019 integrated CMake version? There are features in the latest CMake version that I would like to use, but I'm forced to build from the command line in this case. If I build from the VS IDE, the CMake version used is the Visual Studio-integrated one. I would like to change it if possible.
-
If you want to stick with the built-in version, I guess like you can open a [bug report](https://developercommunity.visualstudio.com/idea/351720/update-the-bundled-cmake-to-version-312.html) about it. – mirh Nov 30 '20 at 12:57
4 Answers
You can download the latest CMake from here to your system. To point Visual Studio to this latest version, you have to edit your CMakeSettings.json file. You must change the value of the cmakeExecutable
option to the installed location of the latest CMake version.
CMakeSettings.json:
...
"cmakeExecutable": "C:/path/to/new/cmake/executable",
...

- 16,549
- 8
- 60
- 74
-
2This works for Visual Studio generator. If I use Ninja generator VS falls back to the integrated version of cmake. – marcks Nov 09 '19 at 08:58
-
1@marcks It sounds like that may be a bug in Visual Studio. It may be worth looking for or opening up a new bug report, if that is the case. – Kevin Nov 09 '19 at 14:46
-
3I have reported the problem to the visual studio developers community [here](https://developercommunity.visualstudio.com/content/problem/814128/how-perform-visual-studio-2019-ninja-builds-with-c.html). I have also opened a new question on stackoverflow [here](https://stackoverflow.com/questions/58778775/how-perform-visual-studio-2019-ninja-builds-with-custom-cmake-version) – marcks Nov 09 '19 at 15:38
-
@marcks Changing the CMake executable requires regenerating the CMake cache. Visual Studio won't automatically do that, though. Select `Project >> Delete Cache and Reconfigure`. – John Dec 08 '21 at 20:39
-
1Hope this works for VS 2019. The given setting was completely ignored in my case in VS 2017. – rbaleksandar Dec 14 '21 at 07:59
-
1Can you provide more information about this CMakeSettings.json file? What is it? Where can we find it? – Mike R Aug 15 '22 at 18:11
-
@MikeR See the MS reference [here](https://learn.microsoft.com/en-us/cpp/build/cmakesettings-reference?view=msvc-170). – Kevin Aug 15 '22 at 20:28
I myself tried with Visual Studio 2019 (Community Edition) and I just had to configure the VS160COMNTOOLS
variable so that CMake correctly detects Visual Studio.
export VS160COMNTOOLS="/c/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/Tools"
(cf https://cmake.org/cmake/help/latest/generator/Visual%20Studio%2016%202019.html)
NB: in my case, in a Travis-CI workflow, I installed Visual Studio using the commands:
choco install visualstudio2019community
choco install visualstudio2019-workload-nativedesktop # required
With only the first package, CMake detection of VS2019 failed.

- 1,431
- 8
- 18
-
2On travis-ci, I would suggest to just install the build tools: `choco install visualstudio2019buildtools --package-parameters "--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64"` – cansik Jul 25 '20 at 15:17
If you are building in VS2019 with CMakePresets.json
instead of proprietary configs in CMakeSettings.json
, then I found no other way then replacing the CMake files in VS folder. I had no problems since replacing the files.
They are located here:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake
Should this path not be correct on your machine, you can also see this in the CMake Output window:

- 1,483
- 1
- 17
- 38
setting cmakeExecutable
worked for me (vs 2022). I just add another note that the path to cmake executable is machine-specific. If you want to hide it, you can use Enviroment variable. Just create a new environment variable in Windows and reference to it in CMakeSettings.json
:
...
"cmakeExecutable": "${env.cmake_path}"
...

- 401
- 3
- 8