You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.5 KiB
34 lines
1.5 KiB
project(f103-usb C ASM)
|
|
cmake_minimum_required(VERSION 3.5.0)
|
|
|
|
file(GLOB_RECURSE USER_SOURCES "Src/*.c")
|
|
file(GLOB_RECURSE HAL_SOURCES "Drivers/STM32F1xx_HAL_Driver/Src/*.c")
|
|
|
|
file(GLOB_RECURSE USB_SOURCES
|
|
"Middlewares/ST/STM32_USB_Device_Library/Core/Src/*.c"
|
|
"Middlewares/ST/STM32_USB_Device_Library/Class/HID/Src/*.c")
|
|
|
|
add_library(USBFS ${USB_SOURCES})
|
|
add_library(HAL ${HAL_SOURCES})
|
|
add_library(CMSIS
|
|
Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c
|
|
Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xb.s)
|
|
|
|
include_directories(Inc)
|
|
include_directories(Drivers/STM32F1xx_HAL_Driver/Inc)
|
|
include_directories(Drivers/CMSIS/Include)
|
|
include_directories(Drivers/CMSIS/Device/ST/STM32F1xx/Include)
|
|
include_directories(Middlewares/ST/STM32_USB_Device_Library/Class/HID/Inc)
|
|
include_directories(Middlewares/ST/STM32_USB_Device_Library/Core/Inc)
|
|
|
|
add_definitions(-DSTM32F103x6)
|
|
add_executable(${PROJECT_NAME}.elf ${USER_SOURCES} ${LINKER_SCRIPT})
|
|
|
|
target_link_libraries(${PROJECT_NAME}.elf HAL CMSIS USBFS)
|
|
|
|
set(HEX_FILE ${PROJECT_SOURCE_DIR}/build/${PROJECT_NAME}.hex)
|
|
set(BIN_FILE ${PROJECT_SOURCE_DIR}/build/${PROJECT_NAME}.bin)
|
|
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} \nBuilding ${BIN_FILE}")
|
|
|