mirror of https://github.com/ARMmbed/mbed-os.git
CMake: refactor GigaDevice targets
Refactor all GigaDevice targets to be CMake buildsystem targets. This removes the need for checking MBED_TARGET_LABELS repeatedly and allows us to be more flexible in the way we include MBED_TARGET source in the build. A side effect of this is it will allow us to support custom targets without breaking the build for 'standard' targets, as we use CMake's standard mechanism for adding build rules to the build system, rather than implementing our own layer of logic to exclude files not needed for the target being built. Using this approach, if an MBED_TARGET is not linked to using `target_link_libraries` its source files will not be added to the build. This means custom target source can be added to the user's application CMakeLists.txt without polluting the build system when trying to compile for a standard MBED_TARGET.pull/14281/head
parent
8284807a00
commit
33c35f791b
|
@ -1,13 +1,12 @@
|
|||
# Copyright (c) 2020 ARM Limited. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if("GD32F30X" IN_LIST MBED_TARGET_LABELS)
|
||||
add_subdirectory(TARGET_GD32F30X)
|
||||
elseif("GD32F4XX" IN_LIST MBED_TARGET_LABELS)
|
||||
add_subdirectory(TARGET_GD32F4XX)
|
||||
endif()
|
||||
add_subdirectory(TARGET_GD32F30X)
|
||||
add_subdirectory(TARGET_GD32F4XX)
|
||||
|
||||
target_include_directories(mbed-core
|
||||
add_library(mbed-gigadevice INTERFACE)
|
||||
|
||||
target_include_directories(mbed-gigadevice
|
||||
INTERFACE
|
||||
.
|
||||
)
|
||||
|
|
|
@ -1,38 +1,38 @@
|
|||
# Copyright (c) 2020 ARM Limited. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if("GD32F307VG" IN_LIST MBED_TARGET_LABELS)
|
||||
target_include_directories(mbed-core
|
||||
INTERFACE
|
||||
TARGET_GD32F307VG
|
||||
TARGET_GD32F307VG/device
|
||||
)
|
||||
add_library(mbed-gd32-f307vg INTERFACE)
|
||||
|
||||
target_sources(mbed-core
|
||||
INTERFACE
|
||||
TARGET_GD32F307VG/PeripheralPins.c
|
||||
target_include_directories(mbed-gd32-f307vg
|
||||
INTERFACE
|
||||
TARGET_GD32F307VG
|
||||
TARGET_GD32F307VG/device
|
||||
)
|
||||
|
||||
TARGET_GD32F307VG/device/system_gd32f30x.c
|
||||
)
|
||||
target_sources(mbed-gd32-f307vg
|
||||
INTERFACE
|
||||
TARGET_GD32F307VG/PeripheralPins.c
|
||||
|
||||
if(${MBED_TOOLCHAIN} STREQUAL "ARM")
|
||||
set(LINKER_FILE TARGET_GD32F307VG/device/TOOLCHAIN_ARM_STD/gd32f307vg.sct)
|
||||
set(STARTUP_FILE TARGET_GD32F307VG/device/TOOLCHAIN_ARM_STD/startup_gd32f30x_cl.S)
|
||||
elseif(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
|
||||
set(LINKER_FILE TARGET_GD32F307VG/device/TOOLCHAIN_GCC_ARM/GD32F307xG.ld)
|
||||
set(STARTUP_FILE TARGET_GD32F307VG/device/TOOLCHAIN_GCC_ARM/startup_gd32f30x_cl.S)
|
||||
endif()
|
||||
TARGET_GD32F307VG/device/system_gd32f30x.c
|
||||
)
|
||||
|
||||
if(${MBED_TOOLCHAIN} STREQUAL "ARM")
|
||||
set(LINKER_FILE TARGET_GD32F307VG/device/TOOLCHAIN_ARM_STD/gd32f307vg.sct)
|
||||
set(STARTUP_FILE TARGET_GD32F307VG/device/TOOLCHAIN_ARM_STD/startup_gd32f30x_cl.S)
|
||||
elseif(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
|
||||
set(LINKER_FILE TARGET_GD32F307VG/device/TOOLCHAIN_GCC_ARM/GD32F307xG.ld)
|
||||
set(STARTUP_FILE TARGET_GD32F307VG/device/TOOLCHAIN_GCC_ARM/startup_gd32f30x_cl.S)
|
||||
endif()
|
||||
|
||||
set_property(GLOBAL PROPERTY MBED_TARGET_LINKER_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE})
|
||||
add_library(mbed-gd32f30x INTERFACE)
|
||||
|
||||
target_include_directories(mbed-core
|
||||
target_include_directories(mbed-gd32f30x
|
||||
INTERFACE
|
||||
.
|
||||
GD32F30x_standard_peripheral/Include
|
||||
)
|
||||
|
||||
target_sources(mbed-core
|
||||
target_sources(mbed-gd32f30x
|
||||
INTERFACE
|
||||
analogin_api.c
|
||||
analogout_api.c
|
||||
|
@ -77,3 +77,8 @@ target_sources(mbed-core
|
|||
|
||||
${STARTUP_FILE}
|
||||
)
|
||||
|
||||
mbed_set_linker_script(mbed-gd32f30x ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE})
|
||||
|
||||
target_link_libraries(mbed-gd32f30x INTERFACE mbed-gigadevice)
|
||||
target_link_libraries(mbed-gd32-f307vg INTERFACE mbed-gd32f30x)
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
# Copyright (c) 2020 ARM Limited. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if("GD32F450ZI" IN_LIST MBED_TARGET_LABELS)
|
||||
target_include_directories(mbed-core
|
||||
INTERFACE
|
||||
TARGET_GD32F450ZI
|
||||
)
|
||||
add_library(mbed-gd32-f450zi INTERFACE)
|
||||
|
||||
target_sources(mbed-core
|
||||
INTERFACE
|
||||
TARGET_GD32F450ZI/PeripheralPins.c
|
||||
)
|
||||
endif()
|
||||
target_include_directories(mbed-gd32-f450zi
|
||||
INTERFACE
|
||||
TARGET_GD32F450ZI
|
||||
)
|
||||
|
||||
target_sources(mbed-gd32-f450zi
|
||||
INTERFACE
|
||||
TARGET_GD32F450ZI/PeripheralPins.c
|
||||
)
|
||||
|
||||
if(${MBED_TOOLCHAIN} STREQUAL "ARM")
|
||||
set(LINKER_FILE device/TOOLCHAIN_ARM_STD/gd32f450zi.sct)
|
||||
|
@ -21,16 +21,16 @@ elseif(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
|
|||
set(STARTUP_FILE device/TOOLCHAIN_GCC_ARM/startup_gd32f450.S)
|
||||
endif()
|
||||
|
||||
set_property(GLOBAL PROPERTY MBED_TARGET_LINKER_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE})
|
||||
add_library(mbed-gd32f4xx INTERFACE)
|
||||
|
||||
target_include_directories(mbed-core
|
||||
target_include_directories(mbed-gd32f4xx
|
||||
INTERFACE
|
||||
.
|
||||
device
|
||||
GD32F4xx_standard_peripheral/Include
|
||||
)
|
||||
|
||||
target_sources(mbed-core
|
||||
target_sources(mbed-gd32f4xx
|
||||
INTERFACE
|
||||
analogin_api.c
|
||||
analogout_api.c
|
||||
|
@ -84,3 +84,8 @@ target_sources(mbed-core
|
|||
|
||||
${STARTUP_FILE}
|
||||
)
|
||||
|
||||
mbed_set_linker_script(mbed-gd32-f450zi ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE})
|
||||
|
||||
target_link_libraries(mbed-gd32f4xx INTERFACE mbed-gigadevice)
|
||||
target_link_libraries(mbed-gd32-f450zi INTERFACE mbed-gd32f4xx)
|
||||
|
|
Loading…
Reference in New Issue