Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 1 | # |
| 2 | # Copyright © 2020 Arm Ltd and Contributors. All rights reserved. |
| 3 | # SPDX-License-Identifier: MIT |
| 4 | # |
| 5 | |
| 6 | cmake_minimum_required (VERSION 3.8.0) |
| 7 | project(armnnDelegate) |
| 8 | |
| 9 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") |
| 10 | |
| 11 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") |
| 12 | |
| 13 | set(armnnDelegate_sources) |
| 14 | list(APPEND armnnDelegate_sources |
| 15 | include/armnn_delegate.hpp |
| 16 | include/DelegateOptions.hpp |
| 17 | src/armnn_delegate.cpp |
| 18 | src/DelegateOptions.cpp) |
| 19 | |
| 20 | add_library(armnnDelegate SHARED ${armnnDelegate_sources}) |
| 21 | |
| 22 | target_include_directories(armnnDelegate |
| 23 | PUBLIC |
| 24 | $<INSTALL_INTERFACE:include> |
| 25 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
| 26 | PRIVATE |
| 27 | ${CMAKE_CURRENT_SOURCE_DIR}/src) |
| 28 | |
| 29 | include(GNUInstallDirs) |
| 30 | |
| 31 | ## Add Armnn as a Dependency |
| 32 | find_package(Armnn REQUIRED) |
| 33 | target_link_libraries(armnnDelegate Armnn::Armnn) |
| 34 | |
| 35 | ## Add Tensorflow v2.3.1 dependency |
| 36 | find_package(Tensorflow 2.3.1 REQUIRED MODULE) |
| 37 | |
| 38 | target_link_libraries(armnnDelegate |
| 39 | ${Tensorflow_LIB}) |
| 40 | |
| 41 | target_include_directories(armnnDelegate |
| 42 | PRIVATE |
| 43 | ${Tensorflow_INCLUDE_DIR}) |
| 44 | |
| 45 | ## Add TfLite v2.3.1 dependency |
| 46 | find_package(TfLite REQUIRED MODULE) |
| 47 | |
| 48 | target_link_libraries(armnnDelegate |
| 49 | ${TfLite_LIB}) |
| 50 | |
| 51 | target_include_directories(armnnDelegate |
| 52 | PRIVATE |
| 53 | ${TfLite_INCLUDE_DIR}) |
| 54 | |
| 55 | target_include_directories(armnnDelegate |
| 56 | SYSTEM PRIVATE |
| 57 | "${TfLite_Schema_INCLUDE_PATH}") |
| 58 | |
| 59 | ## Add Flatbuffers dependency |
| 60 | find_package(Flatbuffers REQUIRED MODULE) |
| 61 | |
| 62 | target_link_libraries(armnnDelegate |
| 63 | ${Flatbuffers_LIB}) |
| 64 | |
| 65 | target_include_directories(armnnDelegate |
| 66 | PRIVATE |
| 67 | ${Flatbuffers_INCLUDE_DIR}) |
| 68 | |
| 69 | set(armnnDelegate_unittest_sources) |
| 70 | list(APPEND armnnDelegate_unittest_sources |
| 71 | src/test/ArmnnDelegateTest.cpp) |
| 72 | |
| 73 | add_executable(DelegateUnitTests ${armnnDelegate_unittest_sources}) |
| 74 | target_include_directories(DelegateUnitTests PRIVATE src) |
| 75 | target_include_directories(DelegateUnitTests PRIVATE third-party) |
| 76 | |
| 77 | target_link_libraries(DelegateUnitTests armnnDelegate) |
| 78 | |
| 79 | target_include_directories(DelegateUnitTests |
| 80 | PRIVATE |
| 81 | ${TfLite_INCLUDE_DIR}) |
| 82 | |
| 83 | target_include_directories(DelegateUnitTests |
| 84 | SYSTEM PRIVATE |
| 85 | "${TfLite_Schema_INCLUDE_PATH}") |
| 86 | |
| 87 | #################################################### |
| 88 | ## Export targets |
| 89 | set(armnn_delegate_export_targets) |
| 90 | list(APPEND armnn_delegate_export_targets |
| 91 | armnnDelegate) |
| 92 | |
| 93 | install( |
| 94 | TARGETS ${armnn_delegate_export_targets} |
| 95 | EXPORT armnn-delegate-targets |
| 96 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 97 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 98 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) |
| 99 | |
| 100 | ## Set export alias |
| 101 | set_target_properties(armnnDelegate |
| 102 | PROPERTIES |
| 103 | EXPORT_NAME ArmnnDelegate) |
| 104 | |
| 105 | ## Export target scrips |
| 106 | install( |
| 107 | EXPORT armnn-delegate-targets |
| 108 | FILE ArmnnDelegateTargets.cmake |
| 109 | NAMESPACE ArmnnDelegate:: |
| 110 | DESTINATION ${CMAKE_INSTALL_LIBDIR}) |
| 111 | |
| 112 | ## Create ArmnnDelegateConfig.cmake |
| 113 | include(CMakePackageConfigHelpers) |
| 114 | set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}) |
| 115 | message(STATUS "CMAKE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}" ) |
| 116 | message(STATUS "CMAKE_CURRENT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}" ) |
| 117 | configure_package_config_file( |
| 118 | ${CMAKE_CURRENT_LIST_DIR}/cmake/Modules/ArmnnDelegateConfig.cmake.in |
| 119 | ${CMAKE_CURRENT_BINARY_DIR}/ArmnnDelegateConfig.cmake |
| 120 | INSTALL_DESTINATION ${INSTALL_CONFIGDIR}) |
| 121 | |
| 122 | ## Install ArmNN Delegate config file |
| 123 | install( |
| 124 | FILES |
| 125 | ${CMAKE_CURRENT_BINARY_DIR}/ArmnnDelegateConfig.cmake |
| 126 | DESTINATION ${INSTALL_CONFIGDIR}) |
| 127 | |
| 128 | ## Export from build tree |
| 129 | export( |
| 130 | EXPORT armnn-delegate-targets |
| 131 | FILE ${CMAKE_CURRENT_BINARY_DIR}/ArmnnDelegateTargets.cmake |
| 132 | NAMESPACE ArmnnDelegate::) |
| 133 | |
| 134 | #################################################### |