How to perform verbose builds of a CMake project with Visual Studio 2019 generator

1.4k Views Asked by At

I am using Clion to work on a CMake project which needs to be built with a Visual Studio 16 2019 generator. When I run a build, Clion performs the following command:

$ cmake.exe --build C:\<PATH_TO_PROJECT>\cmake-build-release --target FooTarget --config Release

With this workflow now I would like to get verbose builds in order to troubleshoot which commands and command line arguments are being used by each build.

Is it possible to get cmake to run verbose builds while using a Visual Studio 2019 generator?

1

There are 1 best solutions below

0
On BEST ANSWER

CMake supports passing generator-specific compiler flags as build tool options.

If you're using a Visual Studio generator, you can pass MsBuild command line options such as -verbosity:level with a command like:

cmake.exe --build C:\<PROJECTDIR>\cmake-build-debug --target <BUILDTARGET> --config Debug -- -verbosity:diagnostic

In Clion, just open the project's CMake settings and add -- -verbosity:diagnostic to the "build options" line edit.