How can I tell CLion to preprocess using GCC but build using a commercial toolchain

I'm working on an embedded project that requires the use of a Codewarrior powerpc compiler that's not flag compatible with GCC and CLang. I've managed to write a toolchain file that defines how to compile objects, link objects and preprocess source files. These definitions allow the project to build perfectly well but on reloading the CMake project CLion attempts to preprocess the source files by using some GCC flags with the compiler I've defined. In checking what those flags achieve I can only assume this is CLion attempting to preprocess all the source files to dump the macros that define which code sections are relevant to the target we're building - likely for the code insight features of the editor.

In my CMake project I've defined the following variables:

set(CMAKE_C_LINK_EXECUTABLE "${CW_PATH_BIN}/mwldeppc.exe -o <TARGET>.elf -srec <TARGET>.mot -map <TARGET>.map <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> <OBJECTS>")
set(CMAKE_C_COMPILE_OBJECT "${CW_PATH_BIN}/mwcceppc.exe -c <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>")
set(CMAKE_C_CREATE_PREPROCESSED_SOURCE "${CW_PATH_BIN}/mwcceppc.exe -E <SOURCE> <DEFINES> <INCLUDES> <FLAGS>")

The Codewarrior compiler doesn't appear to have an equivalent function to GCC's -dD to dump the macros after precompiling the file. So I feel the best way to approach this problem is to convince CLion to build using codewarrior but preprocess for code insight using GCC. Does anyone know how I might achieve this? I was hoping I could manually specify the GCC compiler with CMAKE_C_CREATE_PREPROCESSED_SOURCE, but it's ignoring my current definition on how to preprocess with the codewarrior compiler.

Thanks,

Matthew

0

请先登录再写评论。