blob: cb0243bc2fe9bcbfed704c1c30ddb95699badf0b [file] [log] [blame]
alexander3c798932021-03-26 21:42:19 +00001#----------------------------------------------------------------------------
2# Copyright (c) 2021 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# CMSIS-DSP library CMake helper script.
19
20# 1. We should be cross-compiling (non-native target)
21if (TARGET_PLATFORM STREQUAL native)
22 message(FATAL_ERROR "No CMSIS-DSP support for native target.")
23endif()
24
25# 2. Check if CMSIS sources have been defined
26if (NOT DEFINED CMSIS_SRC_PATH)
27 message(FATAL_ERROR "CMSIS path should be defined for CMSIS-DSP library to be built")
28endif()
29
30# 3. Form a list of all the sources we need in CSMS-DSP library
31set(CMSIS_DSP_PATH_SUFFIX "CMSIS/DSP")
32set(CMSIS_CORE_PATH_SUFFIX "CMSIS/Core")
33set(CMSIS_DSP_SRC_DIR "${CMSIS_SRC_PATH}/${CMSIS_DSP_PATH_SUFFIX}/Source")
34set(CMSIS_DSP_INC_DIR "${CMSIS_SRC_PATH}/${CMSIS_DSP_PATH_SUFFIX}/Include")
35set(CMSIS_DSP_PRI_INC_DIR "${CMSIS_SRC_PATH}/${CMSIS_DSP_PATH_SUFFIX}/PrivateInclude")
36set(CMSIS_CORE_INC_DIR "${CMSIS_SRC_PATH}/${CMSIS_CORE_PATH_SUFFIX}/Include")
37
38file(GLOB_RECURSE
39 CMSIS_DSP_SRC
40 "${CMSIS_DSP_SRC_DIR}/arm_*.c")
41
42# 4. Create static library
43set(CMSIS_DSP_TARGET cmsis-dsp)
44
45add_library(${CMSIS_DSP_TARGET} STATIC ${CMSIS_DSP_SRC})
46
47target_include_directories(${CMSIS_DSP_TARGET} PUBLIC
48 ${CMSIS_DSP_INC_DIR}
49 ${CMSIS_CORE_INC_DIR})
50target_include_directories(${CMSIS_DSP_TARGET} PRIVATE
51 ${CMSIS_DSP_PRI_INC_DIR})
52
53# 5. Add any custom/conditional flags for compilation or linkage
54if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL cortex-m55)
55 target_compile_definitions(${CMSIS_DSP_TARGET} PUBLIC
56 ARM_MATH_MVEI
57 ARM_MATH_DSP
58 ARM_MATH_LOOPUNROLL)
59elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL cortex-m33)
60 # Placeholder, if building with Cortex-M33
61endif()
62
63
64# 6. Provide the library path for the top level CMake to use:
65set(CMSIS_DSP_LIB "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/lib${CMSIS_DSP_TARGET}.a")
66message(STATUS "CMSIS_DSP_LIB set to be generated here: ${CMSIS_DSP_LIB}")
67
68message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR})
69message(STATUS "*******************************************************")
70message(STATUS "Library : " ${CMSIS_DSP_TARGET})
71message(STATUS "Build type : " ${CMAKE_BUILD_TYPE})
72message(STATUS "TARGET_PLATFORM : " ${TARGET_PLATFORM})
73message(STATUS "CMAKE_SYSTEM_PROCESSOR : " ${CMAKE_SYSTEM_PROCESSOR})
74message(STATUS "*******************************************************")