Skip to content

Commit d2be577

Browse files
rajkan01hugueskamba
authored andcommitted
CMake: split rtos from core target
Add or remove and directories containing source files, header files, and macro definitions that implement RTOS support. This includes: - cmsis/CMSIS_5/CMSIS/RTOS2/ - cmsis/device/rtos/ - rtos/source/ConditionVariable.cpp - rtos/source/Thread.cpp
1 parent 2bab2ba commit d2be577

File tree

7 files changed

+25
-18
lines changed

7 files changed

+25
-18
lines changed

CMakeLists.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ add_library(mbed-core OBJECT)
1717
# TODO CMAKE: Replace mbed-os by a new one that will include mbed-core and mbed-rtos
1818
add_library(mbed-os ALIAS mbed-core)
1919

20+
2021
# Validate selected C library type
2122
# The C library type selected has to match the library that the target can support
2223
if(${MBED_C_LIB} STREQUAL "small")
@@ -69,10 +70,12 @@ target_include_directories(mbed-core
6970
${CMAKE_CURRENT_SOURCE_DIR}
7071
)
7172

72-
# TODO CMake: This component is made visible here so its source files in
73-
# drivers/ can be added and it can be linked against by libraries in storage/.
74-
# Should the source files be moved from drivers/ to storage/ ?
73+
# These targets are made visible here so their source files which
74+
# are spread in different directories can be referenced and can be linked against
75+
# by libraries that depend on them.
76+
# TODO CMake: Should the source files be moved?
7577
add_library(mbed-device_key INTERFACE)
78+
add_library(mbed-rtos INTERFACE)
7679

7780
add_subdirectory(cmsis)
7881
add_subdirectory(drivers)
@@ -89,6 +92,8 @@ add_subdirectory(drivers/device_key EXCLUDE_FROM_ALL)
8992
add_subdirectory(drivers/source/usb EXCLUDE_FROM_ALL)
9093
add_subdirectory(features EXCLUDE_FROM_ALL)
9194
add_subdirectory(platform/FEATURE_EXPERIMENTAL_API EXCLUDE_FROM_ALL)
95+
add_subdirectory(cmsis/CMSIS_5/CMSIS/RTOS2 EXCLUDE_FROM_ALL)
96+
add_subdirectory(cmsis/device/rtos EXCLUDE_FROM_ALL)
9297

9398
#
9499
# Configures the application

cmsis/CMSIS_5/CMSIS/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@ elseif("CORTEX_M" IN_LIST MBED_TARGET_LABELS)
77
add_subdirectory(TARGET_CORTEX_M)
88
endif()
99

10-
add_subdirectory(RTOS2)

cmsis/CMSIS_5/CMSIS/RTOS2/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33

44
add_subdirectory(RTX)
55

6-
target_include_directories(mbed-core
6+
target_include_directories(mbed-rtos
77
PUBLIC
88
Include
99
)
1010

11-
target_sources(mbed-core
11+
target_sources(mbed-rtos
1212
PRIVATE
1313
Source/os_systick.c
1414
Source/os_tick_ptim.c

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function(_mbed_get_cortex_m_exception_handlers toolchain_dir)
1919
set(STARTUP_RTX_FILE TARGET_RTOS_M4_M7/irq_cm4f.S)
2020
endif()
2121

22-
target_sources(mbed-core
22+
target_sources(mbed-rtos
2323
PRIVATE
2424
Source/${toolchain_dir}/${STARTUP_RTX_FILE}
2525
)
@@ -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-core PRIVATE Config/TARGET_CORTEX_A/handlers.c)
32+
target_sources(mbed-rtos PRIVATE Config/TARGET_CORTEX_A/handlers.c)
3333
endif()
3434
endforeach()
3535
endfunction()
@@ -44,15 +44,15 @@ elseif(${MBED_TOOLCHAIN} STREQUAL "IAR")
4444
_mbed_get_cortex_m_exception_handlers(TOOLCHAIN_IAR)
4545
endif()
4646

47-
target_include_directories(mbed-core
47+
target_include_directories(mbed-rtos
4848
PUBLIC
4949
Config
5050
Include
5151
Include1
5252
Source
5353
)
5454

55-
target_sources(mbed-core
55+
target_sources(mbed-rtos
5656
PRIVATE
5757
Config/RTX_Config.c
5858

cmsis/device/CMakeLists.txt

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

44
add_subdirectory(RTE)
5-
add_subdirectory(rtos)
65

76
target_include_directories(mbed-core
87
PUBLIC

cmsis/device/rtos/CMakeLists.txt

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

44
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
5-
target_sources(mbed-core
5+
target_sources(mbed-rtos
66
PRIVATE
77
TOOLCHAIN_GCC_ARM/mbed_boot_gcc_arm.c
88
)
99
elseif(${MBED_TOOLCHAIN} STREQUAL "ARM")
10-
target_sources(mbed-core
10+
target_sources(mbed-rtos
1111
PRIVATE
1212
TOOLCHAIN_ARM_STD/mbed_boot_arm_std.c
1313
)
1414
elseif(${MBED_TOOLCHAIN} STREQUAL "IAR")
15-
target_sources(mbed-core
15+
target_sources(mbed-rtos
1616
PRIVATE
1717
TOOLCHAIN_IAR/mbed_boot_iar.c
1818
)
1919
endif()
2020

21-
target_include_directories(mbed-core
21+
target_include_directories(mbed-rtos
2222
PUBLIC
2323
include
2424
)
2525

26-
target_sources(mbed-core PRIVATE
26+
target_sources(mbed-rtos PRIVATE
2727
source/mbed_boot.c
2828
source/mbed_rtos_rtx.c
2929
source/mbed_rtx_handlers.c
3030
source/mbed_rtx_idle.cpp
3131
)
3232

33-
target_compile_definitions(mbed-core
33+
target_compile_definitions(mbed-rtos
3434
PUBLIC
3535
MBED_CONF_RTOS_PRESENT=1
3636
)

rtos/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@ target_include_directories(mbed-core
1212

1313
target_sources(mbed-core
1414
PRIVATE
15-
source/ConditionVariable.cpp
1615
source/EventFlags.cpp
1716
source/Kernel.cpp
1817
source/Mutex.cpp
1918
source/Semaphore.cpp
2019
source/ThisThread.cpp
20+
)
21+
22+
target_sources(mbed-os
23+
PRIVATE
24+
source/ConditionVariable.cpp
2125
source/Thread.cpp
2226
)
2327

0 commit comments

Comments
 (0)