blob: 5806692e9190b5e64937fa791b70bf16c49f8926 [file] [log] [blame]
Kristofer Jonsson18239302020-04-17 08:45:38 +02001#
2# Copyright (c) 2019-2020 Arm Limited. All rights reserved.
3#
4# SPDX-License-Identifier: Apache-2.0
5#
6# Licensed under the Apache License, Version 2.0 (the License); you may
7# not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an AS IS BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18
19# Extract the CPU number from the system processor
20string(REGEX MATCH "^cortex-m([0-9]+)$" CPU_NUMBER ${CMAKE_SYSTEM_PROCESSOR})
21if(NOT CPU_NUMBER)
22 message(FATAL_ERROR "System processor '${CMAKE_SYSTEM_PROCESSOR}' not supported. Should be cortex-m<nr>.")
23endif()
24string(REGEX REPLACE "^cortex-m([0-9]+)$" "\\1" CPU_NUMBER ${CMAKE_SYSTEM_PROCESSOR})
25
26set(ARM_CPU "ARMCM${CPU_NUMBER}")
27
28# CMSIS core library
29add_library(cmsis_core INTERFACE)
30target_include_directories(cmsis_core INTERFACE ${CMSIS_PATH}/CMSIS/Core/Include)
31
32# CMSIS device library
33add_library(cmsis_device OBJECT)
34target_sources(cmsis_device PRIVATE
35 ${CMSIS_PATH}/Device/ARM/${ARM_CPU}/Source/startup_${ARM_CPU}.c
36 ${CMSIS_PATH}/Device/ARM/${ARM_CPU}/Source/system_${ARM_CPU}.c)
37target_compile_definitions(cmsis_device PRIVATE ${ARM_CPU})
Per Åstrand88e5c5b2020-05-06 08:59:51 +020038target_compile_options(cmsis_device INTERFACE -include${ARM_CPU}.h)
39target_include_directories(cmsis_device PUBLIC ${CMSIS_PATH}/Device/ARM/${ARM_CPU}/Include)
40target_link_libraries(cmsis_device PUBLIC cmsis_core)