Using SYSTEM for targets, but still check for changes

I’m running into the following issue: We have targets that set their include paths with the SYSTEM property. We need to include them this way, because they contain code that would trigger warnings otherwise, and we have warnings set as errors.

The problem is that when we update those targets, and the headers change, the files including them aren’t correctly rebuilt. I think because they are marked as SYSTEM they are omitted from being checked.

Is there a way to fix the dependency checks here, while maintaining the behaviour suppressing warnings in the headers?

What is the version of CMake and which compiler do you use?

I’m now at cmake 3.29.6, using clang 19.

And which system and CMake generator?

That differs. The issue exists on Windows, macOS and Linux, using either the Ninja, Makefile or XCode generator.

These generators use different approaches regarding dependencies tracking.

Let try to identify what happen for Makefile generator.

Dependencies are controlled by the following variables:


What are the values for these variables?

Neither of them appear to be set on my linux system using the Makefile generator.

Sorry, but the variable names including language didn’t show up correctly… I fix-up my previous message.

I still cannot find those. I searched the cache for DEPENDS and USE_COMPILER. Neither is to be found anywhere in that file.

These variables are not cache ones.

Right, I misunderstood that. Only CMAKE_DEPFILE_FLAGS_ seems to be set. For C++ (main language in our codebase)


Ok. Sounds good.

Another variable should be considered: CMAKE_DEPENDS_IN_PROJECT_ONLY

Not set either it seems.

Ok. Let take a look at the generated files.

Check in some project target binary directory (i.e. <bindir>/CMakeFiles/…/<your_target>.dir), the contents of dependency files (i.e. with extension .o.d). All your headers should be here (of course after, at least, one compilation done).

Next check, after a second compilation run: in the same directory, you must have a file compiler_depend.make which also holds all your headers.