From 1823930ea1baaaf5975dc0b03eddb45917509410 Mon Sep 17 00:00:00 2001 From: Kristofer Jonsson Date: Fri, 17 Apr 2020 08:45:38 +0200 Subject: MLBEDSW-1729 Adding core software build files Change-Id: Ia4d90f2e8875f33b70aec2dd53e2128192a4e10a --- cmsis.cmake | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 cmsis.cmake (limited to 'cmsis.cmake') diff --git a/cmsis.cmake b/cmsis.cmake new file mode 100644 index 0000000..27b1090 --- /dev/null +++ b/cmsis.cmake @@ -0,0 +1,39 @@ +# +# Copyright (c) 2019-2020 Arm Limited. All rights reserved. +# +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the License); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an AS IS BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Extract the CPU number from the system processor +string(REGEX MATCH "^cortex-m([0-9]+)$" CPU_NUMBER ${CMAKE_SYSTEM_PROCESSOR}) +if(NOT CPU_NUMBER) + message(FATAL_ERROR "System processor '${CMAKE_SYSTEM_PROCESSOR}' not supported. Should be cortex-m.") +endif() +string(REGEX REPLACE "^cortex-m([0-9]+)$" "\\1" CPU_NUMBER ${CMAKE_SYSTEM_PROCESSOR}) + +set(ARM_CPU "ARMCM${CPU_NUMBER}") + +# CMSIS core library +add_library(cmsis_core INTERFACE) +target_include_directories(cmsis_core INTERFACE ${CMSIS_PATH}/CMSIS/Core/Include) + +# CMSIS device library +add_library(cmsis_device OBJECT) +target_sources(cmsis_device PRIVATE + ${CMSIS_PATH}/Device/ARM/${ARM_CPU}/Source/startup_${ARM_CPU}.c + ${CMSIS_PATH}/Device/ARM/${ARM_CPU}/Source/system_${ARM_CPU}.c) +target_compile_definitions(cmsis_device PRIVATE ${ARM_CPU}) +target_include_directories(cmsis_device PRIVATE ${CMSIS_PATH}/Device/ARM/${ARM_CPU}/Include) +target_link_libraries(cmsis_device PRIVATE cmsis_core) -- cgit v1.2.1