cmakefilecmakeinfineon

CMake toolchain file for custom toolchain (-c compiler option different meaning)


I try to create CMake toolchain file for Tasking Aurix compiler (ctc) in which -c option have different meaning:

-c --iso=<year>                    ISO C standard (90, 99) (default: 99)

Is it possible to omit -c parameter for object files recipes or maybe it's possible to set custom template for such recipes?

Currently I have ugly workaround for it so after CMake I call script which edit generated makefile's and change option -c to -c 99 but preferably I would like to be able to generate valid makefile's from CMake directly.


Solution

  • OK I was able to find solution. To achieve it I had to overwrite default behavior by setting CMAKE_<LANG>_COMPILE_OBJECT variable, so in my case bellow lines

    set(target_compiler ${CMAKE_C_COMPILER})
    set(CMAKE_C_FLAGS "-c 99")
    set(CMAKE_C_COMPILE_OBJECT "${target_compiler} <INCLUDES> <FLAGS> -o <OBJECT> <SOURCE>")
    

    solved my problem