Anton Komlev | 94758d4 | 2023-06-15 16:39:36 +0100 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Matthew Dalzell | 0d154c8 | 2025-02-10 14:07:27 +0000 | [diff] [blame^] | 2 | # Copyright (c) 2023-2025, Arm Limited. All rights reserved. |
Anton Komlev | 94758d4 | 2023-06-15 16:39:36 +0100 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | # |
| 8 | # This CMake script used in a split build only. In the legacy 'sinlge' build |
| 9 | # this file is ignoed. Please don't be confused. |
| 10 | # |
David Hu | 4c3c0ca | 2023-12-02 22:09:18 +0800 | [diff] [blame] | 11 | cmake_minimum_required(VERSION 3.21) |
Anton Komlev | 94758d4 | 2023-06-15 16:39:36 +0100 | [diff] [blame] | 12 | |
| 13 | add_library(CMSIS_5_RTX_V8MMN STATIC IMPORTED GLOBAL) |
| 14 | add_library(CMSIS_5_RTX_V8MMFN STATIC IMPORTED GLOBAL) |
| 15 | add_library(CMSIS_5_RTX_V8MBN STATIC IMPORTED GLOBAL) |
| 16 | add_library(CMSIS_5_RTX_CM3 STATIC IMPORTED GLOBAL) |
| 17 | |
David Hu | 87b46a8 | 2023-10-21 23:23:42 +0800 | [diff] [blame] | 18 | set(CMSIS_LIBS_DIR ${CMAKE_CURRENT_LIST_DIR}/RTOS2/RTX/Library) |
Anton Komlev | 94758d4 | 2023-06-15 16:39:36 +0100 | [diff] [blame] | 19 | |
| 20 | if ("${CMAKE_C_COMPILER_ID}" STREQUAL GNU) |
| 21 | set_target_properties(CMSIS_5_RTX_V8MMN PROPERTIES IMPORTED_LOCATION ${CMSIS_LIBS_DIR}/GCC/libRTX_V8MMN.a) |
| 22 | set_target_properties(CMSIS_5_RTX_V8MMFN PROPERTIES IMPORTED_LOCATION ${CMSIS_LIBS_DIR}/GCC/libRTX_V8MMFN.a) |
| 23 | set_target_properties(CMSIS_5_RTX_V8MBN PROPERTIES IMPORTED_LOCATION ${CMSIS_LIBS_DIR}/GCC/libRTX_V8MBN.a) |
| 24 | set_target_properties(CMSIS_5_RTX_CM3 PROPERTIES IMPORTED_LOCATION ${CMSIS_LIBS_DIR}/GCC/libRTX_CM3.a) |
Matthew Dalzell | 0d154c8 | 2025-02-10 14:07:27 +0000 | [diff] [blame^] | 25 | elseif(("${CMAKE_C_COMPILER_ID}" STREQUAL ARMClang) |
| 26 | OR ("${CMAKE_C_COMPILER_ID}" STREQUAL Clang)) |
Anton Komlev | 94758d4 | 2023-06-15 16:39:36 +0100 | [diff] [blame] | 27 | set_target_properties(CMSIS_5_RTX_V8MMN PROPERTIES IMPORTED_LOCATION ${CMSIS_LIBS_DIR}/ARM/RTX_V8MMN.lib) |
| 28 | set_target_properties(CMSIS_5_RTX_V8MMFN PROPERTIES IMPORTED_LOCATION ${CMSIS_LIBS_DIR}/ARM/RTX_V8MMFN.lib) |
| 29 | set_target_properties(CMSIS_5_RTX_V8MBN PROPERTIES IMPORTED_LOCATION ${CMSIS_LIBS_DIR}/ARM/RTX_V8MBN.lib) |
| 30 | set_target_properties(CMSIS_5_RTX_CM3 PROPERTIES IMPORTED_LOCATION ${CMSIS_LIBS_DIR}/ARM/RTX_CM3.lib) |
| 31 | elseif("${CMAKE_C_COMPILER_ID}" STREQUAL IAR) |
| 32 | add_library(CMSIS_5_RTX_V81MMN STATIC IMPORTED GLOBAL) |
| 33 | set_target_properties(CMSIS_5_RTX_V8MMN PROPERTIES IMPORTED_LOCATION ${CMSIS_LIBS_DIR}/IAR/RTX_V8MMN.a) |
| 34 | set_target_properties(CMSIS_5_RTX_V81MMN PROPERTIES IMPORTED_LOCATION ${CMSIS_LIBS_DIR}/IAR/RTX_V81MMN.a) |
| 35 | set_target_properties(CMSIS_5_RTX_V8MMFN PROPERTIES IMPORTED_LOCATION ${CMSIS_LIBS_DIR}/IAR/RTX_V8MMFN.a) |
| 36 | set_target_properties(CMSIS_5_RTX_V8MBN PROPERTIES IMPORTED_LOCATION ${CMSIS_LIBS_DIR}/IAR/RTX_V8MBN.a) |
| 37 | set_target_properties(CMSIS_5_RTX_CM3 PROPERTIES IMPORTED_LOCATION ${CMSIS_LIBS_DIR}/IAR/RTX_CM3.a) |
| 38 | else() |
| 39 | message(FATAL_ERROR "${CMAKE_C_COMPILER_ID} does not have CMSIS RTX static libraries set up") |
| 40 | endif() |
| 41 | |
Kevin Peng | 7723011 | 2023-10-12 14:14:54 +0800 | [diff] [blame] | 42 | if(NOT DEFINED CMSIS_5_RTX_LIB) |
Kevin Peng | 7dc5934 | 2023-10-26 13:56:10 +0800 | [diff] [blame] | 43 | # Select RTX library according to cpu/arch if platform does not select one. |
| 44 | if(TFM_SYSTEM_ARCHITECTURE STREQUAL "armv6-m") |
| 45 | set(CMSIS_5_RTX_LIB "CMSIS_5_RTX_CM3") |
| 46 | elseif(TFM_SYSTEM_ARCHITECTURE STREQUAL "armv8-m.base") |
| 47 | set(CMSIS_5_RTX_LIB "CMSIS_5_RTX_V8MBN") |
| 48 | elseif(TFM_SYSTEM_ARCHITECTURE STREQUAL "armv8-m.main") |
| 49 | if(CONFIG_TFM_ENABLE_FP OR CONFIG_TFM_ENABLE_MVE_FP) |
| 50 | set(CMSIS_5_RTX_LIB "CMSIS_5_RTX_V8MMFN") |
| 51 | else() |
| 52 | set(CMSIS_5_RTX_LIB "CMSIS_5_RTX_V8MMN") |
| 53 | endif() |
| 54 | elseif(TFM_SYSTEM_ARCHITECTURE STREQUAL "armv8.1-m.main") |
| 55 | if("${CMAKE_C_COMPILER_ID}" STREQUAL "IAR") |
| 56 | set(CMSIS_5_RTX_LIB "CMSIS_5_RTX_V81MMN") |
| 57 | elseif(CONFIG_TFM_ENABLE_FP OR CONFIG_TFM_ENABLE_MVE_FP) |
| 58 | set(CMSIS_5_RTX_LIB "CMSIS_5_RTX_V8MMFN") |
| 59 | else() |
| 60 | set(CMSIS_5_RTX_LIB "CMSIS_5_RTX_V8MMN") |
| 61 | endif() |
| 62 | elseif(TFM_SYSTEM_PROCESSOR STREQUAL "cortex-m4") |
| 63 | set(CMSIS_5_RTX_LIB "CMSIS_5_RTX_CM3") |
| 64 | else() |
| 65 | message(FATAL_ERROR |
| 66 | "CMSIS_5_RTX_LIB library is NOT defined." |
| 67 | "Unsupported processor ${TFM_SYSTEM_PROCESSOR} or architecture ${TFM_SYSTEM_ARCHITECTURE}." |
| 68 | "Specify it in build command or update TFM_SYSTEM_PROCESSOR/TFM_SYSTEM_ARCHITECTURE.") |
| 69 | endif() |
Kevin Peng | 7723011 | 2023-10-12 14:14:54 +0800 | [diff] [blame] | 70 | endif() |
| 71 | |
David Hu | 87b46a8 | 2023-10-21 23:23:42 +0800 | [diff] [blame] | 72 | add_library(RTX_OS INTERFACE) |
Anton Komlev | 94758d4 | 2023-06-15 16:39:36 +0100 | [diff] [blame] | 73 | |
| 74 | target_sources(RTX_OS |
David Hu | 87b46a8 | 2023-10-21 23:23:42 +0800 | [diff] [blame] | 75 | INTERFACE |
Anton Komlev | 94758d4 | 2023-06-15 16:39:36 +0100 | [diff] [blame] | 76 | RTOS2/RTX/Config/RTX_Config.c |
| 77 | RTOS2/RTX/Source/rtx_lib.c |
| 78 | ) |
| 79 | |
| 80 | target_include_directories(RTX_OS |
David Hu | 87b46a8 | 2023-10-21 23:23:42 +0800 | [diff] [blame] | 81 | INTERFACE |
Anton Komlev | 94758d4 | 2023-06-15 16:39:36 +0100 | [diff] [blame] | 82 | Core/Include |
| 83 | RTOS2/Include |
| 84 | RTOS2/RTX/Include |
| 85 | RTOS2/RTX/Config |
| 86 | ) |
| 87 | |
| 88 | target_link_libraries(RTX_OS |
David Hu | 87b46a8 | 2023-10-21 23:23:42 +0800 | [diff] [blame] | 89 | INTERFACE |
Kevin Peng | 7723011 | 2023-10-12 14:14:54 +0800 | [diff] [blame] | 90 | ${CMSIS_5_RTX_LIB} |
Anton Komlev | 94758d4 | 2023-06-15 16:39:36 +0100 | [diff] [blame] | 91 | platform_ns # for cmsis_compiler.h |
Anton Komlev | 94758d4 | 2023-06-15 16:39:36 +0100 | [diff] [blame] | 92 | ) |