Skip to content

Commit fce0a82

Browse files
committed
Ambiq Micro: refactor CMake targets
Follow what we did for ST, to create separate CMake targets for each Mbed target.
1 parent 9607cea commit fce0a82

File tree

12 files changed

+198
-129
lines changed

12 files changed

+198
-129
lines changed

targets/TARGET_Ambiq_Micro/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# Copyright (c) 2020 ARM Limited. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
if("Apollo3" IN_LIST MBED_TARGET_LABELS)
5-
add_subdirectory(TARGET_Apollo3)
6-
endif()
4+
add_subdirectory(TARGET_Apollo3 EXCLUDE_FROM_ALL)
75

8-
target_include_directories(mbed-core
6+
add_library(Ambiq_Micro INTERFACE)
7+
8+
target_include_directories(Ambiq_Micro
99
INTERFACE
1010
sdk/devices
1111
sdk/utils
1212
)
1313

14-
target_sources(mbed-core
14+
target_sources(Ambiq_Micro
1515
INTERFACE
1616
sdk/devices/am_devices_button.c
1717
sdk/devices/am_devices_led.c
Lines changed: 16 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -1,128 +1,19 @@
11
# Copyright (c) 2020 ARM Limited. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
if("hm01b0" IN_LIST MBED_TARGET_LABELS)
5-
target_include_directories(mbed-core
6-
INTERFACE
7-
COMPONENT_hm01b0/hm01b0
8-
)
4+
add_subdirectory(COMPONENT_hm01b0/hm01b0 EXCLUDE_FROM_ALL)
5+
add_subdirectory(COMPONENT_lis2dh12/lis2dh12 EXCLUDE_FROM_ALL)
96

10-
target_sources(mbed-core
11-
INTERFACE
12-
COMPONENT_hm01b0/hm01b0/HM01B0.c
13-
)
14-
endif()
15-
16-
if("lis2dh12" IN_LIST MBED_TARGET_LABELS)
17-
target_include_directories(mbed-core
18-
INTERFACE
19-
COMPONENT_lis2dh12/lis2dh12
20-
)
21-
22-
target_sources(mbed-core
23-
INTERFACE
24-
COMPONENT_lis2dh12/lis2dh12/lis2dh12_platform_apollo3.c
25-
COMPONENT_lis2dh12/lis2dh12/lis2dh12_reg.c
26-
)
27-
endif()
28-
29-
if("SFE_ARTEMIS" IN_LIST MBED_TARGET_LABELS)
30-
target_include_directories(mbed-core
31-
INTERFACE
32-
TARGET_SFE_ARTEMIS
33-
TARGET_SFE_ARTEMIS/bsp
34-
)
35-
36-
target_sources(mbed-core
37-
INTERFACE
38-
TARGET_SFE_ARTEMIS/bsp/am_bsp.c
39-
TARGET_SFE_ARTEMIS/bsp/am_bsp_pins.c
40-
)
41-
elseif("SFE_ARTEMIS_ATP" IN_LIST MBED_TARGET_LABELS)
42-
target_include_directories(mbed-core
43-
INTERFACE
44-
TARGET_SFE_ARTEMIS_ATP
45-
TARGET_SFE_ARTEMIS_ATP/bsp
46-
)
47-
48-
target_sources(mbed-core
49-
INTERFACE
50-
TARGET_SFE_ARTEMIS_ATP/bsp/am_bsp.c
51-
TARGET_SFE_ARTEMIS_ATP/bsp/am_bsp_pins.c
52-
)
53-
elseif("SFE_ARTEMIS_DK" IN_LIST MBED_TARGET_LABELS)
54-
target_include_directories(mbed-core
55-
INTERFACE
56-
TARGET_SFE_ARTEMIS_DK
57-
TARGET_SFE_ARTEMIS_DK/bsp
58-
)
7+
add_subdirectory(TARGET_SFE_ARTEMIS EXCLUDE_FROM_ALL)
8+
add_subdirectory(TARGET_SFE_ARTEMIS_ATP EXCLUDE_FROM_ALL)
9+
add_subdirectory(TARGET_SFE_ARTEMIS_DK EXCLUDE_FROM_ALL)
10+
add_subdirectory(TARGET_SFE_ARTEMIS_MODULE EXCLUDE_FROM_ALL)
11+
add_subdirectory(TARGET_SFE_ARTEMIS_NANO EXCLUDE_FROM_ALL)
12+
add_subdirectory(TARGET_SFE_ARTEMIS_THING_PLUS EXCLUDE_FROM_ALL)
13+
add_subdirectory(TARGET_SFE_EDGE EXCLUDE_FROM_ALL)
14+
add_subdirectory(TARGET_SFE_EDGE2 EXCLUDE_FROM_ALL)
5915

60-
target_sources(mbed-core
61-
INTERFACE
62-
TARGET_SFE_ARTEMIS_DK/bsp/am_bsp.c
63-
TARGET_SFE_ARTEMIS_DK/bsp/am_bsp_pins.c
64-
)
65-
elseif("SFE_ARTEMIS_MODULE" IN_LIST MBED_TARGET_LABELS)
66-
target_include_directories(mbed-core
67-
INTERFACE
68-
TARGET_SFE_ARTEMIS_MODULE
69-
TARGET_SFE_ARTEMIS_MODULE/bsp
70-
)
71-
72-
target_sources(mbed-core
73-
INTERFACE
74-
TARGET_SFE_ARTEMIS_MODULE/bsp/am_bsp.c
75-
TARGET_SFE_ARTEMIS_MODULE/bsp/am_bsp_pins.c
76-
)
77-
elseif("SFE_ARTEMIS_NANO" IN_LIST MBED_TARGET_LABELS)
78-
target_include_directories(mbed-core
79-
INTERFACE
80-
TARGET_SFE_ARTEMIS_NANO
81-
TARGET_SFE_ARTEMIS_NANO/bsp
82-
)
83-
84-
target_sources(mbed-core
85-
INTERFACE
86-
TARGET_SFE_ARTEMIS_NANO/bsp/am_bsp.c
87-
TARGET_SFE_ARTEMIS_NANO/bsp/am_bsp_pins.c
88-
)
89-
elseif("SFE_ARTEMIS_THING_PLUS" IN_LIST MBED_TARGET_LABELS)
90-
target_include_directories(mbed-core
91-
INTERFACE
92-
TARGET_SFE_ARTEMIS_THING_PLUS
93-
TARGET_SFE_ARTEMIS_THING_PLUS/bsp
94-
)
95-
96-
target_sources(mbed-core
97-
INTERFACE
98-
TARGET_SFE_ARTEMIS_THING_PLUS/bsp/am_bsp.c
99-
TARGET_SFE_ARTEMIS_THING_PLUS/bsp/am_bsp_pins.c
100-
)
101-
elseif("SFE_EDGE" IN_LIST MBED_TARGET_LABELS)
102-
target_include_directories(mbed-core
103-
INTERFACE
104-
TARGET_SFE_EDGE
105-
TARGET_SFE_EDGE/bsp
106-
)
107-
108-
target_sources(mbed-core
109-
INTERFACE
110-
TARGET_SFE_EDGE/bsp/am_bsp.c
111-
TARGET_SFE_EDGE/bsp/am_bsp_pins.c
112-
)
113-
elseif("SFE_EDGE2" IN_LIST MBED_TARGET_LABELS)
114-
target_include_directories(mbed-core
115-
INTERFACE
116-
TARGET_SFE_EDGE2
117-
TARGET_SFE_EDGE2/bsp
118-
)
119-
120-
target_sources(mbed-core
121-
INTERFACE
122-
TARGET_SFE_EDGE2/bsp/am_bsp.c
123-
TARGET_SFE_EDGE2/bsp/am_bsp_pins.c
124-
)
125-
endif()
16+
add_library(Apollo3 INTERFACE)
12617

12718
if(${MBED_TOOLCHAIN} STREQUAL "ARM")
12819
set(LINKER_FILE TOOLCHAIN_ARM_STD/AMA3B1KK.sct)
@@ -132,9 +23,9 @@ elseif(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
13223
set(STARTUP_FILE TOOLCHAIN_GCC_ARM/startup_gcc.c)
13324
endif()
13425

135-
set_property(GLOBAL PROPERTY MBED_TARGET_LINKER_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE})
26+
mbed_set_linker_script(Apollo3 ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE})
13627

137-
target_include_directories(mbed-core
28+
target_include_directories(Apollo3
13829
INTERFACE
13930
device
14031
sdk/CMSIS/AmbiqMicro/Include
@@ -144,7 +35,7 @@ target_include_directories(mbed-core
14435
sdk/mcu/apollo3/regs
14536
)
14637

147-
target_sources(mbed-core
38+
target_sources(Apollo3
14839
INTERFACE
14940
device/PeripheralPinConfigs.c
15041
device/PeripheralPins.c
@@ -200,7 +91,8 @@ target_sources(mbed-core
20091
${STARTUP_FILE}
20192
)
20293

203-
target_link_libraries(mbed-core
94+
target_link_libraries(Apollo3
20495
INTERFACE
20596
${CMAKE_CURRENT_SOURCE_DIR}/sdk/CMSIS/ARM/Lib/ARM/libarm_cortexM4lf_math.a
97+
Ambiq_Micro
20698
)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright (c) 2020 ARM Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
add_library(hm01b0 INTERFACE)
5+
6+
target_include_directories(hm01b0
7+
INTERFACE
8+
.
9+
)
10+
11+
target_sources(hm01b0
12+
INTERFACE
13+
HM01B0.c
14+
)
15+
16+
target_link_libraries(hm01b0 INTERFACE Apollo3)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright (c) 2020 ARM Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
add_library(lis2dh12 INTERFACE)
5+
6+
target_include_directories(lis2dh12
7+
INTERFACE
8+
.
9+
)
10+
11+
target_sources(lis2dh12
12+
INTERFACE
13+
COMPONENT_lis2dh12/lis2dh12/lis2dh12_platform_apollo3.c
14+
COMPONENT_lis2dh12/lis2dh12/lis2dh12_reg.c
15+
)
16+
17+
target_link_libraries(lis2dh12 INTERFACE Apollo3)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright (c) 2020 ARM Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
add_library(SFE_ARTEMIS INTERFACE)
5+
6+
target_include_directories(SFE_ARTEMIS
7+
INTERFACE
8+
.
9+
bsp
10+
)
11+
12+
target_sources(SFE_ARTEMIS
13+
INTERFACE
14+
bsp/am_bsp.c
15+
bsp/am_bsp_pins.c
16+
)
17+
18+
target_link_libraries(SFE_ARTEMIS INTERFACE Apollo3)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright (c) 2020 ARM Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
add_library(SFE_ARTEMIS_ATP INTERFACE)
5+
6+
target_include_directories(SFE_ARTEMIS_ATP
7+
INTERFACE
8+
.
9+
bsp
10+
)
11+
12+
target_sources(SFE_ARTEMIS_ATP
13+
INTERFACE
14+
bsp/am_bsp.c
15+
bsp/am_bsp_pins.c
16+
)
17+
18+
target_link_libraries(SFE_ARTEMIS INTERFACE Apollo3)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright (c) 2020 ARM Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
add_library(SFE_ARTEMIS_DK INTERFACE)
5+
6+
target_include_directories(SFE_ARTEMIS_DK
7+
INTERFACE
8+
.
9+
bsp
10+
)
11+
12+
target_sources(SFE_ARTEMIS_DK
13+
INTERFACE
14+
bsp/am_bsp.c
15+
bsp/am_bsp_pins.c
16+
)
17+
18+
target_link_libraries(SFE_ARTEMIS_DK INTERFACE Apollo3)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright (c) 2020 ARM Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
add_library(SFE_ARTEMIS_MODULE INTERFACE)
5+
6+
target_include_directories(SFE_ARTEMIS_MODULE
7+
INTERFACE
8+
.
9+
bsp
10+
)
11+
12+
target_sources(SFE_ARTEMIS_MODULE
13+
INTERFACE
14+
bsp/am_bsp.c
15+
bsp/am_bsp_pins.c
16+
)
17+
18+
target_link_libraries(SFE_ARTEMIS_MODULE INTERFACE Apollo3)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright (c) 2020 ARM Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
add_library(SFE_ARTEMIS_NANO INTERFACE)
5+
6+
target_include_directories(SFE_ARTEMIS_NANO
7+
INTERFACE
8+
.
9+
bsp
10+
)
11+
12+
target_sources(SFE_ARTEMIS_NANO
13+
INTERFACE
14+
bsp/am_bsp.c
15+
bsp/am_bsp_pins.c
16+
)
17+
18+
target_link_libraries(SFE_ARTEMIS_NANO INTERFACE Apollo3)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright (c) 2020 ARM Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
add_library(SFE_ARTEMIS_THING_PLUS INTERFACE)
5+
6+
target_include_directories(SFE_ARTEMIS_THING_PLUS
7+
INTERFACE
8+
.
9+
bsp
10+
)
11+
12+
target_sources(SFE_ARTEMIS_THING_PLUS
13+
INTERFACE
14+
bsp/am_bsp.c
15+
bsp/am_bsp_pins.c
16+
)
17+
18+
target_link_libraries(SFE_ARTEMIS_THING_PLUS INTERFACE Apollo3)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright (c) 2020 ARM Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
add_library(SFE_EDGE INTERFACE)
5+
6+
target_include_directories(SFE_EDGE
7+
INTERFACE
8+
.
9+
bsp
10+
)
11+
12+
target_sources(SFE_EDGE
13+
INTERFACE
14+
bsp/am_bsp.c
15+
bsp/am_bsp_pins.c
16+
)
17+
18+
target_link_libraries(SFE_EDGE INTERFACE Apollo3)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright (c) 2020 ARM Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
add_library(SFE_EDGE2 INTERFACE)
5+
6+
target_include_directories(SFE_EDGE2
7+
INTERFACE
8+
.
9+
bsp
10+
)
11+
12+
target_sources(SFE_EDGE2
13+
INTERFACE
14+
bsp/am_bsp.c
15+
bsp/am_bsp_pins.c
16+
)
17+
18+
target_link_libraries(SFE_EDGE2 INTERFACE Apollo3)

0 commit comments

Comments
 (0)