Skip to content

Commit cb72773

Browse files
rajkan010xc0170
authored andcommitted
CMake: add mbed-os and mbed-baremetal targets
mbed-os consists of mbed-core and mbed-rtos mbed-baremetal consists of mbed-core The main change is for mbed-core. Changing from object library to be interface. This way it allows us to do the above to have 2 main targets for users to use. This should be backward compatible change as mbed-os target we used contains the same files/options as previously set.
1 parent 0cd870d commit cb72773

File tree

67 files changed

+194
-182
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+194
-182
lines changed

CMakeLists.txt

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,22 @@ endif()
1313
include(${MBED_ROOT}/tools/cmake/core.cmake)
1414
include(${MBED_ROOT}/tools/cmake/profile.cmake)
1515

16-
add_library(mbed-core OBJECT)
17-
# TODO CMAKE: Replace mbed-os by a new one that will include mbed-core and mbed-rtos
18-
add_library(mbed-os ALIAS mbed-core)
16+
add_library(mbed-core INTERFACE)
1917

18+
add_library(mbed-os INTERFACE)
19+
20+
target_link_libraries(mbed-os
21+
INTERFACE
22+
mbed-rtos
23+
mbed-core
24+
)
25+
26+
add_library(mbed-baremetal INTERFACE)
27+
28+
target_link_libraries(mbed-baremetal
29+
INTERFACE
30+
mbed-core
31+
)
2032

2133
# Validate selected C library type
2234
# The C library type selected has to match the library that the target can support
@@ -50,23 +62,21 @@ mbed_set_cpu_core_options(mbed-core ${MBED_TOOLCHAIN})
5062
mbed_set_toolchain_options(mbed-core)
5163
mbed_set_c_lib(mbed-core ${MBED_C_LIB})
5264
mbed_set_printf_lib(mbed-core ${MBED_PRINTF_LIB})
53-
mbed_set_language_standard(mbed-core)
5465
mbed_set_profile_options(mbed-core ${MBED_TOOLCHAIN})
5566

