
    set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)

    project(boot C CXX ASM)
    add_link_options(-specs=nano.specs -specs=nosys.specs)
    add_compile_options(-specs=nano.specs -specs=nosys.specs)
# project settings



    set(INCLUDE_DIR
            Core/Inc
            #/////////////////////////////////////////////USER CAN ADD INCLUDE_DIR HERE
            App
            loader
            ../ARMCM0_STM32G0
            #/////////////////////////////////////////////
            )



    add_definitions(-DDEBUG -DUSE_FULL_LL_DRIVER -DUSE_HAL_DRIVER -DSTM32G070xx)




file(GLOB_RECURSE SOURCES "Core/*.*" "App/*.*" "loader/*.*" "../ARMCM0_STM32G0/*.*")
list(FILTER SOURCES EXCLUDE REGEX "IAR\\/.*.[c|h]$")
list(FILTER SOURCES EXCLUDE REGEX "Keil\\/.*.[c|h]$")
set(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/Boot/STM32G070CBTX_FLASH.ld)
add_executable(${PROJECT_NAME}.elf ${SOURCES} )
target_compile_options(${PROJECT_NAME}.elf PUBLIC ${COMPILE_OPTIONS})
target_link_options(${PROJECT_NAME}.elf PUBLIC ${LINK_OPTIONS})
set(HEX_FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.hex)
set(BIN_FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.bin)
    target_include_directories(${PROJECT_NAME}.elf PRIVATE ${INCLUDE_DIR} )
    target_link_libraries(${PROJECT_NAME}.elf PUBLIC ${MCU_SERIES}_HAL_DRIVER CMSIS)
add_custom_command(TARGET ${PROJECT_NAME}.elf PRE_BUILD
        COMMAND  ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/${MEM_MAP_FILE}" ${PROJECT_BINARY_DIR}/../${MEM_MAP_FILE}
        )
add_custom_command(TARGET ${PROJECT_NAME}.elf POST_BUILD
        COMMAND ${CMAKE_OBJCOPY} -Oihex $<TARGET_FILE:${PROJECT_NAME}.elf> ${HEX_FILE}
        COMMAND ${CMAKE_OBJCOPY} -Obinary $<TARGET_FILE:${PROJECT_NAME}.elf> ${BIN_FILE}
        COMMENT "Building ${HEX_FILE}
    Building ${BIN_FILE}")