- Split mbed-core and mbed-rtos into -sources and -flags targets

- Fix some logic errors in top level cmakelists related to building greentea tests
- Fix mbed_create_distro() for OBJECT libraries
pull/15339/head
Jamie Smith 2022-04-03 17:38:18 -07:00 committed by Jay Sridharan
parent 63aa3360c0
commit c11d32fbf4
29 changed files with 155 additions and 112 deletions

View File

@ -11,7 +11,8 @@ cmake_policy(VERSION 3.16...3.22)
# - MBED_OS_IS_STANDALONE: True if Mbed OS is the top-level project. False if Mbed is being built as part of an application.
# - MBED_IS_NATIVE_BUILD: True if we are building for the host machine. False if we are building for a microcontroller
# - MBED_OS_ENABLE_TESTS: True if we are building *any* internal Mbed OS tests at all. Enabled by -DBUILD_TESTING=TRUE (which is enabled by default when standalone).
# - BUILD_GREENTEA_TESTS: True to build greentea on-target tests. False to build host UNITTESTS.
# - BUILD_GREENTEA_TESTS: True to build greentea on-target tests. False to build host UNITTESTS. Defaults to false when standalone.
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
# We are the top level project, so tests or unittests are being built.
@ -21,37 +22,41 @@ else()
set(MBED_OS_IS_STANDALONE FALSE)
endif()
if(CMAKE_CROSSCOMPILING)
set(MBED_IS_NATIVE_BUILD FALSE)
else()
set(MBED_IS_NATIVE_BUILD TRUE)
endif()
if(MBED_IS_NATIVE_BUILD)
# Pick up some include files that are needed later
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/tools/cmake)
endif()
if(MBED_IS_NATIVE_BUILD)
# Pick up some include files that are needed later
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/tools/cmake)
include(mbed_create_distro)
else()
# Grab the Mbed configs for this target
include(${MBED_CONFIG_PATH}/mbed_config.cmake)
include(mbed_set_linker_script)
endif()
# Set up options for testing
option(BUILD_TESTING "Whether to enable CTest tests in this project" ${MBED_OS_IS_STANDALONE}) # This option is also created by include(CTest) but we need it here earlier on.
if(MBED_OS_IS_STANDALONE AND BUILD_TESTING)
set(MBED_OS_ENABLE_TESTS TRUE)
option(BUILD_GREENTEA_TESTS "Build greentea tests instead of unit tests" ${CMAKE_CROSSCOMPILING})
option(BUILD_GREENTEA_TESTS "Build greentea tests instead of unit tests" FALSE)
endif()
# Figure out if this is a native build
if(MBED_OS_IS_STANDALONE)
# For standalong builds, look for mbed-config.cmake in the top level mbed os dir
# Standalone build, use BUILD_GREENTEA_TESTS to determine if we are building for native or not (user can select)
if(BUILD_GREENTEA_TESTS)
set(MBED_IS_NATIVE_BUILD FALSE)
else()
set(MBED_IS_NATIVE_BUILD TRUE)
endif()
else()
# Building as a subdir. This means that the top-level project will already have called project(), so we can
# rely on CMake's platform detection.
if(CMAKE_CROSSCOMPILING)
set(MBED_IS_NATIVE_BUILD FALSE)
else()
set(MBED_IS_NATIVE_BUILD TRUE)
endif()
endif()
if(MBED_OS_IS_STANDALONE AND NOT MBED_IS_NATIVE_BUILD)
# For standalone builds, default to looking for mbed-config.cmake in the binary dir
set(MBED_CONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR} CACHE STRING "")
# Initialize Mbed build system
include(${CMAKE_CURRENT_LIST_DIR}/tools/cmake/app.cmake)
endif()
if(MBED_IS_NATIVE_BUILD)
@ -77,7 +82,8 @@ endif()
# Create core Mbed OS targets and set up build flags ----------------------------------------------------------------------------------
project(mbed-os)
# Create project and find compilers (if not already found)
project(mbed-os LANGUAGES C CXX ASM)
# Add all paths to the list files within Mbed OS
list(APPEND CMAKE_MODULE_PATH
@ -100,8 +106,10 @@ endif()
# are spread in different directories can be referenced and can be linked against
# by libraries that depend on them.
add_library(mbed-device_key INTERFACE)
add_library(mbed-rtos INTERFACE) # Collects source files and flags that are in mbed-os but not mbed-baremetal
add_library(mbed-core INTERFACE) # Collects source files and flags common to mbed-baremetal and mbed-os
add_library(mbed-rtos-flags INTERFACE) # Collects source files that are in mbed-os but not mbed-baremetal
add_library(mbed-rtos-sources INTERFACE) # Collects flags that are in mbed-os but not mbed-baremetal
add_library(mbed-core-flags INTERFACE) # Collects flags common to mbed-baremetal and mbed-os
add_library(mbed-core-sources INTERFACE) # Collects source files common to mbed-baremetal and mbed-os
# Validate selected C library type
# The C library type selected has to match the library that the target can support
@ -132,13 +140,13 @@ if(NOT MBED_IS_NATIVE_BUILD)
)
endif()
mbed_set_cpu_core_definitions(mbed-core)
mbed_set_cpu_core_definitions(mbed-core-flags)
if(${MBED_TOOLCHAIN_FILE_USED})
mbed_set_profile_options(mbed-core ${MBED_TOOLCHAIN})
mbed_set_c_lib(mbed-core ${MBED_C_LIB})
mbed_set_printf_lib(mbed-core ${MBED_PRINTF_LIB})
mbed_set_profile_options(mbed-core-flags ${MBED_TOOLCHAIN})
mbed_set_c_lib(mbed-core-flags ${MBED_C_LIB})
mbed_set_printf_lib(mbed-core-flags ${MBED_PRINTF_LIB})
target_compile_features(mbed-core
target_compile_features(mbed-core-flags
INTERFACE
c_std_11
cxx_std_14
@ -146,7 +154,7 @@ if(NOT MBED_IS_NATIVE_BUILD)
endif()
target_compile_definitions(mbed-core
target_compile_definitions(mbed-core-flags
INTERFACE
TARGET_NAME=${MBED_TARGET}
)
@ -172,24 +180,31 @@ if(NOT MBED_IS_NATIVE_BUILD)
#
# TODO: Remove this and find a more idiomatic way of passing compile definitions to CPP without
# using response files or global properties.
mbed_generate_options_for_linker(mbed-core RESPONSE_FILE_PATH)
mbed_generate_options_for_linker(mbed-core-flags RESPONSE_FILE_PATH)
set_property(GLOBAL PROPERTY COMPILE_DEFS_RESPONSE_FILE ${RESPONSE_FILE_PATH})
# Add compile definitions for backward compatibility with the toolchain
# supported. New source files should instead check for __GNUC__ and __clang__
# for the GCC_ARM and ARM toolchains respectively.
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
target_compile_definitions(mbed-core
target_compile_definitions(mbed-core-flags
INTERFACE
TOOLCHAIN_GCC_ARM
TOOLCHAIN_GCC
)
elseif(${MBED_TOOLCHAIN} STREQUAL "ARM")
target_compile_definitions(mbed-core
target_compile_definitions(mbed-core-flags
INTERFACE
TOOLCHAIN_ARM
)
endif()
# Ensure the words that make up the Mbed target name are separated with a hyphen, lowercase, and with the `mbed-` prefix.
string(TOLOWER ${MBED_TARGET} MBED_TARGET_CMAKE_NAME)
string(REPLACE "_" "-" MBED_TARGET_CMAKE_NAME ${MBED_TARGET_CMAKE_NAME})
string(PREPEND MBED_TARGET_CMAKE_NAME "mbed-")
endif()
if(MBED_IS_NATIVE_BUILD)
@ -202,11 +217,11 @@ endif()
# Generate target config header and include it in all files
if(NOT MBED_IS_NATIVE_BUILD)
mbed_write_target_config_header(${CMAKE_CURRENT_BINARY_DIR}/mbed-target-config.h MBED_TARGET_DEFINITIONS MBED_CONFIG_DEFINITIONS)
target_compile_options(mbed-core INTERFACE -include ${CMAKE_CURRENT_BINARY_DIR}/mbed-target-config.h)
target_compile_options(mbed-core-flags INTERFACE -include ${CMAKE_CURRENT_BINARY_DIR}/mbed-target-config.h)
endif()
# Include mbed.h and config from generate folder
target_include_directories(mbed-core
target_include_directories(mbed-core-flags
INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}
)
@ -237,20 +252,20 @@ add_subdirectory(cmsis/device/rtos EXCLUDE_FROM_ALL)
# Create top-level targets ----------------------------------------------------------------------------------
if(NOT MBED_IS_NATIVE_BUILD)
# Ensure the words that make up the Mbed target name are separated with a hyphen, lowercase, and with the `mbed-` prefix.
string(TOLOWER ${MBED_TARGET} MBED_TARGET_CONVERTED)
string(REPLACE "_" "-" MBED_TARGET_CONVERTED ${MBED_TARGET_CONVERTED})
string(PREPEND MBED_TARGET_CONVERTED "mbed-")
endif()
if(NOT MBED_IS_NATIVE_BUILD)
# Core Mbed OS library
# Create a distro for the microcontroller cmake target, ensuring its sources are only compiled once
mbed_create_distro(${MBED_TARGET_CMAKE_NAME}-obj ${MBED_TARGET_CMAKE_NAME} mbed-core-flags)
# Now make core flags depend on that distro, ensuring everything has access to the uC's flags and objects.
target_link_libraries(mbed-core-flags INTERFACE ${MBED_TARGET_CMAKE_NAME}-obj)
# Core Mbed OS libraries
# mbed-baremetal contains baremetal sources + target sources + target compile flags.
# mbed-os will be a superset of mbed-baremetal, also containing the RTOS sources and RTOS flags.
# Note that many different source files will compile differently depending on if the RTOS is in use.
# So, it's needed to compile the core sources twice, once for RTOS and once for non-RTOS.
mbed_create_distro(mbed-baremetal mbed-core ${MBED_TARGET_CONVERTED})
mbed_create_distro(mbed-os mbed-core mbed-rtos ${MBED_TARGET_CONVERTED})
mbed_create_distro(mbed-baremetal mbed-core-flags mbed-core-sources)
mbed_create_distro(mbed-os mbed-core-flags mbed-core-sources mbed-rtos-flags mbed-rtos-sources)
endif()
# Ninja requires to be forced for response files

View File

@ -3,12 +3,12 @@
add_subdirectory(RTX)
target_include_directories(mbed-rtos
target_include_directories(mbed-rtos-flags
INTERFACE
Include
)
target_sources(mbed-rtos
target_sources(mbed-rtos-sources
INTERFACE
Source/os_systick.c
Source/os_tick_ptim.c

View File

@ -22,7 +22,7 @@ if(${CMAKE_CROSSCOMPILING})
set(STARTUP_RTX_FILE TARGET_RTOS_M4_M7/irq_cm4f.S)
endif()
target_sources(mbed-rtos
target_sources(mbed-rtos-sources
INTERFACE
Source/${toolchain_dir}/${STARTUP_RTX_FILE}
)
@ -42,7 +42,7 @@ if(${CMAKE_CROSSCOMPILING})
_mbed_get_cortex_m_exception_handlers(TOOLCHAIN_GCC)
endif()
target_include_directories(mbed-rtos
target_include_directories(mbed-rtos-flags
INTERFACE
Config
Include
@ -50,7 +50,7 @@ target_include_directories(mbed-rtos
Source
)
target_sources(mbed-rtos
target_sources(mbed-rtos-sources
INTERFACE
Config/RTX_Config.c

View File

@ -3,7 +3,7 @@
add_subdirectory(RTE)
target_include_directories(mbed-core
target_include_directories(mbed-core-flags
INTERFACE
.
)

View File

@ -1,7 +1,7 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
target_include_directories(mbed-core
target_include_directories(mbed-core-flags
INTERFACE
include
)

View File

@ -3,24 +3,24 @@
if(${CMAKE_CROSSCOMPILING})
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
target_sources(mbed-rtos
target_sources(mbed-rtos-sources
INTERFACE
TOOLCHAIN_GCC_ARM/mbed_boot_gcc_arm.c
)
elseif(${MBED_TOOLCHAIN} STREQUAL "ARM")
target_sources(mbed-rtos
target_sources(mbed-rtos-sources
INTERFACE
TOOLCHAIN_ARM_STD/mbed_boot_arm_std.c
)
endif()
endif()
target_include_directories(mbed-rtos
target_include_directories(mbed-rtos-flags
INTERFACE
include
)
target_sources(mbed-rtos
target_sources(mbed-rtos-sources
INTERFACE
source/mbed_boot.c
source/mbed_rtos_rtx.c
@ -28,7 +28,7 @@ target_sources(mbed-rtos
source/mbed_rtx_idle.cpp
)
target_compile_definitions(mbed-rtos
target_compile_definitions(mbed-rtos-flags
INTERFACE
MBED_CONF_RTOS_PRESENT=1
)

View File

@ -31,5 +31,5 @@ target_compile_definitions(mbed-cellular
target_link_libraries(mbed-cellular
INTERFACE
mbed-netsocket
mbed-core
mbed-core-flags
)

View File

@ -14,5 +14,5 @@ target_sources(mbed-ble
target_link_libraries(mbed-ble
INTERFACE
mbed-core
mbed-core-flags
)

View File

@ -22,16 +22,16 @@ target_sources(mbed-nanostack-libservice
# The definition, source files and include directories below
# are needed by mbed-trace which is part of the mbed-core CMake target
target_compile_definitions(mbed-core
target_compile_definitions(mbed-core-flags
INTERFACE
MBED_CONF_NANOSTACK_LIBSERVICE_PRESENT=1
)
target_include_directories(mbed-core
target_include_directories(mbed-core-flags
INTERFACE
.
./mbed-client-libservice
)
target_sources(mbed-core
target_sources(mbed-core-sources
INTERFACE
source/libBits/common_functions.c
source/libip6string/ip6tos.c

View File

@ -9,7 +9,7 @@ if(MBED_OS_ENABLE_TESTS)
endif()
endif()
target_include_directories(mbed-core
target_include_directories(mbed-core-flags
INTERFACE
.
./include
@ -17,7 +17,7 @@ target_include_directories(mbed-core
./include/drivers/internal
)
target_sources(mbed-core
target_sources(mbed-core-sources
INTERFACE
source/AnalogIn.cpp
source/AnalogOut.cpp

View File

@ -4,8 +4,8 @@
# List of all features libraries available.
add_library(mbed-fpga-ci-test-shield INTERFACE)
add_library(mbed-client-cli INTERFACE)
add_library(mbed-unity INTERFACE)
add_library(mbed-utest INTERFACE)
add_library(mbed-unity OBJECT EXCLUDE_FROM_ALL)
add_library(mbed-utest OBJECT EXCLUDE_FROM_ALL)
add_subdirectory(frameworks/COMPONENT_FPGA_CI_TEST_SHIELD)
add_subdirectory(frameworks/mbed-client-cli)

View File

@ -1,14 +1,17 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
add_library(mbed-greentea OBJECT EXCLUDE_FROM_ALL)
target_include_directories(mbed-greentea
INTERFACE
PUBLIC
.
greentea-client
)
target_sources(mbed-greentea
INTERFACE
PRIVATE
source/greentea_metrics.cpp
source/greentea_test_env.cpp
)
target_link_libraries(mbed-greentea PUBLIC mbed-core-flags)

View File

@ -1,6 +1,6 @@
# Copyright (c) 2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
add_library(mbed-greentea-io INTERFACE)
target_sources(mbed-greentea-io INTERFACE mbed_io.cpp)
target_link_libraries(mbed-greentea-io INTERFACE mbed-core)
add_library(mbed-greentea-io OBJECT EXCLUDE_FROM_ALL)
target_sources(mbed-greentea-io PRIVATE mbed_io.cpp)
target_link_libraries(mbed-greentea-io PUBLIC mbed-core-flags)

View File

@ -2,12 +2,14 @@
# SPDX-License-Identifier: Apache-2.0
target_include_directories(mbed-unity
INTERFACE
PUBLIC
.
unity
)
target_sources(mbed-unity
INTERFACE
PRIVATE
source/unity.c
)
target_link_libraries(mbed-unity PUBLIC mbed-core-flags mbed-utest)

View File

@ -2,13 +2,14 @@
# SPDX-License-Identifier: Apache-2.0
target_include_directories(mbed-utest
INTERFACE
PUBLIC
.
utest
../greentea-client
)
target_sources(mbed-utest
INTERFACE
PRIVATE
mbed-utest-shim.cpp
source/unity_handler.cpp
source/utest_case.cpp
@ -20,3 +21,5 @@ target_sources(mbed-utest
source/utest_stack_trace.cpp
source/utest_types.cpp
)
target_link_libraries(mbed-utest PUBLIC mbed-core-flags)

View File

@ -13,13 +13,13 @@ add_subdirectory(TARGET_FLASH_CMSIS_ALGO EXCLUDE_FROM_ALL)
add_subdirectory(usb)
target_include_directories(mbed-core
target_include_directories(mbed-core-flags
INTERFACE
include
include/hal
)
target_sources(mbed-core
target_sources(mbed-core-sources
INTERFACE
source/LowPowerTickerWrapper.cpp
source/mbed_compat.c

View File

@ -1,13 +1,13 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
target_include_directories(mbed-core
target_include_directories(mbed-core-flags
INTERFACE
include
include/usb
)
target_sources(mbed-core
target_sources(mbed-core-sources
INTERFACE
source/mbed_usb_phy.cpp
)

View File

@ -21,7 +21,7 @@ add_subdirectory(mbed-trace)
add_subdirectory(randlib)
add_subdirectory(source)
target_include_directories(mbed-core
target_include_directories(mbed-core-flags
INTERFACE
include
include/platform

View File

@ -20,7 +20,7 @@ target_sources(mbed-psa
src/psa_hrng.c
)
target_link_libraries(mbed-core
target_link_libraries(mbed-core-flags
INTERFACE
mbed-psa
)

View File

@ -1,12 +1,12 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
target_include_directories(mbed-core
target_include_directories(mbed-core-flags
INTERFACE
.
)
target_sources(mbed-core
target_sources(mbed-core-sources
INTERFACE
mstd_mutex.cpp
)

View File

@ -3,13 +3,13 @@
add_subdirectory(source)
target_include_directories(mbed-core
target_include_directories(mbed-core-flags
INTERFACE
include
include/mbed-trace
)
target_sources(mbed-core
target_sources(mbed-core-sources
INTERFACE
source/mbed_trace.c
)

View File

@ -7,12 +7,12 @@ endif()
add_subdirectory(minimal-printf)
target_include_directories(mbed-core
target_include_directories(mbed-core-flags
INTERFACE
.
)
target_sources(mbed-core
target_sources(mbed-core-sources
INTERFACE
ATCmdParser.cpp
CThunkBase.cpp
@ -50,7 +50,7 @@ target_sources(mbed-core
)
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM" AND MBED_C_LIB STREQUAL "small")
target_sources(mbed-core
target_sources(mbed-core-sources
INTERFACE
newlib_nano_malloc_workaround.c
)

View File

@ -1,9 +1,9 @@
# Copyright (c) 2020-2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
target_sources(mbed-core INTERFACE TOOLCHAIN_GCC/except.S)
target_sources(mbed-core-sources INTERFACE TOOLCHAIN_GCC/except.S)
target_sources(mbed-core
target_sources(mbed-core-sources
INTERFACE
mbed_fault_handler.c
)

View File

@ -1,12 +1,12 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
target_include_directories(mbed-core
target_include_directories(mbed-core-flags
INTERFACE
.
)
target_sources(mbed-core
target_sources(mbed-core-sources
INTERFACE
mbed_printf_armlink_overrides.c
mbed_printf_implementation.c

View File

@ -9,7 +9,7 @@ if(MBED_OS_ENABLE_TESTS)
endif()
endif()
target_include_directories(mbed-core
target_include_directories(mbed-core-flags
INTERFACE
.
./include
@ -18,7 +18,7 @@ target_include_directories(mbed-core
./source
)
target_sources(mbed-core
target_sources(mbed-core-sources
INTERFACE
source/EventFlags.cpp
source/Kernel.cpp
@ -30,7 +30,7 @@ target_sources(mbed-core
)
target_compile_definitions(mbed-core
target_compile_definitions(mbed-core-flags
INTERFACE
MBED_CONF_RTOS_API_PRESENT=1
)

View File

@ -13,6 +13,7 @@ endif()
include(${MBED_CONFIG_PATH}/mbed_config.cmake)
include(mbed_set_post_build)
include(mbed_generate_config_header)
include(mbed_create_distro)
# Load toolchain file
if(NOT CMAKE_TOOLCHAIN_FILE OR MBED_TOOLCHAIN_FILE_USED)
@ -62,6 +63,3 @@ else()
message(STATUS "Missing Python dependencies (python3, intelhex, prettytable) so the memory map cannot be printed")
endif()
# load mbed_create_distro
include(${CMAKE_CURRENT_LIST_DIR}/create_distro.cmake)

View File

@ -34,9 +34,6 @@ endfunction(copy_append_property)
function(mbed_create_distro NAME) # ARGN: modules...
add_library(${NAME} OBJECT EXCLUDE_FROM_ALL)
# First link as private dependencies
target_link_libraries(${NAME} PRIVATE ${ARGN})
# Now copy include dirs, compile defs, and compile options (but NOT interface source files) over
# to the distribution target so they will be passed into things that link to it.
# To do this, we need to recursively traverse the tree of dependencies.
@ -51,6 +48,27 @@ function(mbed_create_distro NAME) # ARGN: modules...
copy_append_property(INTERFACE_INCLUDE_DIRECTORIES ${CURR_MODULE} ${NAME})
copy_append_property(INTERFACE_LINK_OPTIONS ${CURR_MODULE} ${NAME})
# Make sure that linking to the distro pulls in the compiled code from CURR_MODULE
target_link_libraries(${NAME} PRIVATE ${CURR_MODULE})
# CMake currently has a limitation that OBJECT libraries cannot link to other OBJECT libraries
# via the LINK_LIBRARIES property -- CMake will not link the objects in properly :/.
# see: https://cmake.org/pipermail/cmake/2019-May/069453.html
# Once the INTERFACE_LINK_LIBRARIES_DIRECT property becomes widely available we could use that instead to fix this.
get_property(CURR_MODULE_TYPE TARGET ${CURR_MODULE} PROPERTY TYPE)
if("${CURR_MODULE_TYPE}" STREQUAL "OBJECT_LIBRARY")
target_sources(${NAME} INTERFACE $<TARGET_OBJECTS:${CURR_MODULE}>)
# Check if this object library has any other libraries exported through its INTERFACE_SOURCES.
# If it does, we need to propagate those too.
get_property(OBJ_INTERFACE_SOURCES TARGET ${NAME} PROPERTY INTERFACE_SOURCES)
foreach(INTERFACE_SOURCE ${OBJ_INTERFACE_SOURCES})
if(INTERFACE_SOURCE MATCHES "\\$<TARGET_OBJECTS:.*>")
target_sources(${NAME} INTERFACE ${INTERFACE_SOURCE})
endif()
endforeach()
endif()
list(REMOVE_AT REMAINING_MODULES 0)
list(APPEND COMPLETED_MODULES ${CURR_MODULE})
@ -58,8 +76,12 @@ function(mbed_create_distro NAME) # ARGN: modules...
get_property(SUBMODULES TARGET ${CURR_MODULE} PROPERTY INTERFACE_LINK_LIBRARIES)
foreach(SUBMODULE ${SUBMODULES})
if(NOT "${SUBMODULE}" MATCHES "::@") # remove CMake internal CMAKE_DIRECTORY_ID_SEP markers
if(NOT ${SUBMODULE} IN_LIST COMPLETED_MODULES)
list(APPEND REMAINING_MODULES ${SUBMODULE})
# Remove LINK_ONLY genexes from target_link_libraries(... PRIVATE). We can ignore things wrapped in these
# because they will already have been handled by the target_link_libraries earlier on.
if(NOT "${SUBMODULE}" MATCHES "\\$<LINK_ONLY:.*>")
if(NOT ${SUBMODULE} IN_LIST COMPLETED_MODULES)
list(APPEND REMAINING_MODULES ${SUBMODULE})
endif()
endif()
endif()
endforeach()

View File

@ -78,13 +78,6 @@ function(mbed_greentea_add_test)
return()
endif()
# TODO: After we convert all greentea tests to use CTest, remove this
# add_subdirectory call. We will attach the tests to the mbed-os project,
# rather than creating a new project for each test that depends on mbed-os.
if(NOT BUILD_GREENTEA_TESTS)
add_subdirectory(${MBED_ROOT} build)
endif()
add_executable(${MBED_GREENTEA_TEST_NAME})
target_include_directories(${MBED_GREENTEA_TEST_NAME}
@ -119,6 +112,12 @@ function(mbed_greentea_add_test)
set(MBED_GREENTEA_TEST_IMAGE_NAME "${MBED_GREENTEA_TEST_NAME}.bin")
endif()
# User can set this cache variable to supply extra arguments to greentea.
# such as: -d to set the drive path, -p to set the COM port.
if(DEFINED MBED_GREENTEA_EXTRA_HTRUN_ARGUMENTS)
list(APPEND MBED_HTRUN_ARGUMENTS ${MBED_GREENTEA_EXTRA_HTRUN_ARGUMENTS})
endif()
if(DEFINED MBED_GREENTEA_HOST_TESTS_DIR)
list(APPEND MBED_HTRUN_ARGUMENTS "-e;${MBED_GREENTEA_HOST_TESTS_DIR}")
endif()

View File

@ -6,6 +6,7 @@
# Called once for each MCU target in the build system.
#
function(mbed_set_linker_script input_target raw_linker_script_path)
set(LINKER_SCRIPT_PATH ${CMAKE_CURRENT_BINARY_DIR}/${input_target}.link_script.ld)
# To avoid path limits on Windows, we create a "response file" and set the path to it as a
# global property. We need this solely to pass the compile definitions to GCC's preprocessor,