blob: b98feb2bf1eec57e616f284a7bcd335e29db0aaa [file] [log] [blame]
alexander31ae9f02022-02-10 16:15:54 +00001#----------------------------------------------------------------------------
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#########################################################
21cmake_minimum_required(VERSION 3.15.6)
22
23set(CMSIS_DEVICE_TARGET cmsis_device)
24
25project(${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)
30if (NOT ${CMAKE_CROSSCOMPILING})
31 message(FATAL_ERROR "No ${CMSIS_DEVICE_TARGET} support for this target.")
32endif()
33
34# 2. Check if CMSIS sources have been defined
35if (NOT DEFINED CMSIS_SRC_PATH)
36 message(FATAL_ERROR "CMSIS_SRC_PATH path should be defined for ${CMSIS_DEVICE_TARGET}.")
37endif()
38
39# 3. Create static library
40add_library(${CMSIS_DEVICE_TARGET} STATIC)
41
42## Include directories - public
43target_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
51target_sources(${CMSIS_DEVICE_TARGET}
52 PRIVATE
Kshitij Sisodiafb93fa72022-02-24 09:51:02 +000053 ${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
57target_compile_definitions(${CMSIS_DEVICE_TARGET} PUBLIC ${ARM_CPU})
58
alexander31ae9f02022-02-10 16:15:54 +000059# Tell linker that reset interrupt handler is our entry point
60target_link_options(
61 ${CMSIS_DEVICE_TARGET}
62 INTERFACE
63 --entry Reset_Handler)
64
Kshitij Sisodiaacc6b852022-03-01 10:23:11 +000065# Check if semihosting configuration is available
66if (COMMAND configure_semihosting)
67 option(USE_SEMIHOSTING "Enable/disable semihosting option" OFF)
68 configure_semihosting(${CMSIS_DEVICE_TARGET} ${USE_SEMIHOSTING})
69endif()
70
alexander31ae9f02022-02-10 16:15:54 +000071# 4 Display status:
72message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR})
73message(STATUS "*******************************************************")
74message(STATUS "Library : " ${CMSIS_DEVICE_TARGET})
75message(STATUS "CMAKE_SYSTEM_PROCESSOR : " ${CMAKE_SYSTEM_PROCESSOR})
76message(STATUS "*******************************************************")