1# 2# Copyright © 2017, 2023 Arm Ltd. All rights reserved. 3# SPDX-License-Identifier: MIT 4# 5if(BUILD_TF_LITE_PARSER) 6 set(armnn_tf_lite_parser_sources) 7 list(APPEND armnn_tf_lite_parser_sources 8 ../../include/armnnTfLiteParser/ITfLiteParser.hpp 9 ../../include/armnnTfLiteParser/Version.hpp 10 TfLiteParser.hpp 11 TfLiteParser.cpp 12 ) 13 14 if(EXECUTE_NETWORK_STATIC) 15 add_library_ex(armnnTfLiteParser OBJECT ${armnn_tf_lite_parser_sources}) 16 else() 17 add_library_ex(armnnTfLiteParser SHARED ${armnn_tf_lite_parser_sources}) 18 endif() 19 20 include_directories(SYSTEM "${FLATBUFFERS_INCLUDE_PATH}") 21 set_target_properties(armnnTfLiteParser PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) 22 target_include_directories(armnnTfLiteParser PRIVATE ../armnn) 23 target_include_directories(armnnTfLiteParser PRIVATE ../armnnUtils) 24 target_include_directories(armnnTfLiteParser SYSTEM PRIVATE "${TF_LITE_SCHEMA_INCLUDE_PATH}") 25 26 27 # using the armnn/delegate/cmake/Modules/FindTfLiteSrc.cmake to find the TfLite sources 28 # so that we can use the tensorflow/lite/version.h to determine which version of 29 # tensorflow lite we are compiling against 30 find_package(TfLiteSrc REQUIRED MODULE) 31 32 # Various tflite header files are not warning clean 33 # We can't change compilation flags on header files directly, so we need to add them to an interface library first 34 add_library(tflite_version_headers INTERFACE) 35 target_include_directories(tflite_version_headers INTERFACE $<BUILD_INTERFACE:${TfLite_INCLUDE_DIR}> 36 $<INSTALL_INTERFACE:include/tflite_version_headers>) 37 38 if(COMPILER_IS_GNU_LIKE) 39 target_compile_options(tflite_version_headers INTERFACE -Wno-conversion 40 -Wno-sign-conversion 41 -Wno-unused-parameter 42 -Wno-unused-function) 43 endif() 44 45 46 # If user has explicitly specified flatbuffers lib then use that, 47 # otherwise search for it based on FLATBUFFERS_BUILD_DIR 48 if (FLATBUFFERS_LIBRARY) 49 target_link_libraries(armnnTfLiteParser 50 armnn 51 tflite_version_headers 52 ${FLATBUFFERS_LIBRARY}) 53 else() 54 # Use PATH_SUFFIXES to help find separate libs for debug/release on Windows builds 55 find_library(FLATBUFFERS_LIBRARY_DEBUG NAMES flatbuffers 56 HINTS ${FLATBUFFERS_BUILD_DIR} 57 PATH_SUFFIXES "Debug") 58 find_library(FLATBUFFERS_LIBRARY_RELEASE NAMES flatbuffers 59 HINTS ${FLATBUFFERS_BUILD_DIR} 60 PATH_SUFFIXES "Release") 61 target_link_libraries(armnnTfLiteParser 62 armnn 63 tflite_version_headers 64 debug ${FLATBUFFERS_LIBRARY_DEBUG} 65 optimized ${FLATBUFFERS_LIBRARY_RELEASE}) 66 endif() 67 68 set_target_properties(armnnTfLiteParser PROPERTIES VERSION ${TFLITE_PARSER_LIB_VERSION} SOVERSION ${TFLITE_PARSER_LIB_SOVERSION} ) 69 70 install(TARGETS armnnTfLiteParser 71 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 72 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) 73endif() 74