mirror of
https://github.com/candle-usb/candleLight_fw.git
synced 2025-01-14 05:42:53 +08:00
cmake : remove some duplication in add_XYZ_target
This commit is contained in:
parent
537c0860c3
commit
0c23387317
@ -202,64 +202,47 @@ populate_ldscript(CPU_FAMILY STM32G0B1XK
|
||||
######### commands for adding each target have a lot in common: make helper func.
|
||||
# Split into two categories, F042-based and F072-based.
|
||||
|
||||
function(add_f042_target TGTNAME)
|
||||
set(CPU_FAMILY STM32F042X6)
|
||||
function(add_target_common TGTNAME CPU_FAMILY)
|
||||
add_executable(${TGTNAME}_fw ${SOURCE_FILES})
|
||||
add_dependencies(${TGTNAME}_fw version_h)
|
||||
target_include_directories(${TGTNAME}_fw PRIVATE include/ ${CMAKE_CURRENT_BINARY_DIR})
|
||||
target_compile_options(${TGTNAME}_fw BEFORE PRIVATE ${CPUFLAGS_F0})
|
||||
target_compile_definitions(${TGTNAME}_fw PRIVATE BOARD_${TGTNAME} STM32F0)
|
||||
target_link_options(${TGTNAME}_fw BEFORE PRIVATE ${CPUFLAGS_F0})
|
||||
target_link_options(${TGTNAME}_fw PRIVATE -T ${CPU_FAMILY}_processed.ld)
|
||||
target_link_libraries(${TGTNAME}_fw PRIVATE STM32_HAL_STM32F042x6 STM32_USB_Device_Library_STM32F042x6)
|
||||
make_bin_file(${TGTNAME}_fw)
|
||||
dfu_flash(${TGTNAME}_fw)
|
||||
show_object_size(${TGTNAME}_fw)
|
||||
endfunction()
|
||||
|
||||
function(add_f042_target TGTNAME)
|
||||
add_target_common(${TGTNAME} STM32F042X6)
|
||||
target_compile_options(${TGTNAME}_fw BEFORE PRIVATE ${CPUFLAGS_F0})
|
||||
target_compile_definitions(${TGTNAME}_fw PRIVATE BOARD_${TGTNAME} STM32F0)
|
||||
target_link_options(${TGTNAME}_fw BEFORE PRIVATE ${CPUFLAGS_F0})
|
||||
target_link_libraries(${TGTNAME}_fw PRIVATE STM32_HAL_STM32F042x6 STM32_USB_Device_Library_STM32F042x6)
|
||||
endfunction()
|
||||
|
||||
function(add_f072_target TGTNAME)
|
||||
set(CPU_FAMILY STM32F072XB)
|
||||
add_executable(${TGTNAME}_fw ${SOURCE_FILES})
|
||||
add_dependencies(${TGTNAME}_fw version_h)
|
||||
target_include_directories(${TGTNAME}_fw PRIVATE include/ ${CMAKE_CURRENT_BINARY_DIR})
|
||||
add_target_common(${TGTNAME} STM32F072XB)
|
||||
target_compile_options(${TGTNAME}_fw BEFORE PRIVATE ${CPUFLAGS_F0})
|
||||
target_compile_definitions(${TGTNAME}_fw PRIVATE BOARD_${TGTNAME} STM32F0)
|
||||
target_link_options(${TGTNAME}_fw BEFORE PRIVATE ${CPUFLAGS_F0})
|
||||
target_link_options(${TGTNAME}_fw PRIVATE -T ${CPU_FAMILY}_processed.ld)
|
||||
target_link_libraries(${TGTNAME}_fw PRIVATE STM32_HAL_STM32F072xB STM32_USB_Device_Library_STM32F072xB)
|
||||
make_bin_file(${TGTNAME}_fw)
|
||||
dfu_flash(${TGTNAME}_fw)
|
||||
show_object_size(${TGTNAME}_fw)
|
||||
|
||||
endfunction()
|
||||
|
||||
function(add_f407_target TGTNAME)
|
||||
set(CPU_FAMILY STM32F407XE)
|
||||
add_executable(${TGTNAME}_fw ${SOURCE_FILES})
|
||||
add_dependencies(${TGTNAME}_fw version_h)
|
||||
target_include_directories(${TGTNAME}_fw PRIVATE include/ ${CMAKE_CURRENT_BINARY_DIR})
|
||||
add_target_common(${TGTNAME} STM32F407XE)
|
||||
target_compile_definitions(${TGTNAME}_fw PRIVATE BOARD_${TGTNAME} STM32F4)
|
||||
target_compile_options(${TGTNAME}_fw BEFORE PRIVATE ${CPUFLAGS_F4})
|
||||
target_link_options(${TGTNAME}_fw BEFORE PRIVATE ${CPUFLAGS_F4})
|
||||
target_link_options(${TGTNAME}_fw PRIVATE -T ${CPU_FAMILY}_processed.ld)
|
||||
target_link_libraries(${TGTNAME}_fw PRIVATE STM32_HAL_STM32F407xE STM32_USB_Device_Library_STM32F407xE)
|
||||
make_bin_file(${TGTNAME}_fw)
|
||||
dfu_flash(${TGTNAME}_fw)
|
||||
show_object_size(${TGTNAME}_fw)
|
||||
endfunction()
|
||||
|
||||
function(add_g0b1_target TGTNAME)
|
||||
set(CPU_FAMILY STM32G0B1XK)
|
||||
add_executable(${TGTNAME}_fw ${SOURCE_FILES})
|
||||
add_dependencies(${TGTNAME}_fw version_h)
|
||||
target_include_directories(${TGTNAME}_fw PRIVATE include/ ${CMAKE_CURRENT_BINARY_DIR})
|
||||
add_target_common(${TGTNAME} STM32G0B1XK)
|
||||
target_compile_definitions(${TGTNAME}_fw PRIVATE BOARD_${TGTNAME} STM32G0)
|
||||
target_compile_options(${TGTNAME}_fw BEFORE PRIVATE ${CPUFLAGS_G0})
|
||||
target_link_options(${TGTNAME}_fw BEFORE PRIVATE ${CPUFLAGS_G0})
|
||||
target_link_options(${TGTNAME}_fw PRIVATE -T ${CPU_FAMILY}_processed.ld)
|
||||
target_link_libraries(${TGTNAME}_fw PRIVATE STM32_HAL_STM32G0B1xK STM32_USB_Device_Library_STM32G0B1xK)
|
||||
make_bin_file(${TGTNAME}_fw)
|
||||
dfu_flash(${TGTNAME}_fw)
|
||||
show_object_size(${TGTNAME}_fw)
|
||||
endfunction()
|
||||
|
||||
########## generate list of targets.
|
||||
|
Loading…
x
Reference in New Issue
Block a user