blob: d53662db3abf2de32d59bbfe45856eb25a723298 [file] [log] [blame]
Kristofer Jonsson49bdee82020-04-06 13:21:21 +02001#
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
19cmake_minimum_required(VERSION 3.15.6)
20
21project(ethosu_core_driver VERSION 0.0.1)
22
23#
24# Build options
25#
26
27option(DRIVER_BUILD_PMU "Driver supports NPU-PMU" ON)
28option(LOG_SUPPORT "Enable logging." ON)
29
30set(CMSIS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../library/cmsis" CACHE PATH "Path to CMSIS.")
31set(TIMING_ADAPTER_PATH "${CMAKE_CURRENT_SOURCE_DIR}/timing-adapter" CACHE STRING "Path to timing adapter.")
32
33if(EXISTS "${TIMING_ADAPTER_PATH}")
34 option(DRIVER_BUILD_TIMING_ADAPTER "Enable timing-adapter" ON)
35else()
36 option(DRIVER_BUILD_TIMING_ADAPTER "Enable timing-adapter" OFF)
37endif()
38
39#
40# Global settings
41#
42
43if(CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m0")
44 add_compile_definitions(CPU_CORTEX_M0)
45elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m3")
46 add_compile_definitions(CPU_CORTEX_M3)
47elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m33")
48 add_compile_definitions(CPU_CORTEX_M33)
49 add_compile_definitions(__DSP_PRESENT=1)
50elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m4")
51 add_compile_definitions(CPU_CORTEX_M4)
52elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m55")
53 add_compile_definitions(CPU_CORTEX_M55)
54 add_compile_definitions(__DSP_PRESENT=1)
55 add_compile_definitions(__FPU_PRESENT=1)
56elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m7")
57 add_compile_definitions(CPU_CORTEX_M7)
58else()
59 message(FATAL_ERROR "Unsupported compiler ${CMAKE_SYSTEM_PROCESSOR}.")
60endif()
61
62# Enable logging support
63if (LOG_SUPPORT)
64 add_compile_definitions(LOG_ENABLED)
65endif()
66
67# Make include directories available for current- and sub projects
68include_directories(include src)
69include_directories(${CMSIS_PATH}/CMSIS/Core/Include)
70
71#
72# Build libraries
73#
74
75# Build driver library
76add_library(ethosu_core_driver STATIC)
77target_include_directories(ethosu_core_driver
78 PUBLIC include)
79target_sources(ethosu_core_driver PRIVATE src/ethosu_driver.c src/ethosu_device.c)
80
81# Build timing adapter
82if (DRIVER_BUILD_TIMING_ADAPTER)
83 add_subdirectory(timing-adapter)
84 target_link_libraries(ethosu_core_driver PUBLIC timing-adapter)
85endif()
86
87# Build PMU
88if (DRIVER_BUILD_PMU)
89 add_subdirectory(ethosu_pmu)
90 target_link_libraries(ethosu_core_driver PUBLIC ethosu_core_driver_pmu)
91endif()
92
93#
94# Print build status
95#
96
97message(STATUS "*******************************************************")
98message(STATUS "PROJECT_NAME : ${PROJECT_NAME}")
99message(STATUS "CMAKE_SYSTEM_PROCESSOR : ${CMAKE_SYSTEM_PROCESSOR}")
100message(STATUS "DRIVER_BUILD_PMU : ${DRIVER_BUILD_PMU}")
101message(STATUS "DRIVER_BUILD_TIMING_ADAPTER : ${DRIVER_BUILD_TIMING_ADAPTER}")
102message(STATUS "LOG_SUPPORT : ${LOG_SUPPORT}")
103message(STATUS "CMSIS_PATH : ${CMSIS_PATH}")
104message(STATUS "TIMING_ADAPTER_PATH : ${TIMING_ADAPTER_PATH}")
105message(STATUS "*******************************************************")