diff --git a/firmware/asdf/cmake/generic-gcc-avr.cmake b/firmware/asdf/cmake/generic-gcc-avr.cmake index 03a3e1b..c27c638 100644 --- a/firmware/asdf/cmake/generic-gcc-avr.cmake +++ b/firmware/asdf/cmake/generic-gcc-avr.cmake @@ -151,6 +151,45 @@ else(WITH_MCU) set(MCU_TYPE_FOR_FILENAME "") endif(WITH_MCU) +function(c_toolchain_flags) + # fix array base indexing beginning in AVR-GCC 12: + + list(APPEND TOOLCHAIN_FLAGS + -std=c99 + # -Wa,-adhln + -Wall + -funsigned-char + -funsigned-bitfields + -ffunction-sections + -fdata-sections + -fpack-struct + -fshort-enums + -O2 + -Wall + -Wextra + -Wpointer-arith + -Wcast-align + -Wwrite-strings + -Wswitch-default + -Wunreachable-code + -Winit-self + -Wmissing-field-initializers + -Wno-unknown-pragmas + -Wstrict-prototypes + -Wundef + -Wold-style-definition + ) + + if(CMAKE_C_COMPILER_VERSION GREATER_EQUAL "11.3") + message(STATUS "Appending page size fix for GCC >= 11.3") + list(APPEND TOOLCHAIN_FLAGS --param=min-pagesize=0) + endif() + + set(CFLAGS ${TOOLCHAIN_FLAGS} PARENT_SCOPE) +endfunction(c_toolchain_flags) + + + ########################################################################## # add_avr_executable # - IN_VAR: EXECUTABLE_NAME diff --git a/firmware/asdf/src/CMakeLists.txt b/firmware/asdf/src/CMakeLists.txt index d3428b2..f639fb3 100644 --- a/firmware/asdf/src/CMakeLists.txt +++ b/firmware/asdf/src/CMakeLists.txt @@ -52,32 +52,7 @@ configure_file(${ASDF_SRC_DIR}/asdf_keymap_setup.c.in ${CMAKE_CURRENT_BINARY_DI configure_file(${ASDF_SRC_DIR}/asdf_keymap_setup.h.in ${CMAKE_CURRENT_BINARY_DIR}/asdf_keymap_setup.h) - -list(APPEND CFLAGS - -std=c99 -# -Wa,-adhln - -Wall - -funsigned-char - -funsigned-bitfields - -ffunction-sections - -fdata-sections - -fpack-struct - -fshort-enums - -O2 - -Wall - -Wextra - -Wpointer-arith - -Wcast-align - -Wwrite-strings - -Wswitch-default - -Wunreachable-code - -Winit-self - -Wmissing-field-initializers - -Wno-unknown-pragmas - -Wstrict-prototypes - -Wundef - -Wold-style-definition -) +c_toolchain_flags() list (APPEND SOURCES asdf.c