CMake default compiler options and Microchip XC16 compatibility

Hi!

I’m working on a project where I’m using a custom CMake-based build system for PIC24FJ256GA7 MCU.

I’ve added the freeRTOS repository as a git submodule into my project but after configuring my CMake to make use of it i faced the compiler options issues…

In the FreeRTOS repository CMakeLists.txt file, there are such options:


target_compile_options(freertos_kernel PRIVATE
    ### Gnu/Clang C Options
    $<$<COMPILE_LANG_AND_ID:C,GNU>:-fdiagnostics-color=always>
    $<$<COMPILE_LANG_AND_ID:C,Clang>:-fcolor-diagnostics>


    $<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wall>
    $<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wextra>
    $<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wpedantic>
    $<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Werror>
    $<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wconversion>
    $<$<COMPILE_LANG_AND_ID:C,Clang>:-Weverything>


    # Suppressions required to build clean with clang.
    $<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-unused-macros>
    $<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-padded>
    $<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-missing-variable-declarations>
    $<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-covered-switch-default>
    $<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-cast-align>
)

To make my build pass a had to cut out these three options:

-fdiagnostics-color=always
-Wpedantic
-Werror
The first two seems to not be supported by the XC16 compiler at all…

[build] elf-cc1: error: unrecognized command line option “-Wpedantic”
[build] elf-cc1: error: unrecognized command line option “-fdiagnostics-color=always”

And the -Werror was causing the SIZE_MAX macro redefinition error… It is strange for me because the SIZE_MAX macro is redefined in the portmacro.h file which is also provided by the freeRTOS repo and it seems like a default choice to use it.

I’m wondering if anyone could suggest to me the best way of handling it?

For now, I’ve just commented it out and created a git patch file which is being applied at the beginning of every build but I would like to know a better solution than modifying the submodule…

Hi @eMKa94,
Welcome to FreeRTOS community!

Thanks for reporting this back to us. We’re going to discuss this internally.
Will get back to you with conclusion. For now, please use git patch as workaround.

Thanks.

1 Like

Hi @eMKa94,
Sorry for late response. We’ve merged Kernel PR#872 to not set compile options by default. You can still pick your options by command target_compile_options(freertos_kernel PRIVATE ...) in your cmake file. Take cmake_example as example.

Thanks.

1 Like