blob: d304a84178ddf1f274cd665053b7429acbc07fa5 [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
19include(ProcessorCount)
20ProcessorCount(J)
21
22set(TFLU_CC "${CMAKE_C_COMPILER} --target=${CMAKE_C_COMPILER_TARGET} -mcpu=${CMAKE_SYSTEM_PROCESSOR}${CPU_FEATURES}")
23set(TFLU_CXX "${CMAKE_CXX_COMPILER} --target=${CMAKE_C_COMPILER_TARGET} -mcpu=${CMAKE_SYSTEM_PROCESSOR}${CPU_FEATURES}")
24set(TFLU_AR ${CMAKE_AR})
25
26set(TFLU_PATH "${TENSORFLOW_PATH}/tensorflow/lite/micro")
27set(TFLU_GENDIR ${CMAKE_CURRENT_BINARY_DIR}/tensorflow/)
28set(TFLU_TARGET "lib")
29set(TFLU_TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR}${CPU_FEATURES})
30set(TFLU_ETHOSU_LIBS $<TARGET_FILE:ethosu_core_driver>)
31
32if(CORE_SOFTWARE_BACKEND STREQUAL NPU)
Henrik Hoglind43fd4de2020-05-08 14:18:26 +020033 list(APPEND TFLU_TAGS "ethos-u")
Kristofer Jonsson18239302020-04-17 08:45:38 +020034endif()
35
36string(JOIN TFLU_TAGS " " TFLU_TAGS)
37
38# Command and target
39add_custom_target(tflu_gen ALL
Henrik Hoglind43fd4de2020-05-08 14:18:26 +020040 COMMAND make -j${J} -f ${TFLU_PATH}/tools/make/Makefile microlite TARGET=${TFLU_TARGET} TARGET_ARCH=${TFLU_TARGET_ARCH} CC_TOOL=${TFLU_CC} CXX_TOOL=${TFLU_CXX} AR_TOOL=${TFLU_AR} GENDIR=${TFLU_GENDIR} CMSIS_PATH=${CMSIS_PATH} ETHOSU_DRIVER_PATH=${CORE_DRIVER_PATH} ETHOSU_DRIVER_LIBS=${TFLU_ETHOSU_LIBS} TAGS="${TFLU_TAGS}"
Kristofer Jonsson18239302020-04-17 08:45:38 +020041 WORKING_DIRECTORY ${TENSORFLOW_PATH})
42
43# Create library and link library to custom target
44add_library(tflu STATIC IMPORTED)
45set_property(TARGET tflu PROPERTY IMPORTED_LOCATION ${TFLU_GENDIR}/lib/libtensorflow-microlite.a)
46add_dependencies(tflu tflu_gen)
47target_include_directories(tflu INTERFACE ${TENSORFLOW_PATH})