Change CMSIS Device file paths for CMSIS 6
This patch adds support for building with CMSIS_6 in addition to
CMSIS_5. A cmake flag(CMSIS_VER) with default value of 5 has been added.
This can be overridden in the cmake command line. CMSIS Device
component is no longer part of CMSIS_6 and is part of Cortex_DFP repo.
This patch also has the file path changes required to include CMSIS
Device from Cortex_DFP.
Change-Id: I148ab6b384d725ca83e75ac08e15c58809f25ac1
Signed-off-by: Rajasekaran Kalidoss <rajasekaran.kalidoss@arm.com>
diff --git a/cmsis.cmake b/cmsis.cmake
index f8a916f..6e1cc4f 100644
--- a/cmsis.cmake
+++ b/cmsis.cmake
@@ -1,6 +1,5 @@
#
-# Copyright (c) 2019-2022 Arm Limited.
-#
+# Copyright (c) 2019-2022, 2024 Arm Limited.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the License); you may
@@ -41,27 +40,37 @@
# CMSIS device
add_library(cmsis_device INTERFACE)
-target_include_directories(cmsis_device INTERFACE ${CMSIS_PATH}/Device/ARM/${ARM_CPU}/Include)
+
+if (${CMSIS_VER} EQUAL 5)
+ cmake_path(SET CMSIS_DEVICE_PATH "${CMSIS_PATH}/Device/ARM")
+ cmake_path(SET CMSIS_DEVICE_CPU_FEATURE "${ARM_CPU}${ARM_FEATURES}")
+else()
+ cmake_path(APPEND CMSIS_PATH "Cortex_DFP/Device/" OUTPUT_VARIABLE CMSIS_DEVICE_PATH)
+ cmake_path(SET CMSIS_DEVICE_CPU_FEATURE "${ARM_CPU}")
+endif()
+
+target_include_directories(cmsis_device INTERFACE ${CMSIS_DEVICE_PATH}/${ARM_CPU}/Include)
target_compile_options(cmsis_device INTERFACE
- "$<$<COMPILE_LANGUAGE:C>:-include${ARM_CPU}${ARM_FEATURES}.h>"
- "$<$<COMPILE_LANGUAGE:CXX>:-include${ARM_CPU}${ARM_FEATURES}.h>")
+ "$<$<COMPILE_LANGUAGE:C>:-include${CMSIS_DEVICE_CPU_FEATURE}.h>"
+ "$<$<COMPILE_LANGUAGE:CXX>:-include${CMSIS_DEVICE_CPU_FEATURE}.h>")
+
target_link_libraries(cmsis_device INTERFACE cmsis_core)
# CMSIS startup
add_library(cmsis_startup INTERFACE)
target_sources(cmsis_startup INTERFACE
- ${CMSIS_PATH}/Device/ARM/${ARM_CPU}/Source/startup_${ARM_CPU}.c)
+ ${CMSIS_DEVICE_PATH}/${ARM_CPU}/Source/startup_${ARM_CPU}.c)
-set_source_files_properties(${CMSIS_PATH}/Device/ARM/${ARM_CPU}/Source/startup_${ARM_CPU}.c
+set_source_files_properties(${CMSIS_DEVICE_PATH}/${ARM_CPU}/Source/startup_${ARM_CPU}.c
PROPERTIES COMPILE_FLAGS -Wno-redundant-decls)
-target_compile_definitions(cmsis_startup INTERFACE ${ARM_CPU}${ARM_FEATURES})
+target_compile_definitions(cmsis_startup INTERFACE ${CMSIS_DEVICE_CPU_FEATURE})
target_link_libraries(cmsis_startup INTERFACE cmsis_device)
# CMSIS system
add_library(cmsis_system INTERFACE)
target_sources(cmsis_system INTERFACE
- ${CMSIS_PATH}/Device/ARM/${ARM_CPU}/Source/system_${ARM_CPU}.c)
-target_compile_definitions(cmsis_system INTERFACE ${ARM_CPU}${ARM_FEATURES})
+ ${CMSIS_DEVICE_PATH}/${ARM_CPU}/Source/system_${ARM_CPU}.c)
+target_compile_definitions(cmsis_system INTERFACE ${CMSIS_DEVICE_CPU_FEATURE})
target_link_libraries(cmsis_system INTERFACE cmsis_startup)