56-
set_target_properties(mbed-core
57-
PROPERTIES
58-
MBED_TARGET_LABELS "${MBED_TARGET_LABELS}"
67+
set(MBED_TARGET_LABELS
68+
${MBED_TARGET_LABELS} CACHE INTERNAL ""
5969
)
6070

6171
target_compile_definitions(mbed-core
62-
PUBLIC
72+
INTERFACE
6373
${MBED_TARGET_DEFINITIONS}
6474
${MBED_CONFIG_DEFINITIONS}
6575
)
6676

6777
# Include mbed.h and config from generate folder
6878
target_include_directories(mbed-core
69-
PUBLIC
79+
INTERFACE
7080
${CMAKE_CURRENT_SOURCE_DIR}
7181
)
7282

cmsis/CMSIS_5/CMSIS/RTOS2/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
add_subdirectory(RTX)
55

66
target_include_directories(mbed-rtos
7-
PUBLIC
7+
INTERFACE
88
Include
99
)
1010

1111
target_sources(mbed-rtos
12-
PRIVATE
12+
INTERFACE
1313
Source/os_systick.c
1414
Source/os_tick_ptim.c
1515
)

cmsis/CMSIS_5/CMSIS/RTOS2/RTX/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function(_mbed_get_cortex_m_exception_handlers toolchain_dir)
2020
endif()
2121

2222
target_sources(mbed-rtos
23-
PRIVATE
23+
INTERFACE
2424
Source/${toolchain_dir}/${STARTUP_RTX_FILE}
2525
)
2626
endforeach()
@@ -29,7 +29,7 @@ endfunction()
2929
function(_mbed_get_cortex_a_exception_handlers)
3030
foreach(key ${MBED_TARGET_LABELS})
3131
if(${key} STREQUAL CORTEX_A)
32-
target_sources(mbed-rtos PRIVATE Config/TARGET_CORTEX_A/handlers.c)
32+
target_sources(mbed-rtos INTERFACE Config/TARGET_CORTEX_A/handlers.c)
3333
endif()
3434
endforeach()
3535
endfunction()
@@ -45,15 +45,15 @@ elseif(${MBED_TOOLCHAIN} STREQUAL "IAR")
4545
endif()
4646

4747
target_include_directories(mbed-rtos
48-
PUBLIC
48+
INTERFACE
4949
Config
5050
Include
5151
Include1
5252
Source
5353
)
5454

5555
target_sources(mbed-rtos
56-
PRIVATE
56+
INTERFACE
5757
Config/RTX_Config.c
5858

5959
Library/cmsis_os1.c

cmsis/CMSIS_5/CMSIS/TARGET_CORTEX_A/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
target_include_directories(mbed-core
5-
PUBLIC
5+
INTERFACE
66
Include
77
)
88

99
target_sources(mbed-core
10-
PRIVATE
10+
INTERFACE
1111
Source/irq_ctrl_gic.c
1212
)

cmsis/CMSIS_5/CMSIS/TARGET_CORTEX_M/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
target_include_directories(mbed-core
5-
PUBLIC
5+
INTERFACE
66
Include
77
)
88

99
target_sources(mbed-core
10-
PRIVATE
10+
INTERFACE
1111
Source/mbed_tz_context.c
1212
)

cmsis/device/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
add_subdirectory(RTE)
55

66
target_include_directories(mbed-core
7-
PUBLIC
7+
INTERFACE
88
.
99
)

cmsis/device/RTE/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
target_include_directories(mbed-core
5-
PUBLIC
5+
INTERFACE
66
include
77
)

cmsis/device/rtos/CMakeLists.txt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,35 @@
33

44
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
55
target_sources(mbed-rtos
6-
PRIVATE
6+
INTERFACE
77
TOOLCHAIN_GCC_ARM/mbed_boot_gcc_arm.c
88
)
99
elseif(${MBED_TOOLCHAIN} STREQUAL "ARM")
1010
target_sources(mbed-rtos
11-
PRIVATE
11+
INTERFACE
1212
TOOLCHAIN_ARM_STD/mbed_boot_arm_std.c
1313
)
1414
elseif(${MBED_TOOLCHAIN} STREQUAL "IAR")
1515
target_sources(mbed-rtos
16-
PRIVATE
16+
INTERFACE
1717
TOOLCHAIN_IAR/mbed_boot_iar.c
1818
)
1919
endif()
2020

2121
target_include_directories(mbed-rtos
22-
PUBLIC
22+
INTERFACE
2323
include
2424
)
2525

26-
target_sources(mbed-rtos PRIVATE
27-
source/mbed_boot.c
28-
source/mbed_rtos_rtx.c
29-
source/mbed_rtx_handlers.c
30-
source/mbed_rtx_idle.cpp
26+
target_sources(mbed-rtos
27+
INTERFACE
28+
source/mbed_boot.c
29+
source/mbed_rtos_rtx.c
30+
source/mbed_rtx_handlers.c
31+
source/mbed_rtx_idle.cpp
3132
)
3233

3334
target_compile_definitions(mbed-rtos
34-
PUBLIC
35+
INTERFACE
3536
MBED_CONF_RTOS_PRESENT=1
3637
)

connectivity/libraries/nanostack-libservice/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ target_sources(mbed-nanostack-libservice
2222
# The definition, source files and include directories below
2323
# are needed by mbed-trace which is part of the mbed-core CMake target
2424
target_compile_definitions(mbed-core
25-
PUBLIC
25+
INTERFACE
2626
MBED_CONF_NANOSTACK_LIBSERVICE_PRESENT=1
2727
)
2828
target_include_directories(mbed-core
29-
PUBLIC
29+
INTERFACE
3030
.
3131
./mbed-client-libservice
3232
)
3333
target_sources(mbed-core
34-
PRIVATE
34+
INTERFACE
3535
source/libBits/common_functions.c
3636
source/libip6string/ip6tos.c
3737
)

drivers/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
target_include_directories(mbed-core
5-
PUBLIC
5+
INTERFACE
66
.
77
./include
88
./include/drivers
99
./include/drivers/internal
1010
)
1111

1212
target_sources(mbed-core
13-
PRIVATE
13+
INTERFACE
1414
source/AnalogIn.cpp
1515
source/AnalogOut.cpp
1616
source/BufferedSerial.cpp

hal/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ endif()
88
add_subdirectory(usb)
99

1010
target_include_directories(mbed-core
11-
PUBLIC
11+
INTERFACE
1212
include
1313
include/hal
1414
)
1515

1616
target_sources(mbed-core
17-
PRIVATE
17+
INTERFACE
1818
source/LowPowerTickerWrapper.cpp
1919
source/mbed_compat.c
2020
source/mbed_critical_section_api.c

hal/TARGET_FLASH_CMSIS_ALGO/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
target_include_directories(mbed-core
5-
PUBLIC
5+
INTERFACE
66
.
77
)
88

99
target_sources(mbed-core
10-
PRIVATE
10+
INTERFACE
1111
flash_common_algo.c
1212
)

hal/usb/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
target_include_directories(mbed-core
5-
PUBLIC
5+
INTERFACE
66
include
77
include/usb
88
)
99

1010
target_sources(mbed-core
11-
PRIVATE
11+
INTERFACE
1212
source/mbed_usb_phy.cpp
1313
)

platform/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ add_subdirectory(randlib)
1111
add_subdirectory(source)
1212

1313
target_include_directories(mbed-core
14-
PUBLIC
14+
INTERFACE
1515
include
1616
include/platform
1717
include/platform/internal

platform/cxxsupport/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
target_include_directories(mbed-core
5-
PUBLIC
5+
INTERFACE
66
${CMAKE_CURRENT_SOURCE_DIR}
77
)
88

99
target_sources(mbed-core
10-
PRIVATE
10+
INTERFACE
1111
mstd_mutex.cpp
1212
)

platform/mbed-trace/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
add_subdirectory(source)
55

66
target_include_directories(mbed-core
7-
PUBLIC
7+
INTERFACE
88
include
99
include/mbed-trace
1010
)
1111

1212
target_sources(mbed-core
13-
PRIVATE
13+
INTERFACE
1414
source/mbed_trace.c
1515
)

platform/source/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ endif()
1010
add_subdirectory(minimal-printf)
1111

1212
target_include_directories(mbed-core
13-
PUBLIC
13+
INTERFACE
1414
.
1515
)
1616

1717
target_sources(mbed-core
18-
PRIVATE
18+
INTERFACE
1919
ATCmdParser.cpp
2020
CThunkBase.cpp
2121
CriticalSectionLock.cpp

platform/source/TARGET_CORTEX_M/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
function(_mbed_set_assembly_source)
66
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
7-
target_sources(mbed-core PRIVATE TOOLCHAIN_GCC/except.S)
7+
target_sources(mbed-core INTERFACE TOOLCHAIN_GCC/except.S)
88
elseif(${MBED_TOOLCHAIN} STREQUAL "ARM")
9-
target_sources(mbed-core PRIVATE TOOLCHAIN_ARM/except.S)
9+
target_sources(mbed-core INTERFACE TOOLCHAIN_ARM/except.S)
1010
elseif(${MBED_TOOLCHAIN} STREQUAL "IAR")
1111
target_sources(mbed-core
12-
PRIVATE
12+
INTERFACE
1313
TOOLCHAIN_IAR/except.S
1414
TOOLCHAIN_IAR/cmain.S
1515
)
@@ -19,6 +19,6 @@ endfunction()
1919
_mbed_set_assembly_source()
2020

2121
target_sources(mbed-core
22-
PRIVATE
22+
INTERFACE
2323
mbed_fault_handler.c
2424
)

platform/source/minimal-printf/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
target_include_directories(mbed-core
5-
PUBLIC
5+
INTERFACE
66
${CMAKE_CURRENT_SOURCE_DIR}
77
)
88

99
target_sources(mbed-core
10-
PRIVATE
10+
INTERFACE
1111
mbed_printf_armlink_overrides.c
1212
mbed_printf_implementation.c
1313
mbed_printf_wrapper.c

0 commit comments

Comments
 (0)