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

Will

June 14th, 2017

We’re excited to announce improved CMake and Ninja support in Visual Studio 15.3 Preview 2. In this preview, we have updated CMake from version 3.7.2 to version 3.8 and added improved support for the CMake Ninja generator. Additionally, this preview includes several fixes for community reported bugs.

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.

We are trying to keep the version of CMake that is included in Visual Studio fresh as possible so you can use the latest and greatest features in your projects. To achieve that goal, we have upgraded the internal version of CMake the Visual Studio uses from CMake 3.7.2 to CMake 3.8.

You can find the full lists of enhancements in the CMake 3.8 release notes at cmake.org.

Target 64-bit Windows with Ninja

In the last preview we introduced support for the Ninja generator. Visual Studio now supports targeting 64-bit systems as well as 32-bit. The Ninja generator is now selected by default when you create a new CMakeSettings.json:

[code lang=”js”] { // See https://go.microsoft.com//fwlink//?linkid=834763 for more information about this file. "configurations": [ { "name": "x86-Debug", "generator": "Ninja", "configurationType" : "Debug", "referenceContexts": [ "msvc_x86" ], "buildRoot": "${env.LOCALAPPDATA}\\CMakeBuild\\${workspaceHash}\\build\\${name}", "cmakeCommandArgs": "", "buildCommandArgs": "-v", "ctestCommandArgs": "" }, { "name": "x86-Release", "generator": "Ninja", "configurationType" : "RelWithDebInfo", "referenceContexts": [ "msvc_x86" ], "buildRoot": "${env.LOCALAPPDATA}\\CMakeBuild\\${workspaceHash}\\build\\${name}", "cmakeCommandArgs": "", "buildCommandArgs": "-v", "ctestCommandArgs": "" }, { "name": "x64-Debug", "generator": "Ninja", "configurationType" : "Debug", "referenceContexts": [ "msvc_x64" ], "buildRoot": "${env.LOCALAPPDATA}\\CMakeBuild\\${workspaceHash}\\build\\${name}", "cmakeCommandArgs": "", "buildCommandArgs": "-v", "ctestCommandArgs": "" }, { "name": "x64-Release", "generator": "Ninja", "configurationType" : "RelWithDebInfo", "referenceContexts": [ "msvc_x64" ], "buildRoot": "${env.LOCALAPPDATA}\\CMakeBuild\\${workspaceHash}\\build\\${name}", "cmakeCommandArgs": "", "buildCommandArgs": "-v", "ctestCommandArgs": "" } ] } [/code]

To update an existing CMakeSettings.json file to use Ninja to build a 64-bit binary, simply update the the generator and referenceContexts. Or if you haven’t heavily customized it you can just delete the existing file and let Visual Studio generate a new one for you. It will default to the Ninja generator for all builds.

Bugfixes and Improvements

You gave us feedback and we listened. Visual Studio 2017 15.3 includes several improvements and addresses bugs reported by the community. The following issues have been fixed as of 2017 15.3 Preview 2:

Wrong configuration is built for CMake installation target under some circumstances. Developer Community: 49339

CMake target selector list shows duplicates. Developer Community: 49056, 49910

CMakeSettings.json does not expand variables. Developer Community: 46703

CMake generation fails if “Standard” is unchecked in “View->Toolbars”. Developer Community: 37195

CMAKE_MAKE_PROGRAM variable not defined in CMake tools for Visual Studio. Developer Community: 46389

CMake Tools for Visual Studio fail to load when selected as an individual component in the Visual Studio installer. Developer Community: 46143

Environment variables not properly inherited by CMake Tools for Visual Studio. Developer Community: 24474, 44177

CMake tools does not offer a “Rebuild” option. Developer Community: 22318

Cannot specify options to CTest. Developer Community: 17968

CTest tests still run if build step fails. Developer Community: 17949

CMake cache generation can get stuck with no option to cancel. Developer Community: 13799

Release builds cannot be debugged due to missing symbols. Developer Community: 13657

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!