diff --git a/CMakeLists.txt b/CMakeLists.txt index e5d16b789d..0dadc5b874 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,7 @@ add_library(mbed-core OBJECT) # TODO CMAKE: Replace mbed-os by a new one that will include mbed-core and mbed-rtos add_library(mbed-os ALIAS mbed-core) + # Validate selected C library type # The C library type selected has to match the library that the target can support if(${MBED_C_LIB} STREQUAL "small") @@ -69,10 +70,12 @@ target_include_directories(mbed-core ${CMAKE_CURRENT_SOURCE_DIR} ) -# TODO CMake: This component is made visible here so its source files in -# drivers/ can be added and it can be linked against by libraries in storage/. -# Should the source files be moved from drivers/ to storage/ ? +# These targets are made visible here so their source files which +# are spread in different directories can be referenced and can be linked against +# by libraries that depend on them. +# TODO CMake: Should the source files be moved? add_library(mbed-device_key INTERFACE) +add_library(mbed-rtos INTERFACE) add_subdirectory(cmsis) add_subdirectory(drivers) @@ -89,6 +92,8 @@ add_subdirectory(drivers/device_key EXCLUDE_FROM_ALL) add_subdirectory(drivers/source/usb EXCLUDE_FROM_ALL) add_subdirectory(features EXCLUDE_FROM_ALL) add_subdirectory(platform/FEATURE_EXPERIMENTAL_API EXCLUDE_FROM_ALL) +add_subdirectory(cmsis/CMSIS_5/CMSIS/RTOS2 EXCLUDE_FROM_ALL) +add_subdirectory(cmsis/device/rtos EXCLUDE_FROM_ALL) # # Configures the application diff --git a/cmsis/CMSIS_5/CMSIS/CMakeLists.txt b/cmsis/CMSIS_5/CMSIS/CMakeLists.txt index a78bd31afb..6d0f9bb548 100644 --- a/cmsis/CMSIS_5/CMSIS/CMakeLists.txt +++ b/cmsis/CMSIS_5/CMSIS/CMakeLists.txt @@ -7,4 +7,3 @@ elseif("CORTEX_M" IN_LIST MBED_TARGET_LABELS) add_subdirectory(TARGET_CORTEX_M) endif() -add_subdirectory(RTOS2) diff --git a/cmsis/CMSIS_5/CMSIS/RTOS2/CMakeLists.txt b/cmsis/CMSIS_5/CMSIS/RTOS2/CMakeLists.txt index ddb54e0590..2069785223 100644 --- a/cmsis/CMSIS_5/CMSIS/RTOS2/CMakeLists.txt +++ b/cmsis/CMSIS_5/CMSIS/RTOS2/CMakeLists.txt @@ -3,12 +3,12 @@ add_subdirectory(RTX) -target_include_directories(mbed-core +target_include_directories(mbed-rtos PUBLIC Include ) -target_sources(mbed-core +target_sources(mbed-rtos PRIVATE Source/os_systick.c Source/os_tick_ptim.c diff --git a/cmsis/CMSIS_5/CMSIS/RTOS2/RTX/CMakeLists.txt b/cmsis/CMSIS_5/CMSIS/RTOS2/RTX/CMakeLists.txt index 62fa6d6076..4154bacdb1 100644 --- a/cmsis/CMSIS_5/CMSIS/RTOS2/RTX/CMakeLists.txt +++ b/cmsis/CMSIS_5/CMSIS/RTOS2/RTX/CMakeLists.txt @@ -19,7 +19,7 @@ function(_mbed_get_cortex_m_exception_handlers toolchain_dir) set(STARTUP_RTX_FILE TARGET_RTOS_M4_M7/irq_cm4f.S) endif() - target_sources(mbed-core + target_sources(mbed-rtos PRIVATE Source/${toolchain_dir}/${STARTUP_RTX_FILE} ) @@ -29,7 +29,7 @@ endfunction() function(_mbed_get_cortex_a_exception_handlers) foreach(key ${MBED_TARGET_LABELS}) if(${key} STREQUAL CORTEX_A) - target_sources(mbed-core PRIVATE Config/TARGET_CORTEX_A/handlers.c) + target_sources(mbed-rtos PRIVATE Config/TARGET_CORTEX_A/handlers.c) endif() endforeach() endfunction() @@ -44,7 +44,7 @@ elseif(${MBED_TOOLCHAIN} STREQUAL "IAR") _mbed_get_cortex_m_exception_handlers(TOOLCHAIN_IAR) endif() -target_include_directories(mbed-core +target_include_directories(mbed-rtos PUBLIC Config Include @@ -52,7 +52,7 @@ target_include_directories(mbed-core Source ) -target_sources(mbed-core +target_sources(mbed-rtos PRIVATE Config/RTX_Config.c diff --git a/cmsis/device/CMakeLists.txt b/cmsis/device/CMakeLists.txt index c3e3b09c67..9322133fe6 100644 --- a/cmsis/device/CMakeLists.txt +++ b/cmsis/device/CMakeLists.txt @@ -2,7 +2,6 @@ # SPDX-License-Identifier: Apache-2.0 add_subdirectory(RTE) -add_subdirectory(rtos) target_include_directories(mbed-core PUBLIC diff --git a/cmsis/device/rtos/CMakeLists.txt b/cmsis/device/rtos/CMakeLists.txt index 43471103e2..2eccfce188 100644 --- a/cmsis/device/rtos/CMakeLists.txt +++ b/cmsis/device/rtos/CMakeLists.txt @@ -2,35 +2,35 @@ # SPDX-License-Identifier: Apache-2.0 if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM") - target_sources(mbed-core + target_sources(mbed-rtos PRIVATE TOOLCHAIN_GCC_ARM/mbed_boot_gcc_arm.c ) elseif(${MBED_TOOLCHAIN} STREQUAL "ARM") - target_sources(mbed-core + target_sources(mbed-rtos PRIVATE TOOLCHAIN_ARM_STD/mbed_boot_arm_std.c ) elseif(${MBED_TOOLCHAIN} STREQUAL "IAR") - target_sources(mbed-core + target_sources(mbed-rtos PRIVATE TOOLCHAIN_IAR/mbed_boot_iar.c ) endif() -target_include_directories(mbed-core +target_include_directories(mbed-rtos PUBLIC include ) -target_sources(mbed-core PRIVATE +target_sources(mbed-rtos PRIVATE source/mbed_boot.c source/mbed_rtos_rtx.c source/mbed_rtx_handlers.c source/mbed_rtx_idle.cpp ) -target_compile_definitions(mbed-core +target_compile_definitions(mbed-rtos PUBLIC MBED_CONF_RTOS_PRESENT=1 ) diff --git a/rtos/CMakeLists.txt b/rtos/CMakeLists.txt index c2f3e993cc..1963ba6653 100644 --- a/rtos/CMakeLists.txt +++ b/rtos/CMakeLists.txt @@ -12,12 +12,16 @@ target_include_directories(mbed-core target_sources(mbed-core PRIVATE - source/ConditionVariable.cpp source/EventFlags.cpp source/Kernel.cpp source/Mutex.cpp source/Semaphore.cpp source/ThisThread.cpp +) + +target_sources(mbed-os + PRIVATE + source/ConditionVariable.cpp source/Thread.cpp )