Ambiq Micro: refactor CMake targets

Follow what we did for ST, to create separate CMake targets for each Mbed target.
pull/14242/head
Martin Kojtal 2021-02-08 15:34:29 +00:00
parent 0f000a0502
commit efbf0bb571
12 changed files with 198 additions and 129 deletions

View File

@ -1,17 +1,17 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
if("Apollo3" IN_LIST MBED_TARGET_LABELS)
add_subdirectory(TARGET_Apollo3)
endif()
add_subdirectory(TARGET_Apollo3 EXCLUDE_FROM_ALL)
target_include_directories(mbed-core
add_library(Ambiq_Micro INTERFACE)
target_include_directories(Ambiq_Micro
INTERFACE
sdk/devices
sdk/utils
)
target_sources(mbed-core
target_sources(Ambiq_Micro
INTERFACE
sdk/devices/am_devices_button.c
sdk/devices/am_devices_led.c

View File

@ -1,128 +1,19 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
if("hm01b0" IN_LIST MBED_TARGET_LABELS)
target_include_directories(mbed-core
INTERFACE
COMPONENT_hm01b0/hm01b0
)
add_subdirectory(COMPONENT_hm01b0/hm01b0 EXCLUDE_FROM_ALL)
add_subdirectory(COMPONENT_lis2dh12/lis2dh12 EXCLUDE_FROM_ALL)
target_sources(mbed-core
INTERFACE
COMPONENT_hm01b0/hm01b0/HM01B0.c
)
endif()
add_subdirectory(TARGET_SFE_ARTEMIS EXCLUDE_FROM_ALL)
add_subdirectory(TARGET_SFE_ARTEMIS_ATP EXCLUDE_FROM_ALL)
add_subdirectory(TARGET_SFE_ARTEMIS_DK EXCLUDE_FROM_ALL)
add_subdirectory(TARGET_SFE_ARTEMIS_MODULE EXCLUDE_FROM_ALL)
add_subdirectory(TARGET_SFE_ARTEMIS_NANO EXCLUDE_FROM_ALL)
add_subdirectory(TARGET_SFE_ARTEMIS_THING_PLUS EXCLUDE_FROM_ALL)
add_subdirectory(TARGET_SFE_EDGE EXCLUDE_FROM_ALL)
add_subdirectory(TARGET_SFE_EDGE2 EXCLUDE_FROM_ALL)
if("lis2dh12" IN_LIST MBED_TARGET_LABELS)
target_include_directories(mbed-core
INTERFACE
COMPONENT_lis2dh12/lis2dh12
)
target_sources(mbed-core
INTERFACE
COMPONENT_lis2dh12/lis2dh12/lis2dh12_platform_apollo3.c
COMPONENT_lis2dh12/lis2dh12/lis2dh12_reg.c
)
endif()
if("SFE_ARTEMIS" IN_LIST MBED_TARGET_LABELS)
target_include_directories(mbed-core
INTERFACE
TARGET_SFE_ARTEMIS
TARGET_SFE_ARTEMIS/bsp
)
target_sources(mbed-core
INTERFACE
TARGET_SFE_ARTEMIS/bsp/am_bsp.c
TARGET_SFE_ARTEMIS/bsp/am_bsp_pins.c
)
elseif("SFE_ARTEMIS_ATP" IN_LIST MBED_TARGET_LABELS)
target_include_directories(mbed-core
INTERFACE
TARGET_SFE_ARTEMIS_ATP
TARGET_SFE_ARTEMIS_ATP/bsp
)
target_sources(mbed-core
INTERFACE
TARGET_SFE_ARTEMIS_ATP/bsp/am_bsp.c
TARGET_SFE_ARTEMIS_ATP/bsp/am_bsp_pins.c
)
elseif("SFE_ARTEMIS_DK" IN_LIST MBED_TARGET_LABELS)
target_include_directories(mbed-core
INTERFACE
TARGET_SFE_ARTEMIS_DK
TARGET_SFE_ARTEMIS_DK/bsp
)
target_sources(mbed-core
INTERFACE
TARGET_SFE_ARTEMIS_DK/bsp/am_bsp.c
TARGET_SFE_ARTEMIS_DK/bsp/am_bsp_pins.c
)
elseif("SFE_ARTEMIS_MODULE" IN_LIST MBED_TARGET_LABELS)
target_include_directories(mbed-core
INTERFACE
TARGET_SFE_ARTEMIS_MODULE
TARGET_SFE_ARTEMIS_MODULE/bsp
)
target_sources(mbed-core
INTERFACE
TARGET_SFE_ARTEMIS_MODULE/bsp/am_bsp.c
TARGET_SFE_ARTEMIS_MODULE/bsp/am_bsp_pins.c
)
elseif("SFE_ARTEMIS_NANO" IN_LIST MBED_TARGET_LABELS)
target_include_directories(mbed-core
INTERFACE
TARGET_SFE_ARTEMIS_NANO
TARGET_SFE_ARTEMIS_NANO/bsp
)
target_sources(mbed-core
INTERFACE
TARGET_SFE_ARTEMIS_NANO/bsp/am_bsp.c
TARGET_SFE_ARTEMIS_NANO/bsp/am_bsp_pins.c
)
elseif("SFE_ARTEMIS_THING_PLUS" IN_LIST MBED_TARGET_LABELS)
target_include_directories(mbed-core
INTERFACE
TARGET_SFE_ARTEMIS_THING_PLUS
TARGET_SFE_ARTEMIS_THING_PLUS/bsp
)
target_sources(mbed-core
INTERFACE
TARGET_SFE_ARTEMIS_THING_PLUS/bsp/am_bsp.c
TARGET_SFE_ARTEMIS_THING_PLUS/bsp/am_bsp_pins.c
)
elseif("SFE_EDGE" IN_LIST MBED_TARGET_LABELS)
target_include_directories(mbed-core
INTERFACE
TARGET_SFE_EDGE
TARGET_SFE_EDGE/bsp
)
target_sources(mbed-core
INTERFACE
TARGET_SFE_EDGE/bsp/am_bsp.c
TARGET_SFE_EDGE/bsp/am_bsp_pins.c
)
elseif("SFE_EDGE2" IN_LIST MBED_TARGET_LABELS)
target_include_directories(mbed-core
INTERFACE
TARGET_SFE_EDGE2
TARGET_SFE_EDGE2/bsp
)
target_sources(mbed-core
INTERFACE
TARGET_SFE_EDGE2/bsp/am_bsp.c
TARGET_SFE_EDGE2/bsp/am_bsp_pins.c
)
endif()
add_library(Apollo3 INTERFACE)
if(${MBED_TOOLCHAIN} STREQUAL "ARM")
set(LINKER_FILE TOOLCHAIN_ARM_STD/AMA3B1KK.sct)
@ -132,9 +23,9 @@ elseif(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
set(STARTUP_FILE TOOLCHAIN_GCC_ARM/startup_gcc.c)
endif()
set_property(GLOBAL PROPERTY MBED_TARGET_LINKER_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE})
mbed_set_linker_script(Apollo3 ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE})
target_include_directories(mbed-core
target_include_directories(Apollo3
INTERFACE
device
sdk/CMSIS/AmbiqMicro/Include
@ -144,7 +35,7 @@ target_include_directories(mbed-core
sdk/mcu/apollo3/regs
)
target_sources(mbed-core
target_sources(Apollo3
INTERFACE
device/PeripheralPinConfigs.c
device/PeripheralPins.c
@ -200,7 +91,8 @@ target_sources(mbed-core
${STARTUP_FILE}
)
target_link_libraries(mbed-core
target_link_libraries(Apollo3
INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/sdk/CMSIS/ARM/Lib/ARM/libarm_cortexM4lf_math.a
Ambiq_Micro
)

View File

@ -0,0 +1,16 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
add_library(hm01b0 INTERFACE)
target_include_directories(hm01b0
INTERFACE
.
)
target_sources(hm01b0
INTERFACE
HM01B0.c
)
target_link_libraries(hm01b0 INTERFACE Apollo3)

View File

@ -0,0 +1,17 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
add_library(lis2dh12 INTERFACE)
target_include_directories(lis2dh12
INTERFACE
.
)
target_sources(lis2dh12
INTERFACE
COMPONENT_lis2dh12/lis2dh12/lis2dh12_platform_apollo3.c
COMPONENT_lis2dh12/lis2dh12/lis2dh12_reg.c
)
target_link_libraries(lis2dh12 INTERFACE Apollo3)

View File

@ -0,0 +1,18 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
add_library(SFE_ARTEMIS INTERFACE)
target_include_directories(SFE_ARTEMIS
INTERFACE
.
bsp
)
target_sources(SFE_ARTEMIS
INTERFACE
bsp/am_bsp.c
bsp/am_bsp_pins.c
)
target_link_libraries(SFE_ARTEMIS INTERFACE Apollo3)

View File

@ -0,0 +1,18 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
add_library(SFE_ARTEMIS_ATP INTERFACE)
target_include_directories(SFE_ARTEMIS_ATP
INTERFACE
.
bsp
)
target_sources(SFE_ARTEMIS_ATP
INTERFACE
bsp/am_bsp.c
bsp/am_bsp_pins.c
)
target_link_libraries(SFE_ARTEMIS INTERFACE Apollo3)

View File

@ -0,0 +1,18 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
add_library(SFE_ARTEMIS_DK INTERFACE)
target_include_directories(SFE_ARTEMIS_DK
INTERFACE
.
bsp
)
target_sources(SFE_ARTEMIS_DK
INTERFACE
bsp/am_bsp.c
bsp/am_bsp_pins.c
)
target_link_libraries(SFE_ARTEMIS_DK INTERFACE Apollo3)

View File

@ -0,0 +1,18 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
add_library(SFE_ARTEMIS_MODULE INTERFACE)
target_include_directories(SFE_ARTEMIS_MODULE
INTERFACE
.
bsp
)
target_sources(SFE_ARTEMIS_MODULE
INTERFACE
bsp/am_bsp.c
bsp/am_bsp_pins.c
)
target_link_libraries(SFE_ARTEMIS_MODULE INTERFACE Apollo3)

View File

@ -0,0 +1,18 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
add_library(SFE_ARTEMIS_NANO INTERFACE)
target_include_directories(SFE_ARTEMIS_NANO
INTERFACE
.
bsp
)
target_sources(SFE_ARTEMIS_NANO
INTERFACE
bsp/am_bsp.c
bsp/am_bsp_pins.c
)
target_link_libraries(SFE_ARTEMIS_NANO INTERFACE Apollo3)

View File

@ -0,0 +1,18 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
add_library(SFE_ARTEMIS_THING_PLUS INTERFACE)
target_include_directories(SFE_ARTEMIS_THING_PLUS
INTERFACE
.
bsp
)
target_sources(SFE_ARTEMIS_THING_PLUS
INTERFACE
bsp/am_bsp.c
bsp/am_bsp_pins.c
)
target_link_libraries(SFE_ARTEMIS_THING_PLUS INTERFACE Apollo3)

View File

@ -0,0 +1,18 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
add_library(SFE_EDGE INTERFACE)
target_include_directories(SFE_EDGE
INTERFACE
.
bsp
)
target_sources(SFE_EDGE
INTERFACE
bsp/am_bsp.c
bsp/am_bsp_pins.c
)
target_link_libraries(SFE_EDGE INTERFACE Apollo3)

View File

@ -0,0 +1,18 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
add_library(SFE_EDGE2 INTERFACE)
target_include_directories(SFE_EDGE2
INTERFACE
.
bsp
)
target_sources(SFE_EDGE2
INTERFACE
bsp/am_bsp.c
bsp/am_bsp_pins.c
)
target_link_libraries(SFE_EDGE2 INTERFACE Apollo3)