blob: e8d46ae39bbb115fb9f898754526a88be0bd44dd [file] [log] [blame]
Kristofer Jonsson18239302020-04-17 08:45:38 +02001#
Kristofer Jonsson1efcc3f2021-02-16 17:40:25 +01002# Copyright (c) 2019-2021 Arm Limited. All rights reserved.
Kristofer Jonsson18239302020-04-17 08:45:38 +02003#
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
Jonas Ohlsson7f3c1c92021-05-05 10:48:03 +020019# Note: On Windows systems CMake 3.20.0 might cause issues with errouneous dependency make files.
20# Issues solved with CMake 3.20.1.
Kristofer Jonsson18239302020-04-17 08:45:38 +020021cmake_minimum_required(VERSION 3.15.6)
22
23project(core_software VERSION 0.0.1)
24
25#
26# Define build options
27#
28
29# Setup paths
30set(CMSIS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmsis" CACHE PATH "Path to CMSIS.")
31set(CORE_DRIVER_PATH "${CMAKE_CURRENT_SOURCE_DIR}/core_driver" CACHE PATH "Path to core driver.")
Kristofer Jonsson641c0912020-08-31 11:34:14 +020032set(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 +020033set(TENSORFLOW_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tensorflow" CACHE PATH "Path to Tensorflow.")
Jonas Ohlsson7f3c1c92021-05-05 10:48:03 +020034set(TFLU_PREBUILT_LIBRARY_PATH "" CACHE PATH "Path to a prebuilt TensorFlow Lite for Microcontrollers library.")
Kristofer Jonsson18239302020-04-17 08:45:38 +020035
Per Åstrand94ca3552020-06-30 10:33:58 +020036# Select accelerator for tensorflow
Kristofer Jonsson641c0912020-08-31 11:34:14 +020037set(CORE_SOFTWARE_ACCELERATOR "NPU" CACHE STRING "Set NPU backend for Tensorflow Lite for microcontrollers")
Per Åstrand94ca3552020-06-30 10:33:58 +020038set_property(CACHE CORE_SOFTWARE_ACCELERATOR PROPERTY STRINGS CPU CMSIS-NN NPU)
Kristofer Jonsson18239302020-04-17 08:45:38 +020039
40# Define build options
41set(CORE_SOFTWARE_RTOS "None" CACHE STRING "Select RTOS to include. (None, MbedOS, FreeRTOS, Zephyr)")
Bhavik Patel68c1f1b2020-07-29 12:28:18 +020042string(TOLOWER ${CORE_SOFTWARE_RTOS} CORE_SOFTWARE_RTOS_LOWER)
Kristofer Jonsson18239302020-04-17 08:45:38 +020043
44#
45# Build
46#
Per Åstrand94ca3552020-06-30 10:33:58 +020047add_library(ethosu_core INTERFACE)
Kristofer Jonsson18239302020-04-17 08:45:38 +020048
49# Build CMSIS
50include(cmsis.cmake)
Per Åstrand19a22ae2020-11-27 19:47:58 +010051target_link_libraries(ethosu_core INTERFACE cmsis_core cmsis_device)
Kristofer Jonsson18239302020-04-17 08:45:38 +020052
53# Build core driver
Per Åstrand94ca3552020-06-30 10:33:58 +020054if (CORE_SOFTWARE_ACCELERATOR STREQUAL "NPU")
55 set(ETHOSU_PMU_INTERACTIVE OFF)
56 add_subdirectory(${CORE_DRIVER_PATH} core_driver)
57 target_link_libraries(ethosu_core INTERFACE ethosu_core_driver)
58endif()
Kristofer Jonsson18239302020-04-17 08:45:38 +020059
60# Build Tensorflow library
61include(tensorflow.cmake)
62
Bhavik Patel68c1f1b2020-07-29 12:28:18 +020063# Build RTOS
64add_subdirectory(rtos)
Bhavik Patel68c1f1b2020-07-29 12:28:18 +020065
Kristofer Jonsson641c0912020-08-31 11:34:14 +020066# Build applications
67add_subdirectory(applications)
68
Jonny Svärd44398c82020-10-06 14:18:28 +020069# Build drivers
70add_subdirectory(drivers)
71
Kristofer Jonsson18239302020-04-17 08:45:38 +020072# Merge libraries into static library
Kristofer Jonsson1efcc3f2021-02-16 17:40:25 +010073target_link_libraries(ethosu_core INTERFACE tflu ethosu_applications ethosu_drivers)