cmake: How to suppress "Entering directory" messages?

Viewed 1551

I have a project with different sub-modules. Each sub-module has a CMakeLists.txt and I have a general CMakeLists.txt at the root of the project.

When I run cmake --build [...] or make [...], it recursively builds sub-modules as expected but it prints verbose like this:

make[2]: Entering directory '/some/path/'
make[2]: Entering directory '/some/path/'
make[2]: Leaving directory '/some/path/'
make[2]: Leaving directory '/some/path/'
...

What I have tried

  • Explicitly turn off cmake/make verbose by adding set(CMAKE_VERBOSE_MAKEFILE OFF) in the general CMakeLists.txt.
  • make [...] --no-print-directory
  • cmake [...] -- [...] --no-print-directory

The --no-print-directory flag removes these messages as intended, but I used to not have to specify this flag in previous projects. I would prefer to avoid using this flag to get the same results as before.

Versions

GNU Make 4.3
cmake version 3.16.4

1 Answers

You can use

MAKEFLAGS += --no-print-directory

Described in the GNU make manual

Related