9

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?

Community
  • 1
  • 1
Cliabhach
  • 1,402
  • 2
  • 12
  • 19

1 Answers1

11

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.

fedepad
  • 4,509
  • 1
  • 13
  • 27
  • 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 Jan 13 '17 at 23:15
  • Let me add some sample output to my question – Cliabhach Jan 13 '17 at 23:16
  • Ok. Wasn't clear from the body for me, that's why I was confused by the title saying one thing and the body mentioning another way of doing it... ;) – fedepad Jan 13 '17 at 23:19
  • Btw, I notice you said `compilation and linking phases` - I'm looking for verbose output from cmake itself, which I don't think is either (correct me if I'm wrong?) – Cliabhach Jan 13 '17 at 23:21
  • 4
    So what is the correct option to get verbose output from CMake itself? – Peter Mortensen Aug 31 '18 at 13:48
  • 2
    @PeterMortensen you need to invoke `cmake` with the `--verbose=1` flag directly. – Cliabhach Sep 03 '18 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 Apr 30 '20 at 16:12