CMake support in Visual Studio – what’s new in 2017 15.3 Preview

Will Buik

We are excited to announce the first preview release of Visual Studio 2017 15.3 update in conjunction with our Build 2017 conference!  This preview includes two new features of interest to developers utilizing CMake.  Support for the CMake Ninja generator and CMake CTest integration in the IDE.

Please download the preview and try out the latest CMake features.  If you are just getting started with CMake, follow the link to learn more about CMake support in Visual Studio.  We are looking forward to your feedback.

Build with Ninja

You asked for support for more CMake build generators and we listened.  The latest preview of the CMake tools for Visual Studio now support the Ninja build system.  Keep in mind, this is a preview so there are a few limitations.  The CMake tools for Visual Studio currently only support building for x86 and are not compatible with CTest.  In addition, Ninja builds are currently only supported on 64-bit OSes.  Don’t worry though, these limitations will be resolved by the time 15.3 hits the public channel.

To get started with the Ninja generator, you will need to edit your CMakeSettings.json file.  Right click on your CMakeLists.txt file and select “Change CMake Settings” to navigate to or create this file if you don’t already have one in your folder:

Edit CMake Settings

If you haven’t added a CMakeSettings.json file to your folder yet, you will see something like this:

CMake Settings JSON

You can choose the Ninja generator by setting the “generator” tag of each configuration you want to build using Ninja.  If you have an existing CMakeSettings.json file you will need to update the generator from “Visual Studio 15 2017” to “Ninja”.  Keep in mind, there isn’t support yet for x64 configurations.

The Ninja generator is selected by default for x86 builds in the preview releases of 15.3, but this will be changing once it is released to the public channel.

CTest Integration

New generators are great, but it is also important for developers to be assured of the quality of their code.  The preferred way to do this with CMake projects is to use CTest.  The good news, if you are already using CTest, you don’t need to do anything.  The latest preview of Visual Studio should detect the tests without any intervention on your part.

CTest Run Tests

If you don’t see the “Run Tests” menu item, make sure you are using the Visual Studio CMake generator in your CMakeSettings.json file.  This limitation will be resolved in a future release.

Once you select “Run Tests” from the CMake menu or by right clicking on your CMakeLists.txt file, your project will be automatically built, and your tests will run. The output is streamed to the CMake Output window – CTest is not yet integrated with the Test Explorer.

Send us Feedback

To try out the latest and greatest CMake features and give us some early feedback, please download and install the latest Visual Studio 2017 Preview.  As always, we welcome your feedback.  Feel free to send any comments through e-mail at cmake@microsoft.com, through Twitter @visualc, or Facebook at Microsoft Visual Cpp.

If you encounter other problems with Visual Studio 2017 please let us know via Report a Problem, which is available in both the installer and the IDE itself.  For suggestions, let us know through UserVoice. We look forward to your feedback!

0 comments

Discussion is closed.

Feedback usabilla icon