CMake: Update mbed os, unittest CMake and add CMAKE_CROSSCOMPILING guard

- Add a new MbedOS project in mbed os root CMake which can be used along with
  BUILD_TESTING conditional check for enabling the unittest build
- Update UNITTEST CMake for setting the CMake configuration like c, cxx flags etc.,
- Add if CMAKE_CROSSCOMPILING conditional check wherever target configuration check
  and toolchain configuration to avoid such configuration gets included for unittest build.
pull/14426/head
Rajkumar Kanagaraj 2021-04-07 07:56:38 -07:00
parent 4ade0bdbea
commit a88f43f367
6 changed files with 193 additions and 345 deletions

2
.gitignore vendored
View File

@ -102,3 +102,5 @@ DELIVERY/
CMakeCache.txt
cmake_install.cmake
CMakeFiles/
cmake_build/
Testing/

View File

@ -5,8 +5,10 @@
cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR)
include(${MBED_CONFIG_PATH}/mbed_config.cmake)
include(mbed_set_linker_script)
if(${CMAKE_CROSSCOMPILING})
include(${MBED_CONFIG_PATH}/mbed_config.cmake)
include(mbed_set_linker_script)
endif()
project(mbed-os)
@ -15,6 +17,18 @@ list(APPEND CMAKE_MODULE_PATH
"${mbed-os_SOURCE_DIR}/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/scripts;${mbed-os_SOURCE_DIR}/targets/TARGET_Cypress/scripts;${mbed-os_SOURCE_DIR}/targets/TARGET_NXP/scripts"
)
option(BUILD_TESTING "Run unit tests only." OFF)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
include(CTest)
add_subdirectory(UNITTESTS)
# Add MBED_TEST_MODE for backward compatibility with Greentea tests written for use with Mbed CLI 1
target_compile_definitions(${PROJECT_NAME}
PUBLIC
MBED_TEST_MODE
)
endif()
add_library(mbed-core INTERFACE)
add_library(mbed-os INTERFACE)
@ -33,88 +47,83 @@ target_link_libraries(mbed-baremetal
)
# 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")
if(NOT "small" IN_LIST MBED_TARGET_SUPPORTED_C_LIBS)
if("std" IN_LIST MBED_TARGET_SUPPORTED_C_LIBS)
message(WARNING
"We noticed that target.c_lib is set to `${MBED_C_LIB}`."
" As the ${MBED_TARGET} target does not support a small C library for the ${MBED_TOOLCHAIN} toolchain,"
" we are using the standard C library instead."
)
set(MBED_C_LIB "std" CACHE STRING "")
if(${CMAKE_CROSSCOMPILING})
if(${MBED_C_LIB} STREQUAL "small")
if(NOT "small" IN_LIST MBED_TARGET_SUPPORTED_C_LIBS)
if("std" IN_LIST MBED_TARGET_SUPPORTED_C_LIBS)
message(WARNING
"We noticed that target.c_lib is set to `${MBED_C_LIB}`."
" As the ${MBED_TARGET} target does not support a small C library for the ${MBED_TOOLCHAIN} toolchain,"
" we are using the standard C library instead."
)
set(MBED_C_LIB "std" CACHE STRING "")
endif()
endif()
elseif(NOT ${MBED_C_LIB} IN_LIST MBED_TARGET_SUPPORTED_C_LIBS)
message(FATAL_ERROR
"Invalid `target.c_lib` ('${MBED_C_LIB}') for '${MBED_TARGET}' target."
"\nPossible value(s): ${MBED_TARGET_SUPPORTED_C_LIBS}"
)
endif()
elseif(NOT ${MBED_C_LIB} IN_LIST MBED_TARGET_SUPPORTED_C_LIBS)
message(FATAL_ERROR
"Invalid `target.c_lib` ('${MBED_C_LIB}') for '${MBED_TARGET}' target."
"\nPossible value(s): ${MBED_TARGET_SUPPORTED_C_LIBS}"
)
endif()
# Validate selected printf library
set(MBED_PRINTF_LIB_TYPES std minimal-printf)
if(NOT ${MBED_PRINTF_LIB} IN_LIST MBED_PRINTF_LIB_TYPES)
message(FATAL_ERROR
"Invalid printf library type '${MBED_PRINTF_LIB}'. Possible values:\n ${MBED_PRINTF_LIB_TYPES}"
)
endif()
# Validate selected printf library
set(MBED_PRINTF_LIB_TYPES std minimal-printf)
if(NOT ${MBED_PRINTF_LIB} IN_LIST MBED_PRINTF_LIB_TYPES)
message(FATAL_ERROR
"Invalid printf library type '${MBED_PRINTF_LIB}'. Possible values:\n ${MBED_PRINTF_LIB_TYPES}"
)
endif()
mbed_set_cpu_core_definitions(mbed-core)
if(${MBED_TOOLCHAIN_FILE_USED})
message(STATUS ${MBED_TOOLCHAIN})
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})
target_compile_features(mbed-core
INTERFACE
c_std_11
cxx_std_14
)
endif()
mbed_set_cpu_core_definitions(mbed-core)
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})
target_compile_features(mbed-core
INTERFACE
c_std_11
cxx_std_14
)
endif()
target_compile_definitions(mbed-core
INTERFACE
${MBED_TARGET_DEFINITIONS}
${MBED_CONFIG_DEFINITIONS}
)
# Add MBED_TEST_MODE for backward compatibility with Greentea tests written for use with Mbed CLI 1
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
target_compile_definitions(${PROJECT_NAME}
PUBLIC
MBED_TEST_MODE
)
endif()
# We need to generate a "response file" to pass to the C preprocessor when we preprocess the linker
# script, because of path length limitations on Windows. We set the response file and bind the path
# to a global property here. The MBED_TARGET being built queries this global property when it sets
# the linker script.
#
# We must set this global property before the targets subdirectory is added to the project. This is
# required because the MBED_TARGET depends on the response file. If the path to the response file
# is not defined when the target requests it the config definitions will not be passed to CPP.
#
# 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)
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
INTERFACE
TOOLCHAIN_GCC_ARM
TOOLCHAIN_GCC
)
elseif(${MBED_TOOLCHAIN} STREQUAL "ARM")
target_compile_definitions(mbed-core
INTERFACE
TOOLCHAIN_ARM
${MBED_TARGET_DEFINITIONS}
${MBED_CONFIG_DEFINITIONS}
)
# We need to generate a "response file" to pass to the C preprocessor when we preprocess the linker
# script, because of path le ngth limitations on Windows. We set the response file and bind the path
# to a global property here. The MBED_TARGET being built queries this global property when it sets
# the linker script.
#
# We must set this global property before the targets subdirectory is added to the project. This is
# required because the MBED_TARGET depends on the response file. If the path to the response file
# is not defined when the target requests it the config definitions will not be passed to CPP.
#
# 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)
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
INTERFACE
TOOLCHAIN_GCC_ARM
TOOLCHAIN_GCC
)
elseif(${MBED_TOOLCHAIN} STREQUAL "ARM")
target_compile_definitions(mbed-core
INTERFACE
TOOLCHAIN_ARM
)
endif()
endif()
# Include mbed.h and config from generate folder
@ -135,24 +144,35 @@ add_subdirectory(drivers)
add_subdirectory(hal)
add_subdirectory(platform)
add_subdirectory(rtos)
add_subdirectory(targets)
if(${CMAKE_CROSSCOMPILING})
add_subdirectory(targets)
# The directories below contain optional target libraries
add_subdirectory(connectivity EXCLUDE_FROM_ALL)
add_subdirectory(storage EXCLUDE_FROM_ALL)
add_subdirectory(events EXCLUDE_FROM_ALL)
else()
add_subdirectory(connectivity)
add_subdirectory(storage)
add_subdirectory(events)
endif()
# The directories below contain optional target libraries
add_subdirectory(events EXCLUDE_FROM_ALL)
add_subdirectory(connectivity EXCLUDE_FROM_ALL)
add_subdirectory(storage EXCLUDE_FROM_ALL)
add_subdirectory(drivers/device_key EXCLUDE_FROM_ALL)
add_subdirectory(drivers/usb EXCLUDE_FROM_ALL)
add_subdirectory(features EXCLUDE_FROM_ALL)
add_subdirectory(cmsis/CMSIS_5/CMSIS/RTOS2 EXCLUDE_FROM_ALL)
add_subdirectory(cmsis/device/rtos EXCLUDE_FROM_ALL)
# 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-")
target_link_libraries(mbed-core INTERFACE ${MBED_TARGET_CONVERTED})
if(${CMAKE_CROSSCOMPILING})
# 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-")
target_link_libraries(mbed-core INTERFACE ${MBED_TARGET_CONVERTED})
endif()
#
# Converts output file of `target` to binary file and to Intel HEX file.

