diff --git a/cmake/FindCMSIS.cmake b/cmake/FindCMSIS.cmake index d6a1a7c2..8b9db26d 100644 --- a/cmake/FindCMSIS.cmake +++ b/cmake/FindCMSIS.cmake @@ -104,9 +104,11 @@ function(cmsis_generate_default_linker_script FAMILY DEVICE CORE) -P "${STM32_CMAKE_DIR}/stm32/linker_ld.cmake" ) endif() - add_custom_target(CMSIS_LD_${DEVICE}${CORE_U} DEPENDS "${OUTPUT_LD_FILE}") - add_dependencies(CMSIS::STM32::${DEVICE}${CORE_C} CMSIS_LD_${DEVICE}${CORE_U}) - stm32_add_linker_script(CMSIS::STM32::${DEVICE}${CORE_C} INTERFACE "${OUTPUT_LD_FILE}") + if (NOT TARGET CMSIS_LD_${DEVICE}${CORE_U}) + add_custom_target(CMSIS_LD_${DEVICE}${CORE_U} DEPENDS "${OUTPUT_LD_FILE}") + add_dependencies(CMSIS::STM32::${DEVICE}${CORE_C} CMSIS_LD_${DEVICE}${CORE_U}) + stm32_add_linker_script(CMSIS::STM32::${DEVICE}${CORE_C} INTERFACE "${OUTPUT_LD_FILE}") + endif() endfunction() foreach(COMP ${CMSIS_FIND_COMPONENTS_FAMILIES})