Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does `cmake --verbose=1` give verbose cmake output but `cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON` does not?

Tags:

cmake

My goal was to see details about an invocation of g++ called directly by cmake from the command line. I do not care about the output of make for the purposes of this question.

According to the official FAQ and the accepted answer on a related question, I should make sure CMAKE_VERBOSE_MAKEFILE:BOOL=ON is set in my generated CMakeCache.txt, by e.g. passing the commandline flag -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON. When I did that it re-queried a bunch of properties, but gave no extra information about the invocation.

However, calling cmake with the flag --verbose=1 showed me exactly what I needed.

What are these two options doing differently? Is --verbose=1 deprecated or otherwise discouraged?

like image 373
Cliabhach Avatar asked Jan 13 '17 22:01

Cliabhach


People also ask

Does CMake default to debug or release?

It will now default to using a debug build if the source directory is a git clone, or a release build if not. It is also quite easy to customize its behavior according to the preferences of your project.

What does Add_subdirectory do in CMake?

Add a subdirectory to the build. Adds a subdirectory to the build. The source_dir specifies the directory in which the source CMakeLists.


1 Answers

No, that's not what the accepted answer and the CMake FAQ you link say, otherwise I would be surprised.
Precisely, they don't say that you should modify CMakeCache.txt. Don't modify that file, it's not a good practice, since one can easily make mistakes.
If you instead have followed exactly what both sources say, i.e.

cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON .
make

or

cmake .
make VERBOSE=1

you would have seen a verbose output from the compilation and linking phases.
Alternatively, you should achieve the same effect if you put in your CMakeLists.txt file the following line:

set( CMAKE_VERBOSE_MAKEFILE on )

The fact that you do not see output in one of the cases might due to previously cached configurations.
I suggest you do if possible out-of-source builds so that in this case you can get rid of every CMake generated files and directories by just removing the build directory.
Then you could just recreate new configurations without interference from previously generated configurations and build files.
Of course, I might be wrong and you hit a bug, but it seems unlikely.


EDIT: That's because in the configuration phase you're not compiling, i.e. you are not using a Makefile, which is what the command line option set. It's not a verbose option for the cmake command itself at any stage (configuration, compiling, installing) of the project build. It will not show extra configuration info when you do cmake . but it should show you extra information when you run the make.
So CMAKE_VERBOSE_MAKEFILE is the wrong option to set if you want to get verbose output from CMake itself.

like image 172
fedepad Avatar answered Oct 19 '22 23:10

fedepad