View File

@ -1,75 +1,39 @@
cmake_minimum_required(VERSION 3.0.2)
set(PROJECT_NAME unittests)
set(LIB_NAME MbedOS)
project(${PROJECT_NAME})
# Copyright (c) 2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# Setup c++ standard
macro(use_cxx14)
if (CMAKE_VERSION VERSION_LESS 3.1)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++14")
endif()
else()
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
endmacro()
use_cxx14()
set(CMAKE_CXX_STANDARD 14 CACHE STRING "")
set(CMAKE_CXX_STANDARD_REQUIRED ON CACHE BOOL "")
add_definitions(-DUNITTEST)
if (MINGW)
# enable PRIx formatting globally
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__STDC_FORMAT_MACROS")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_FORMAT_MACROS")
# enable PRIx formatting globally
add_definitions(-D__STDC_FORMAT_MACROS)
endif (MINGW)
####################
# GTEST
####################
# Download and unpack googletest at configure time
configure_file(googletest-CMakeLists.txt.in googletest-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download)
if (result)
message(FATAL_ERROR "CMake failed for google test: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download)
if (result)
message(FATAL_ERROR "Build failed for google test: ${result}")
endif()
include(FetchContent)
# Download and unpack googletest
FetchContent_Declare(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.10.0
)
FetchContent_MakeAvailable(googletest)
# Prevent overriding the parent project's compiler/linker
# settings on Windows
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
# Add googletest directly to our build. This defines
# the gtest and gtest_main targets.
add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src
${CMAKE_BINARY_DIR}/googletest-build
EXCLUDE_FROM_ALL)
# The gtest/gtest_main/gmock/gmock_main targets carry header search path
# dependencies automatically when using CMake 2.8.11 or
# later.
target_include_directories(gmock_main SYSTEM BEFORE INTERFACE
"$<BUILD_INTERFACE:${gtest_SOURCE_DIR}/include>"
"$<BUILD_INTERFACE:${gmock_SOURCE_DIR}/include>")
####################
# TESTING
####################
include(CTest)
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
"${CMAKE_BINARY_DIR}/Testing"
"${CMAKE_BINARY_DIR}/Testing"
)
####################
@ -78,163 +42,19 @@ set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
if (COVERAGE)
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
message(WARNING "Non-debug build may result misleading code coverage results.")
endif()
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
message(WARNING "Non-debug build may result misleading code coverage results.")
endif()
# Append coverage compiler flags
set(COVERAGE_COMPILER_FLAGS "-g -O0 --coverage")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COVERAGE_COMPILER_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COVERAGE_COMPILER_FLAGS}")
# Append coverage compiler flags
set(COVERAGE_COMPILER_FLAGS "-g -O0 --coverage")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COVERAGE_COMPILER_FLAGS}" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COVERAGE_COMPILER_FLAGS}" CACHE STRING "" FORCE)
endif(COVERAGE)
if (VALGRIND)
find_program(MEMORYCHECK_COMMAND valgrind)
find_program(MEMORYCHECK_COMMAND valgrind)
endif(VALGRIND)
####################
# UNIT TESTS
####################
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUNITTEST")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUNITTEST")
# Set include dirs.
set(unittest-includes-base
"${PROJECT_SOURCE_DIR}/target_h"
"${PROJECT_SOURCE_DIR}/../events/tests/UNITTESTS/target_h"
"${PROJECT_SOURCE_DIR}/../events/tests/UNITTESTS/target_h/equeue"
"${PROJECT_SOURCE_DIR}/target_h/platform"
"${PROJECT_SOURCE_DIR}/target_h/platform/cxxsupport"
"${PROJECT_SOURCE_DIR}/target_h/drivers"
"${PROJECT_SOURCE_DIR}/target_h/rtos/include"
"${PROJECT_SOURCE_DIR}/stubs"
"${PROJECT_SOURCE_DIR}/.."
"${PROJECT_SOURCE_DIR}/../features"
"${PROJECT_SOURCE_DIR}/../platform/include"
"${PROJECT_SOURCE_DIR}/../platform/include/platform"
"${PROJECT_SOURCE_DIR}/../platform/mbed-trace/include"
"${PROJECT_SOURCE_DIR}/../storage/filesystem/littlefs/include"
"${PROJECT_SOURCE_DIR}/../storage/filesystem/fat/include"
"${PROJECT_SOURCE_DIR}/../storage/blockdevice/include"
"${PROJECT_SOURCE_DIR}/../storage/filesystem/include"
"${PROJECT_SOURCE_DIR}/../storage/kvstore/include"
"${PROJECT_SOURCE_DIR}/../storage/kvstore/kv_config"
"${PROJECT_SOURCE_DIR}/../storage/kvstore/kv_config/include"
"${PROJECT_SOURCE_DIR}/../storage/kvstore/tdbstore/include"
"${PROJECT_SOURCE_DIR}/../storage/kvstore/filesystemstore/include"
"${PROJECT_SOURCE_DIR}/../storage/kvstore/kvstore_global_api/include"
"${PROJECT_SOURCE_DIR}/../drivers"
"${PROJECT_SOURCE_DIR}/../drivers/include"
"${PROJECT_SOURCE_DIR}/../drivers/include/drivers"
"${PROJECT_SOURCE_DIR}/../drivers/include/drivers/internal"
"${PROJECT_SOURCE_DIR}/../hal"
"${PROJECT_SOURCE_DIR}/../hal/include"
"${PROJECT_SOURCE_DIR}/../events/include"
"${PROJECT_SOURCE_DIR}/../events/include/events/internal"
"${PROJECT_SOURCE_DIR}/../events/source"
"${PROJECT_SOURCE_DIR}/../rtos/include"
"${PROJECT_SOURCE_DIR}/../features/frameworks"
"${PROJECT_SOURCE_DIR}/../connectivity/libraries/nanostack-libservice"
"${PROJECT_SOURCE_DIR}/../connectivity/libraries/nanostack-libservice/mbed-client-libservice"
"${PROJECT_SOURCE_DIR}/../connectivity/netsocket/include"
"${PROJECT_SOURCE_DIR}/../features/filesystem/fat"
"${PROJECT_SOURCE_DIR}/../features/filesystem/fat/ChaN"
"${PROJECT_SOURCE_DIR}/../features/filesystem/bd"
"${PROJECT_SOURCE_DIR}/../features/filesystem/"
"${PROJECT_SOURCE_DIR}/../features/filesystem/littlefs"
"${PROJECT_SOURCE_DIR}/../features/filesystem/littlefs/littlefs"
"${PROJECT_SOURCE_DIR}/../connectivity/cellular/include/cellular/framework/API"
"${PROJECT_SOURCE_DIR}/../connectivity/cellular/include/cellular/framework/AT"
"${PROJECT_SOURCE_DIR}/../connectivity/cellular/include/cellular/framework/device"
"${PROJECT_SOURCE_DIR}/../connectivity/cellular/include/cellular/framework"
"${PROJECT_SOURCE_DIR}/../connectivity/cellular/include/cellular/framework/common"
"${PROJECT_SOURCE_DIR}/../connectivity"
"${PROJECT_SOURCE_DIR}/../connectivity/lorawan/include/lorawan"
"${PROJECT_SOURCE_DIR}/../connectivity/lorawan/lorastack"
"${PROJECT_SOURCE_DIR}/../connectivity/lorawan/lorastack/mac"
"${PROJECT_SOURCE_DIR}/../connectivity/lorawan/lorastack/phy"
"${PROJECT_SOURCE_DIR}/../connectivity/lorawan"
"${PROJECT_SOURCE_DIR}/../connectivity/mbedtls"
"${PROJECT_SOURCE_DIR}/../connectivity/mbedtls/include"
)
# Create a list for test suites.
set(TEST_SUITES)
# Get all matched tests.
file(GLOB_RECURSE unittest-file-list
"../unittest.cmake" # matches any ../**/unittest.cmake
)
if ("${unittest-file-list}" STREQUAL "")
message(FATAL_ERROR "No tests found. Exiting...")
endif()
# Create unit test targets
foreach(testfile ${unittest-file-list})
####################
# DEFINE TARGETS
####################
# Init file lists.
set(unittest-includes ${unittest-includes-base})
set(unittest-sources)
set(unittest-test-sources)
set(unittest-test-flags)
# Get source files
include("${testfile}")
get_filename_component(TEST_SUITE_DIR ${testfile} DIRECTORY)
file(RELATIVE_PATH
TEST_SUITE_NAME # output
"${PROJECT_SOURCE_DIR}/.." # root
${TEST_SUITE_DIR} #abs dirpath
)
string(REGEX REPLACE "/|\\\\" "-" TEST_SUITE_NAME ${TEST_SUITE_NAME})
set(TEST_SUITES ${TEST_SUITES} ${TEST_SUITE_NAME})
set(LIBS_TO_BE_LINKED gmock_main)
# Build directories list
set(BUILD_DIRECTORIES)
if (unittest-sources)
# Create the testable static library.
add_library("${TEST_SUITE_NAME}.${LIB_NAME}" STATIC ${unittest-sources})
target_include_directories("${TEST_SUITE_NAME}.${LIB_NAME}" PRIVATE
${unittest-includes})
target_compile_options("${TEST_SUITE_NAME}.${LIB_NAME}" PRIVATE
${unittest-test-flags})
set(LIBS_TO_BE_LINKED ${LIBS_TO_BE_LINKED} "${TEST_SUITE_NAME}.${LIB_NAME}")
# Append lib build directory to list
list(APPEND BUILD_DIRECTORIES "./CMakeFiles/${TEST_SUITE_NAME}.${LIB_NAME}.dir")
endif(unittest-sources)
if (unittest-test-sources)
# Create the executable.
add_executable(${TEST_SUITE_NAME} ${unittest-test-sources})
target_include_directories(${TEST_SUITE_NAME} PRIVATE
${unittest-includes})
target_compile_options(${TEST_SUITE_NAME} PRIVATE
${unittest-test-flags})
# Link the executable with the libraries.
target_link_libraries(${TEST_SUITE_NAME} ${LIBS_TO_BE_LINKED})
add_test(NAME "${TEST_SUITE_NAME}" COMMAND ${TEST_SUITE_NAME})
# Append test build directory to list
list(APPEND BUILD_DIRECTORIES "./CMakeFiles/${TEST_SUITE_NAME}.dir")
else()
message(WARNING "No test source files found for ${TEST_SUITE_NAME}.\n")
endif(unittest-test-sources)
endforeach(testfile)
add_subdirectory(stubs)

