3

This question is similar to How to use the new Visual Studio 2017 cmake features with gitlab CI runners but I didn't want to change the other question in case people are really looking for a specific gitlab-ci solution. If they are too similar than maybe this one should be closed.

Independently of gitlab-ci I would like to know how to compile cmake projects with the new Visual Studio 2017 from script or a command prompt. For previous versions msbuild was used together with a *.sln file (see How do I compile a Visual Studio project from the command-line?). But now that you do no longer have to provide a *.sln file to open a project but can simply open a folder (and VS will take care of creating internally some sort of solution), I was wondering if things also get easier on the command line side.

Community
  • 1
  • 1
NOhs
  • 2,780
  • 3
  • 25
  • 59

1 Answers1

1

I would say no, VS 2017 does not make building CMake projects from the command line easier (yet).

Calling devenv commands with a directory will give an "unexpected error":

> devenv . /Build x86-Debug /Project HelloWorld

Microsoft Visual Studio 2017 Version 15.0.26228.9.
Copyright (C) Microsoft Corp. All rights reserved.

Visual Studio has encountered an unexpected error.

The CMake VS 2017 integration is just meant to better support CMake directly out-of the IDE (see also Visual C++ Team Blog - CMake support in Visual Studio).

So just use plain cmake calls to build from the command line.

For the scripts I'm using in my projects to build VS from the command line see e.g. Does CMake always generate configurations for all possible project configurations?

Florian
  • 39,996
  • 9
  • 133
  • 149