Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to build cmake projects directly using MSBuildTools

Currently we are planning to use VS2017 with a cmake project. Inside Visual Studio this works quite like a charm.

Now want to run our builds as part of CI on a dedicated build master running MSBuildTools.

Is it possible to directly run the build using the msbuild command, without creating solution files with cmake? Optimally, I would even use the CMakeSettings.json used from VS2017.

like image 967
Andreas Walter Avatar asked Apr 25 '18 17:04

Andreas Walter


People also ask

Do I need Visual Studio for CMake?

CMake project files (such as CMakeLists. txt ) are consumed directly by Visual Studio for the purposes of IntelliSense and browsing. cmake.exe is invoked directly by Visual Studio for CMake configuration and build.

How do I build a project using CMake?

To build with just cmake change directory into where you want the binaries to be placed. For an in-place build you then run cmake and it will produce a CMakeCache. txt file that contains build options that you can adjust using any text editor.


1 Answers

Use the build-tool-mode of CMake for this. It uses the underlying default build tool which is MSBuild for Visual Studio Generators. From the build directory call:

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

and you get a fast, nearly quiet build. To install use INSTALL target, for running your tests if configured use RUN_TESTS target.

like image 139
vre Avatar answered Sep 28 '22 22:09

vre