einpoklum
einpoklum

Reputation: 132118

CMake + MSVC build tools 2015 - what to do after invoking cmake?

I've never used CMake on Windows, or with MSVC, before; so this is a newbie question.

I've installed CMake and some minimal freely-downloadable "Microsoft Visual C++ build tools 2015" (from here) on a Windows 10 machine. I have my CMake-based project (which builds fine on Linux) checked out, and I'm ready to go.

So, in a shell window, I do:

PS C:\Users\joeuser\the_project> mkdir build
... etc. etc. ...
PS C:\Users\joeuser\the_project> cd build
PS C:\Users\joeuser\the_project\build> cmake ../
-- Building for: Visual Studio 14 2015
-- Selecting Windows SDK version  to target Windows 10.0.15063.
-- lots of checks here
-- etc. etc.

and that's done. So far so good. But - what now? On a Unix'ish system, I would execute make, and perhaps make install; and maybe make clean later on. My questions are:

Upvotes: 0

Views: 1168

Answers (1)

vre
vre

Reputation: 6744

Making my previous comments an answer:

You would then call the underlying build tool directly via CMake:

cmake --build . --target ALL_BUILD --config Debug -- /nologo /verbosity:minimal

This gives you an almost quiet build process as you are used to from make.

Why the hell do I have to provide so much arguments to CMake?

Because CMake is a build system generator and directs those arguments to the underlying build tool (make, MSBuild, nmake, ...). The underlying build tool may have different naming conventions for targets etc., e.g. make users provide almost always the targets all, clean, and install. But the Visual Studio solution generated by CMake uses by default ALL_BUILD, INSTALL, RUN_TESTS. There is no CLEAN target. Using MSBuild,

  • To install your solution you would select --target INSTALL.
  • For running tests, you would select --target RUN_TESTS.
  • For cleaning you have to use --target ALL_BUILD --config Debug -- /nologo /verbosity:minimal /t:Clean because the Visual Studio solution does not contain a clean target but MSBuild provides one.

Further important arguments of MSBuild are:

  • /maxcpucount:<numberOfCpus> (to limit the number of CPUs the build process is using) and
  • "/l:FileLogger,Microsoft.Build.Engine;logfile=<YOUR_LOGFILE_NAME>" to save MSBuild output to file.

Upvotes: 1

Related Questions