10

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?

1 Answer 1

14

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.

7
  • I should have mentioned that I tried adding that flag to the command line as well as putting it directly in the CMakeCache.txt. I'll avoid modifying that particular file in future.
    – Cliabhach
    Commented Jan 13, 2017 at 23:15
  • Let me add some sample output to my question
    – Cliabhach
    Commented Jan 13, 2017 at 23:16
  • 4
    So what is the correct option to get verbose output from CMake itself? Commented Aug 31, 2018 at 13:48
  • 2
    @PeterMortensen you need to invoke cmake with the --verbose=1 flag directly.
    – Cliabhach
    Commented Sep 3, 2018 at 21:51
  • 2
    As included by OP in the OP, he's looking for verbose cmake, which is achieved by cmake --verbose=1 , not what this answer gives
    – WurmD
    Commented Apr 30, 2020 at 16:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.