aboutsummaryrefslogtreecommitdiff
path: root/cmsis.cmake
diff options
context:
space:
mode:
authorKristofer Jonsson <kristofer.jonsson@arm.com>2020-04-17 08:45:38 +0200
committerKristofer Jonsson <kristofer.jonsson@arm.com>2020-04-23 13:33:34 +0200
commit1823930ea1baaaf5975dc0b03eddb45917509410 (patch)
treed69954e36a538c505bb057b41d340b6adc36f25e /cmsis.cmake
parente5dd4b887537f3376db97b3ca3c2610a69e39911 (diff)
downloadethos-u-core-software-1823930ea1baaaf5975dc0b03eddb45917509410.tar.gz
MLBEDSW-1729 Adding core software build files
Change-Id: Ia4d90f2e8875f33b70aec2dd53e2128192a4e10a
Diffstat (limited to 'cmsis.cmake')
-rw-r--r--cmsis.cmake39
1 files changed, 39 insertions, 0 deletions
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<nr>.")
+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)