Kristofer Jonsson | 1823930 | 2020-04-17 08:45:38 +0200 | [diff] [blame] | 1 | # |
| 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 |
| 20 | string(REGEX MATCH "^cortex-m([0-9]+)$" CPU_NUMBER ${CMAKE_SYSTEM_PROCESSOR}) |
| 21 | if(NOT CPU_NUMBER) |
| 22 | message(FATAL_ERROR "System processor '${CMAKE_SYSTEM_PROCESSOR}' not supported. Should be cortex-m<nr>.") |
| 23 | endif() |
| 24 | string(REGEX REPLACE "^cortex-m([0-9]+)$" "\\1" CPU_NUMBER ${CMAKE_SYSTEM_PROCESSOR}) |
| 25 | |
| 26 | set(ARM_CPU "ARMCM${CPU_NUMBER}") |
| 27 | |
| 28 | # CMSIS core library |
| 29 | add_library(cmsis_core INTERFACE) |
| 30 | target_include_directories(cmsis_core INTERFACE ${CMSIS_PATH}/CMSIS/Core/Include) |
| 31 | |
| 32 | # CMSIS device library |
| 33 | add_library(cmsis_device OBJECT) |
| 34 | target_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) |
| 37 | target_compile_definitions(cmsis_device PRIVATE ${ARM_CPU}) |
Per Åstrand | 88e5c5b | 2020-05-06 08:59:51 +0200 | [diff] [blame] | 38 | target_compile_options(cmsis_device INTERFACE -include${ARM_CPU}.h) |
| 39 | target_include_directories(cmsis_device PUBLIC ${CMSIS_PATH}/Device/ARM/${ARM_CPU}/Include) |
| 40 | target_link_libraries(cmsis_device PUBLIC cmsis_core) |