blob: f9653b6752e66e0c2904b280bfca27424d6b1030 [file] [log] [blame]
Ruomei Yandb7c3912019-03-08 17:50:25 +00001#
2# Copyright © 2017 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
Matthew Sloyanac001ee2021-02-03 10:43:04 +00009 ../../include/armnnTfLiteParser/Version.hpp
Ruomei Yandb7c3912019-03-08 17:50:25 +000010 TfLiteParser.hpp
11 TfLiteParser.cpp
12 )
13
14 add_library_ex(armnnTfLiteParser SHARED ${armnn_tf_lite_parser_sources})
15
16 include_directories(SYSTEM "${FLATBUFFERS_INCLUDE_PATH}")
17 set_target_properties(armnnTfLiteParser PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
18 target_include_directories(armnnTfLiteParser PRIVATE ../armnn)
19 target_include_directories(armnnTfLiteParser PRIVATE ../armnnUtils)
20 target_include_directories(armnnTfLiteParser SYSTEM PRIVATE "${TF_LITE_SCHEMA_INCLUDE_PATH}")
21
Jim Flynnfca233e2021-09-23 12:16:53 +010022
23 # using the armnn/delegate/cmake/Modules/FindTfLiteSrc.cmake to find the TfLite sources
24 # so that we can use the tensorflow/lite/version.h to determine which version of
25 # tensorflow lite we are compiling against
26 find_package(TfLiteSrc REQUIRED MODULE)
27
28 # Various tflite header files are not warning clean
29 # We can't change compilation flags on header files directly, so we need to add them to an interface library first
30 add_library(tflite_version_headers INTERFACE)
31 target_include_directories(tflite_version_headers INTERFACE $<BUILD_INTERFACE:${TfLite_INCLUDE_DIR}>
32 $<INSTALL_INTERFACE:include/tflite_version_headers>)
33
Rob Hughesd561ac12021-09-29 15:03:46 +010034 if(COMPILER_IS_GNU_LIKE)
35 target_compile_options(tflite_version_headers INTERFACE -Wno-conversion
36 -Wno-sign-conversion
37 -Wno-unused-parameter
38 -Wno-unused-function)
39 endif()
40
Jim Flynnfca233e2021-09-23 12:16:53 +010041
Rob Hughesc3da2682020-01-07 13:26:42 +000042 # If user has explicitly specified flatbuffers lib then use that,
43 # otherwise search for it based on FLATBUFFERS_BUILD_DIR
44 if (FLATBUFFERS_LIBRARY)
Jim Flynnfca233e2021-09-23 12:16:53 +010045 target_link_libraries(armnnTfLiteParser
46 armnn
47 tflite_version_headers
48 ${FLATBUFFERS_LIBRARY})
Rob Hughesc3da2682020-01-07 13:26:42 +000049 else()
50 # Use PATH_SUFFIXES to help find separate libs for debug/release on Windows builds
51 find_library(FLATBUFFERS_LIBRARY_DEBUG NAMES flatbuffers
52 HINTS ${FLATBUFFERS_BUILD_DIR}
53 PATH_SUFFIXES "Debug")
54 find_library(FLATBUFFERS_LIBRARY_RELEASE NAMES flatbuffers
55 HINTS ${FLATBUFFERS_BUILD_DIR}
56 PATH_SUFFIXES "Release")
Jim Flynnfca233e2021-09-23 12:16:53 +010057 target_link_libraries(armnnTfLiteParser
58 armnn
59 tflite_version_headers
60 debug ${FLATBUFFERS_LIBRARY_DEBUG}
61 optimized ${FLATBUFFERS_LIBRARY_RELEASE})
Rob Hughesc3da2682020-01-07 13:26:42 +000062 endif()
Matthew Benthama7b79282019-06-03 13:00:50 +010063
Matthew Sloyanac001ee2021-02-03 10:43:04 +000064 set_target_properties(armnnTfLiteParser PROPERTIES VERSION ${TFLITE_PARSER_LIB_VERSION} SOVERSION ${TFLITE_PARSER_LIB_SOVERSION} )
Matteo Martincighbccc3452019-10-18 14:59:19 +010065
Matthew Benthama7b79282019-06-03 13:00:50 +010066 install(TARGETS armnnTfLiteParser
Rob Hughes91e1d892019-08-23 10:11:58 +010067 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
68 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
Matthew Benthama7b79282019-06-03 13:00:50 +010069endif()