set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_VERSION Cortex-M4-STM32F4)

set(CMAKE_C_COMPILER arm-none-eabi-gcc)
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)

set(ARM_OPTIONS -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16)

add_compile_options(
        ${ARM_OPTIONS}
        -ffunction-sections
        -fdata-sections
        -MMD
        -MP
)

add_compile_options(-fdiagnostics-color=always)

add_link_options(
        ${ARM_OPTIONS}
        -specs=nano.specs
        -specs=nosys.specs  # puts does not work.....
        #-specs=rdimon.specs
        LINKER:-lc
        LINKER:-lgcc
        LINKER:-lnosys
        #-specs=nano.specs
        #-u_printf_float
        #-u_scanf_float
        -nostartfiles
        #-Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group
        LINKER:--gc-sections
        LINKER:--build-id
        LINKER:-Map=${CMAKE_PROJECT_NAME}.map
        -T${CMAKE_SOURCE_DIR}/generated.STM32F401RET6.ld
)


set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