View File

@ -1,47 +1,49 @@
# Copyright (c) 2020-2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
function(_mbed_get_cortex_m_exception_handlers toolchain_dir)
foreach(key ${MBED_TARGET_LABELS})
if(${key} STREQUAL CORTEX_A)
set(STARTUP_RTX_FILE TARGET_CORTEX_A/irq_ca.S)
elseif(${key} STREQUAL M0)
set(STARTUP_RTX_FILE TARGET_M0/irq_cm0.S)
elseif(${key} STREQUAL M0P)
set(STARTUP_RTX_FILE TARGET_M0P/irq_cm0.S)
elseif(${key} STREQUAL M23)
set(STARTUP_RTX_FILE TARGET_M23/irq_armv8mbl.S)
elseif(${key} STREQUAL M3)
set(STARTUP_RTX_FILE TARGET_M3/irq_cm3.S)
elseif(${key} STREQUAL M33)
set(STARTUP_RTX_FILE TARGET_M33/irq_armv8mml.S)
elseif(${key} STREQUAL M55)
set(STARTUP_RTX_FILE TARGET_M33/irq_armv8mml.S)
elseif(${key} STREQUAL RTOS_M4_M7)
set(STARTUP_RTX_FILE TARGET_RTOS_M4_M7/irq_cm4f.S)
endif()
if(${CMAKE_CROSSCOMPILING})
function(_mbed_get_cortex_m_exception_handlers toolchain_dir)
foreach(key ${MBED_TARGET_LABELS})
if(${key} STREQUAL CORTEX_A)
set(STARTUP_RTX_FILE TARGET_CORTEX_A/irq_ca.S)
elseif(${key} STREQUAL M0)
set(STARTUP_RTX_FILE TARGET_M0/irq_cm0.S)
elseif(${key} STREQUAL M0P)
set(STARTUP_RTX_FILE TARGET_M0P/irq_cm0.S)
elseif(${key} STREQUAL M23)
set(STARTUP_RTX_FILE TARGET_M23/irq_armv8mbl.S)
elseif(${key} STREQUAL M3)
set(STARTUP_RTX_FILE TARGET_M3/irq_cm3.S)
elseif(${key} STREQUAL M33)
set(STARTUP_RTX_FILE TARGET_M33/irq_armv8mml.S)
elseif(${key} STREQUAL M55)
set(STARTUP_RTX_FILE TARGET_M33/irq_armv8mml.S)
elseif(${key} STREQUAL RTOS_M4_M7)
set(STARTUP_RTX_FILE TARGET_RTOS_M4_M7/irq_cm4f.S)
endif()
target_sources(mbed-rtos
INTERFACE
Source/${toolchain_dir}/${STARTUP_RTX_FILE}
)
endforeach()
endfunction()
function(_mbed_get_cortex_a_exception_handlers)
foreach(key ${MBED_TARGET_LABELS})
if(${key} STREQUAL CORTEX_A)
target_sources(mbed-rtos INTERFACE Config/TARGET_CORTEX_A/handlers.c)
endif()
endforeach()
endfunction()
_mbed_get_cortex_a_exception_handlers()
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
_mbed_get_cortex_m_exception_handlers(TOOLCHAIN_GCC)
elseif(${MBED_TOOLCHAIN} STREQUAL "ARM")
_mbed_get_cortex_m_exception_handlers(TOOLCHAIN_ARM)
target_sources(mbed-rtos
INTERFACE
Source/${toolchain_dir}/${STARTUP_RTX_FILE}
)
endforeach()
endfunction()
function(_mbed_get_cortex_a_exception_handlers)
foreach(key ${MBED_TARGET_LABELS})
if(${key} STREQUAL CORTEX_A)
target_sources(mbed-rtos INTERFACE Config/TARGET_CORTEX_A/handlers.c)
endif()
endforeach()
endfunction()
_mbed_get_cortex_a_exception_handlers()
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
_mbed_get_cortex_m_exception_handlers(TOOLCHAIN_GCC)
elseif(${MBED_TOOLCHAIN} STREQUAL "ARM")
_mbed_get_cortex_m_exception_handlers(TOOLCHAIN_ARM)
endif()
endif()
target_include_directories(mbed-rtos

View File

@ -1,16 +1,18 @@
# Copyright (c) 2020-2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
target_sources(mbed-rtos
INTERFACE
TOOLCHAIN_GCC_ARM/mbed_boot_gcc_arm.c
)
elseif(${MBED_TOOLCHAIN} STREQUAL "ARM")
target_sources(mbed-rtos
INTERFACE
TOOLCHAIN_ARM_STD/mbed_boot_arm_std.c
)
if(${CMAKE_CROSSCOMPILING})
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
target_sources(mbed-rtos
INTERFACE
TOOLCHAIN_GCC_ARM/mbed_boot_gcc_arm.c
)
elseif(${MBED_TOOLCHAIN} STREQUAL "ARM")
target_sources(mbed-rtos
INTERFACE
TOOLCHAIN_ARM_STD/mbed_boot_arm_std.c
)
endif()
endif()
target_include_directories(mbed-rtos

View File

@ -3,13 +3,15 @@
add_library(mbed-wiced INTERFACE)
if(${MBED_TOOLCHAIN} STREQUAL "ARM")
set(LIB_WICED_DRIVERS TOOLCHAIN_ARMC6/TARGET_WIO_EMW3166/libwiced_drivers.ar)
elseif(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
set(LIB_WICED_DRIVERS TOOLCHAIN_GCC_ARM/TARGET_WIO_EMW3166/libwiced_drivers.a)
endif()
if(${CMAKE_CROSSCOMPILING})
if(${MBED_TOOLCHAIN} STREQUAL "ARM")
set(LIB_WICED_DRIVERS TOOLCHAIN_ARMC6/TARGET_WIO_EMW3166/libwiced_drivers.ar)
elseif(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
set(LIB_WICED_DRIVERS TOOLCHAIN_GCC_ARM/TARGET_WIO_EMW3166/libwiced_drivers.a)
endif()
target_link_libraries(mbed-wiced INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/${LIB_WICED_DRIVERS})
endif()
target_include_directories(mbed-wiced
INTERFACE