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