The project we managed has too many include folders which exceed the maximum allowed command length.
In order to avoid this issue, I use an IAR feature which move “-I directory” to a file and pass the file as a compile option to the compiler.
The question is that when I use “include_directories” command, CMAKE know where to find include file and could generate correct “DependInfo.cmake” file.
When I move “-l directory” to a file, we don’t use “include_directories” anymore. In this case, the compiler know how to find include file, but CMake don’t know, so cmake couldn’t generate correct “DependInfo.cmake” file.
I tried to use compiler generated *.d file. The result is that *.d file is generated when compiling, but the variable CMAKE_DEPENDS_DEPENDENCY_FILES in DependInfo.cmake is stile empty.
which generator do you use?
If it is a makefile generator, it seems the needed configuration variables to use compiler generated dependencies are not set. Can you try to set CMAKE_<LANG>_DEPENDS_USE_COMPILER variable with value TRUE`?
If this change resolves your problem, can you create an issue for this problem?
I tried your recommendation.
set(CMAKE_C_DEPENDS_USE_COMPILER TRUE)
set(CMAKE_C_DEPFILE_FORMAT “IAR”)
Now, *.d file is generated and DependInfo.cmake seems generate correct CMAKE_DEPENDS_DEPENDENCY_FILES
The generate dependent record example is “<example_folder>/adc/src/adc_controller_drv.c” “<example_folder>/adc/src/adc_controller_drv.o” “IAR” “<example_folder>/adc/src/adc_controller_drv.o.d”
But it does not work. The problem is that when I changed header file, the c file which include the changed header file will not be recompile.
IAR is not a known _DEPFILE_FORMAT value. You probably want to set it to gcc (Makefile syntax). The other option is msvc where the output is grepped for reports of included files (which I doubt IAR uses, but maybe it does).