how to config cmake file correctly for header file change detection (Tasking C compiler + Ninja)

I am using cmake + ninja + Tasking C compiler to build an Infineon Aurix TC3xx project

for instance:
add_executable(“${sw_product}” ${project_source})

the “project_source” contain all the necessary .c files for the project to build

meanwhile I also make a collection of all the header file path (path, not files) like this:
target_include_directories(“${sw_product}” PRIVATE ${project_include} )

The rebuild function work very well

my problem now is for incremental build, if I change the .c file, the cmake can detect the change automatically and only build the changed .c files

but when I change the .h files or the linkerscript (.lsl file), the cmake just ignore it

I read many articles in google and chatGPT. All the adviced measure doesn’t work for my use case. I have a feeling the cmake support (at least documenation) for Tasking compiler is not so well established as common compiler (like gnu gcc)

can anybody here help? at least clarify, why the cmake doen’t support .h files change so easily just like .c file change detection?

Can try after adding these commands in your root CMakeLists.txt file just after the project() command?

set(CMAKE_C_DEPFILE_FORMAT gcc)
set(CMAKE_C_DEPENDS_USE_COMPILER TRUE)

Do you mean CMAKE_DEPENDS_USE_COMPILER? But this affects only the Makefile generator!

The CMAKE_C_DEPFILE_FORMAT is not not documented?

No, do exactly what I mention. And yes, these variables are not documented because they are implementation details.

And you are right, this is only for Makefiles generators. For ninja, it is supposed to be always active.