blob: 9d20c144b29fcc28572b391ef4a8b646e793426f [file] [log] [blame]
Kristofer Jonsson18239302020-04-17 08:45:38 +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(core_software VERSION 0.0.1)
22
23#
24# Define build options
25#
26
27# Setup paths
28set(CMSIS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmsis" CACHE PATH "Path to CMSIS.")
29set(CORE_DRIVER_PATH "${CMAKE_CURRENT_SOURCE_DIR}/core_driver" CACHE PATH "Path to core driver.")
Kristofer Jonsson641c0912020-08-31 11:34:14 +020030set(LINUX_DRIVER_STACK_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../linux_driver_stack" CACHE PATH "Path to Linux driver stack for Arm Ethos-U.")
Kristofer Jonsson18239302020-04-17 08:45:38 +020031set(TENSORFLOW_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tensorflow" CACHE PATH "Path to Tensorflow.")
32
Per Åstrand94ca3552020-06-30 10:33:58 +020033# Select accelerator for tensorflow
Kristofer Jonsson641c0912020-08-31 11:34:14 +020034set(CORE_SOFTWARE_ACCELERATOR "NPU" CACHE STRING "Set NPU backend for Tensorflow Lite for microcontrollers")
Per Åstrand94ca3552020-06-30 10:33:58 +020035set_property(CACHE CORE_SOFTWARE_ACCELERATOR PROPERTY STRINGS CPU CMSIS-NN NPU)
Kristofer Jonsson18239302020-04-17 08:45:38 +020036
37# Define build options
38set(CORE_SOFTWARE_RTOS "None" CACHE STRING "Select RTOS to include. (None, MbedOS, FreeRTOS, Zephyr)")
Bhavik Patel68c1f1b2020-07-29 12:28:18 +020039string(TOLOWER ${CORE_SOFTWARE_RTOS} CORE_SOFTWARE_RTOS_LOWER)
Kristofer Jonsson18239302020-04-17 08:45:38 +020040
41#
42# Build
43#
Per Åstrand94ca3552020-06-30 10:33:58 +020044add_library(ethosu_core INTERFACE)
Kristofer Jonsson18239302020-04-17 08:45:38 +020045
46# Build CMSIS
47include(cmsis.cmake)
Per Åstrand19a22ae2020-11-27 19:47:58 +010048target_link_libraries(ethosu_core INTERFACE cmsis_core cmsis_device)
Kristofer Jonsson18239302020-04-17 08:45:38 +020049
50# Build core driver
Per Åstrand94ca3552020-06-30 10:33:58 +020051if (CORE_SOFTWARE_ACCELERATOR STREQUAL "NPU")
52 set(ETHOSU_PMU_INTERACTIVE OFF)
53 add_subdirectory(${CORE_DRIVER_PATH} core_driver)
54 target_link_libraries(ethosu_core INTERFACE ethosu_core_driver)
55endif()
Kristofer Jonsson18239302020-04-17 08:45:38 +020056
57# Build Tensorflow library
58include(tensorflow.cmake)
59
Bhavik Patel68c1f1b2020-07-29 12:28:18 +020060# Build RTOS
61add_subdirectory(rtos)
Bhavik Patel68c1f1b2020-07-29 12:28:18 +020062
Kristofer Jonsson641c0912020-08-31 11:34:14 +020063# Build applications
64add_subdirectory(applications)
65
Jonny Svärd44398c82020-10-06 14:18:28 +020066# Build drivers
67add_subdirectory(drivers)
68
Kristofer Jonsson18239302020-04-17 08:45:38 +020069# Merge libraries into static library
Per Åstrandd9afc082020-10-06 13:25:08 +020070target_link_libraries(ethosu_core INTERFACE tflu cmsis_core ethosu_applications ethosu_drivers)