0

If in my CMakeLists.txt I have (order #1)

...
set (CMAKE_VERBOSE_MAKEFILE ON  CACHE BOOL "ON")
project ("my_project")
...

on first run I get in ccmake

CMAKE_VERBOSE_MAKEFILE          *ON

But if I invert the order of set (CMAKE_VERBOSE_MAKEFILE ... and project ... (order #2)

...
project ("my_project")
set (CMAKE_VERBOSE_MAKEFILE ON  CACHE BOOL "ON")
...

I get on first run

CMAKE_VERBOSE_MAKEFILE          *OFF

Since I have many projects largely sharing configuration, I want to have a common CMakeLsts.txt, and a project-specific CMakeLsts.txt with the minimum project-specific contents, and an include

project ("my_project")
set (COMMON_DIR "${CMAKE_SOURCE_DIR}/../common")
include ("${COMMON_DIR}/CMakeLists.txt")

and setting CMAKE_VERBOSE_MAKEFILE=ON in ${COMMON_DIR}/CMakeLists.txt. So I seem to be forced to work with order #2.

Under these conditions,

  1. Only having the minimum project-specific contents in the project CMakeLsts.txt (so excluding setting CMAKE_VERBOSE_MAKEFILE=ON).
  2. Setting CMAKE_VERBOSE_MAKEFILE=ON for the first run in the common CMakeLsts.txt.

what are (perhaps more than one) possible ways of getting CMAKE_VERBOSE_MAKEFILE=ON on first run, and then using the cache?
From what I tried, using FORCE is not useful, since if I change the value to something different (OFF in this case), it will revert the value to ON with each run. I wouldn't want to move setting CMAKE_VERBOSE_MAKEFILE=ON to my project-specific CMakeLists.txt.

Related

  1. Overriding a default option(...) value in CMake from a parent CMakeLists.txt
  • This is the precise reason why [presets](https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html) exist. – Alex Reinking Feb 15 '22 at 09:15
  • Also, are you aware of the `--verbose` argument to `cmake --build ...` or the `VERBOSE=1` environment variable that the makefile generators respect? – Alex Reinking Feb 15 '22 at 09:16
  • @AlexReinking - So you mean that with my "simple" `include ("${COMMON_DIR}/CMakeLists.txt")` and appropriate commands (and abiding by conditions #1 and #2) it is not possible to work this out? (besides the fact that presets would cover this job). – sancho.s ReinstateMonicaCellio Feb 15 '22 at 10:05
  • @AlexReinking - I think I had used it long ago, but I would have to read about it again to use it properly. – sancho.s ReinstateMonicaCellio Feb 15 '22 at 10:07
  • You just set the environment variable... docs: https://cmake.org/cmake/help/latest/envvar/VERBOSE.html – Alex Reinking Feb 15 '22 at 10:21
  • @AlexReinking - `VERBOSE=1 make` produced verbose output. `VERBOSE=1 ccmake ..` did not produce `CMAKE_VERBOSE_MAKEFILE=ON`, my main objective. So it is a generally useful flag, although since it does not produce any persistent configuration, it is somewhat distant from my objective. – sancho.s ReinstateMonicaCellio Feb 15 '22 at 11:08
  • You should pass this in via a source evaluated before the project files are parsed. In decreasing order of my preference those would be cmake presets, cache initialization script and toolchain file, that is assuming you don't want to pass the value using `-D CMAKE_VERBOSE_MAKEFILE:BOOL=1` during configuration. Imho this is an option that should be chosen by the user though, so I certainly wouldn't hardcode it anywhere where it's always used... – fabian Feb 15 '22 at 19:01

0 Answers0