Skip to content

CMake: refactor GigaDevice targets #14281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions targets/TARGET_GigaDevice/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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 EXCLUDE_FROM_ALL)
add_subdirectory(TARGET_GD32F4XX EXCLUDE_FROM_ALL)

target_include_directories(mbed-core
add_library(mbed-gigadevice INTERFACE)

target_include_directories(mbed-gigadevice
INTERFACE
.
)
47 changes: 26 additions & 21 deletions targets/TARGET_GigaDevice/TARGET_GD32F30X/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
31 changes: 18 additions & 13 deletions targets/TARGET_GigaDevice/TARGET_GD32F4XX/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -84,3 +84,8 @@ target_sources(mbed-core

${STARTUP_FILE}
)

mbed_set_linker_script(mbed-gd32f4xx ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE})

target_link_libraries(mbed-gd32f4xx INTERFACE mbed-gigadevice)
target_link_libraries(mbed-gd32-f450zi INTERFACE mbed-gd32f4xx)