Ruomei Yan | db7c391 | 2019-03-08 17:50:25 +0000 | [diff] [blame] | 1 | # |
| 2 | # Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | # SPDX-License-Identifier: MIT |
| 4 | # |
| 5 | if(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 Sloyan | ac001ee | 2021-02-03 10:43:04 +0000 | [diff] [blame] | 9 | ../../include/armnnTfLiteParser/Version.hpp |
Ruomei Yan | db7c391 | 2019-03-08 17:50:25 +0000 | [diff] [blame] | 10 | 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 Flynn | fca233e | 2021-09-23 12:16:53 +0100 | [diff] [blame] | 22 | |
| 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 Hughes | d561ac1 | 2021-09-29 15:03:46 +0100 | [diff] [blame] | 34 | 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 Flynn | fca233e | 2021-09-23 12:16:53 +0100 | [diff] [blame] | 41 | |
Rob Hughes | c3da268 | 2020-01-07 13:26:42 +0000 | [diff] [blame] | 42 | # 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 Flynn | fca233e | 2021-09-23 12:16:53 +0100 | [diff] [blame] | 45 | target_link_libraries(armnnTfLiteParser |
| 46 | armnn |
| 47 | tflite_version_headers |
| 48 | ${FLATBUFFERS_LIBRARY}) |
Rob Hughes | c3da268 | 2020-01-07 13:26:42 +0000 | [diff] [blame] | 49 | 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 Flynn | fca233e | 2021-09-23 12:16:53 +0100 | [diff] [blame] | 57 | target_link_libraries(armnnTfLiteParser |
| 58 | armnn |
| 59 | tflite_version_headers |
| 60 | debug ${FLATBUFFERS_LIBRARY_DEBUG} |
| 61 | optimized ${FLATBUFFERS_LIBRARY_RELEASE}) |
Rob Hughes | c3da268 | 2020-01-07 13:26:42 +0000 | [diff] [blame] | 62 | endif() |
Matthew Bentham | a7b7928 | 2019-06-03 13:00:50 +0100 | [diff] [blame] | 63 | |
Matthew Sloyan | ac001ee | 2021-02-03 10:43:04 +0000 | [diff] [blame] | 64 | set_target_properties(armnnTfLiteParser PROPERTIES VERSION ${TFLITE_PARSER_LIB_VERSION} SOVERSION ${TFLITE_PARSER_LIB_SOVERSION} ) |
Matteo Martincigh | bccc345 | 2019-10-18 14:59:19 +0100 | [diff] [blame] | 65 | |
Matthew Bentham | a7b7928 | 2019-06-03 13:00:50 +0100 | [diff] [blame] | 66 | install(TARGETS armnnTfLiteParser |
Rob Hughes | 91e1d89 | 2019-08-23 10:11:58 +0100 | [diff] [blame] | 67 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 68 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) |
Matthew Bentham | a7b7928 | 2019-06-03 13:00:50 +0100 | [diff] [blame] | 69 | endif() |