DEPFILEs generation for GHS compiler

Hi!

I’m trying to convert a makefile GHS project to a Cmake one and get issues with .h files dependencies. As far as I understand GHS(201355) does not support .d files generation. Existing makefile project uses gcc as a workaround to generate .d files. How can I do such a trick (or some other workaround) in Cmake? I do not want to add .h files manually.

BR,
Mike

We used this workaround for ninja generator:

# ---------------------------------------------------------------------------
# general user options for ninja and ghs compiler
# ---------------------------------------------------------------------------
option(CMAKE_C_DEPFILE_EXTENSION_REPLACE "name depend files as main.d instead of main.c.d" YES)
option(CMAKE_C_OUTPUT_EXTENSION_REPLACE "name object files as main.o instead of main.c.o" YES)
option(CMAKE_CXX_DEPFILE_EXTENSION_REPLACE "name depend files as main.d instead of main.cpp.d" YES)
option(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE "name object files as main.o instead of main.cpp.o" YES)

option(CMAKE_DEPENDS_IN_PROJECT_ONLY "do not use system header files" YES)
if(CMAKE_DEPENDS_IN_PROJECT_ONLY)
  set(CMAKE_DEPFILE_FLAGS_C "-MMD" CACHE STRING "dependency flag" FORCE)
  set(CMAKE_DEPFILE_FLAGS_CXX "-MMD" CACHE STRING "dependency flag" FORCE)
else()
  set(CMAKE_DEPFILE_FLAGS_C "-MD" CACHE STRING "dependency flag" FORCE)
  set(CMAKE_DEPFILE_FLAGS_CXX "-MD" CACHE STRING "dependency flag" FORCE)
endif()

You can try to define variable CMAKE_<LANG>_DEPENDS_EXTRA_COMMANDS for the dependencies generation.

Take a look at the file Compiler/CUDA.cmake for a practical example.

This suggestion does not solve the problem exposed.

May be, with our GHS compiler we had only the problem with the dependency file name generated : file.c -> file.d was generated from compiler and not used from ninja.