cmake_minimum_required(VERSION 3.17)

project(stm32)
add_library(stm32 INTERFACE)

# Enable CMake support for ASM and C languages
enable_language(C ASM)

target_compile_definitions(stm32 INTERFACE 
    USE_STDPERIPH_DRIVER
    HSE_VALUE=16000000
    STM32F10X_CL
    GD32E10x
    __TARGET_FPU_VFP
    __FPU_PRESENT=1
    $<$<CONFIG:Debug>:DEBUG>
)

target_include_directories(stm32 INTERFACE
    ../../CMSIS
    ../../Library/
    ../../Library/inc
)

target_sources(stm32 INTERFACE
    ../../CMSIS/system_stm32f10x.c
    ../../Library/src/misc.c
    ../../Library/src/stm32f10x_adc.c
    ../../Library/src/stm32f10x_can.c
    ../../Library/src/stm32f10x_dma.c
    ../../Library/src/stm32f10x_exti.c
    ../../Library/src/stm32f10x_flash.c
    ../../Library/src/stm32f10x_gpio.c
    ../../Library/src/stm32f10x_i2c.c
    ../../Library/src/stm32f10x_pwr.c
    ../../Library/src/stm32f10x_rcc.c
    ../../Library/src/stm32f10x_spi.c
    ../../Library/src/stm32f10x_tim.c
    ../../Library/src/stm32f10x_usart.c
    ../../Library/src/stm32f10x_bkp.c
    ../../startup_stm32f10x_hd.s
)

target_link_directories(stm32 INTERFACE
    
)

target_link_libraries(stm32 INTERFACE

)

# Validate that STM32CubeMX code is compatible with C standard
if(CMAKE_C_STANDARD LESS 11)
    message(ERROR "Generated code requires C11 or higher")
endif()


