alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 1 | #---------------------------------------------------------------------------- |
| 2 | # Copyright (c) 2022 Arm Limited. All rights reserved. |
| 3 | # SPDX-License-Identifier: Apache-2.0 |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | #---------------------------------------------------------------------------- |
| 17 | |
| 18 | ######################################################### |
| 19 | # Generic CMSIS Start up library for Cortex-M targets # |
| 20 | ######################################################### |
| 21 | cmake_minimum_required(VERSION 3.15.6) |
| 22 | |
| 23 | set(CMSIS_DEVICE_TARGET cmsis_device) |
| 24 | |
| 25 | project(${CMSIS_DEVICE_TARGET} |
| 26 | DESCRIPTION "Generic CMSIS start up file for Cortex-M targets" |
| 27 | LANGUAGES C CXX ASM) |
| 28 | |
| 29 | # 1. We should be cross-compiling (non-native target) |
| 30 | if (NOT ${CMAKE_CROSSCOMPILING}) |
| 31 | message(FATAL_ERROR "No ${CMSIS_DEVICE_TARGET} support for this target.") |
| 32 | endif() |
| 33 | |
| 34 | # 2. Check if CMSIS sources have been defined |
| 35 | if (NOT DEFINED CMSIS_SRC_PATH) |
| 36 | message(FATAL_ERROR "CMSIS_SRC_PATH path should be defined for ${CMSIS_DEVICE_TARGET}.") |
| 37 | endif() |
| 38 | |
| 39 | # 3. Create static library |
| 40 | add_library(${CMSIS_DEVICE_TARGET} STATIC) |
| 41 | |
| 42 | ## Include directories - public |
| 43 | target_include_directories(${CMSIS_DEVICE_TARGET} |
| 44 | PUBLIC |
| 45 | include |
| 46 | ${CMSIS_SRC_PATH}/CMSIS/Core/Include |
| 47 | ${CMSIS_SRC_PATH}/Device/ARM/${ARM_CPU}/Include |
| 48 | ${CMSIS_SRC_PATH}/Device/ARM/${ARM_CPU}/Include/Template) |
| 49 | |
| 50 | ## Sources |
| 51 | target_sources(${CMSIS_DEVICE_TARGET} |
| 52 | PRIVATE |
Kshitij Sisodia | fb93fa7 | 2022-02-24 09:51:02 +0000 | [diff] [blame] | 53 | ${CMSIS_SRC_PATH}/Device/ARM/${ARM_CPU}/Source/system_${ARM_CPU}.c |
| 54 | ${CMSIS_SRC_PATH}/Device/ARM/${ARM_CPU}/Source/startup_${ARM_CPU}.c) |
| 55 | |
| 56 | # Device definition needs to be set, is checked in source files to include correct header |
| 57 | target_compile_definitions(${CMSIS_DEVICE_TARGET} PUBLIC ${ARM_CPU}) |
| 58 | |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 59 | # Tell linker that reset interrupt handler is our entry point |
| 60 | target_link_options( |
| 61 | ${CMSIS_DEVICE_TARGET} |
| 62 | INTERFACE |
| 63 | --entry Reset_Handler) |
| 64 | |
Kshitij Sisodia | acc6b85 | 2022-03-01 10:23:11 +0000 | [diff] [blame] | 65 | # Check if semihosting configuration is available |
| 66 | if (COMMAND configure_semihosting) |
Kshitij Sisodia | 6a2ac46 | 2022-03-01 17:36:06 +0000 | [diff] [blame^] | 67 | configure_semihosting(${CMSIS_DEVICE_TARGET} OFF) |
Kshitij Sisodia | acc6b85 | 2022-03-01 10:23:11 +0000 | [diff] [blame] | 68 | endif() |
| 69 | |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 70 | # 4 Display status: |
| 71 | message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR}) |
| 72 | message(STATUS "*******************************************************") |
| 73 | message(STATUS "Library : " ${CMSIS_DEVICE_TARGET}) |
| 74 | message(STATUS "CMAKE_SYSTEM_PROCESSOR : " ${CMAKE_SYSTEM_PROCESSOR}) |
| 75 | message(STATUS "*******************************************************") |