blob: ff099c6ebfecc985fbdf20245138e30bae2d2da9 [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
Kristofer Jonsson537c71c2020-05-05 14:17:22 +020027option(DRIVER_PMU_AUTOINIT "Enable PMU boot auto-initialization" OFF)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020028
Kristofer Jonsson537c71c2020-05-05 14:17:22 +020029set(CMSIS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmsis" CACHE PATH "Path to CMSIS.")
Kristofer Jonssonc05c9882020-08-05 11:46:52 +020030
31set(LOG_NAMES emerg alert crit err warning notice info debug)
32set(ETHOSU_LOG_SEVERITY "info" CACHE STRING "Driver log severity level ${LOG_NAMES}")
33set_property(CACHE ETHOSU_LOG_SEVERITY PROPERTY STRINGS ${LOG_NAMES})
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020034
35#
36# Global settings
37#
38
39if(CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m0")
40 add_compile_definitions(CPU_CORTEX_M0)
Bhavik Patel747c8732020-07-27 17:22:44 +020041elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m1")
42 add_compile_definitions(CPU_CORTEX_M1)
43elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m23")
44 add_compile_definitions(CPU_CORTEX_M23)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020045elseif(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)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020049elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m4")
50 add_compile_definitions(CPU_CORTEX_M4)
51elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m55")
52 add_compile_definitions(CPU_CORTEX_M55)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020053elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m7")
54 add_compile_definitions(CPU_CORTEX_M7)
55else()
56 message(FATAL_ERROR "Unsupported compiler ${CMAKE_SYSTEM_PROCESSOR}.")
57endif()
58
Kristofer Jonssonc05c9882020-08-05 11:46:52 +020059# Check that ETHOSU_LOG_SEVERITY has one of the supported levels
60list(FIND LOG_NAMES ${ETHOSU_LOG_SEVERITY} LOG_SEVERITY)
61if (${LOG_SEVERITY} EQUAL -1)
62 message(FATAL_ERROR "Unsupported log level ${ETHOSU_LOG_SEVERITY}")
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020063endif()
64
Jonny Svärdb64628f2020-06-02 15:24:54 +020065# Enable PMU boot auto-initialization
66if(DRIVER_PMU_AUTOINIT)
67 add_compile_definitions(PMU_AUTOINIT)
68endif()
69
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020070# Make include directories available for current- and sub projects
71include_directories(include src)
72include_directories(${CMSIS_PATH}/CMSIS/Core/Include)
73
74#
75# Build libraries
76#
77
78# Build driver library
79add_library(ethosu_core_driver STATIC)
Kristofer Jonsson537c71c2020-05-05 14:17:22 +020080target_include_directories(ethosu_core_driver PUBLIC include)
81target_sources(ethosu_core_driver PRIVATE src/ethosu_driver.c src/ethosu_device.c src/ethosu_pmu.c)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020082
Kristofer Jonssonc05c9882020-08-05 11:46:52 +020083# Set the log level for the target
84target_compile_definitions(ethosu_core_driver PRIVATE ETHOSU_LOG_SEVERITY=${LOG_SEVERITY})
Bhavik Patelf5057812020-07-16 22:36:02 +020085
Bhavik Patel747c8732020-07-27 17:22:44 +020086# Install library and include files
87install(TARGETS ethosu_core_driver LIBRARY DESTINATION "lib")
88install(FILES include/ethosu_device.h include/ethosu_driver.h include/pmu_ethosu.h
89 DESTINATION "include")
90
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020091#
92# Print build status
93#
94
95message(STATUS "*******************************************************")
96message(STATUS "PROJECT_NAME : ${PROJECT_NAME}")
97message(STATUS "CMAKE_SYSTEM_PROCESSOR : ${CMAKE_SYSTEM_PROCESSOR}")
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020098message(STATUS "CMSIS_PATH : ${CMSIS_PATH}")
Kristofer Jonssonc05c9882020-08-05 11:46:52 +020099message(STATUS "ETHOSU_LOG_SEVERITY : ${ETHOSU_LOG_SEVERITY}")
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200100message(STATUS "*******************************************************")