Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 1 | # |
Kevin May | 93bbf00 | 2024-03-11 09:31:10 +0000 | [diff] [blame] | 2 | # Copyright © 2022-2024 Arm Ltd and Contributors. All rights reserved. |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 3 | # SPDX-License-Identifier: MIT |
| 4 | # |
| 5 | |
Jan Eilers | b968a4f | 2020-11-15 14:44:43 +0000 | [diff] [blame] | 6 | cmake_minimum_required (VERSION 3.7.0) |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 7 | project(armnnDelegate) |
Ryan OShea | 238ecd9 | 2023-03-07 11:44:23 +0000 | [diff] [blame] | 8 | set(CMAKE_CXX_STANDARD 17) |
| 9 | set(CMAKE_CXX_STANDARD_REQUIRED ON) |
Ryan OShea | 238ecd9 | 2023-03-07 11:44:23 +0000 | [diff] [blame] | 10 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wall -Wextra -Werror -Wold-style-cast -Wno-missing-braces -Wconversion -Wsign-conversion -Wno-comment") |
Finn Williams | bbbefec | 2020-11-25 14:32:42 +0000 | [diff] [blame] | 11 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/Modules/") |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 12 | |
Teresa Charlin | ad1b3d7 | 2023-03-14 12:10:28 +0000 | [diff] [blame] | 13 | option(BUILD_UNIT_TESTS "Build unit tests" ON) |
| 14 | option(BUILD_CLASSIC_DELEGATE "Build classic delegate" ON) |
| 15 | option(BUILD_OPAQUE_DELEGATE "Build opaque delegate" OFF) |
| 16 | option(BUILD_SHARED_LIBS "Build share libs" ON) |
| 17 | option(BUILD_DELEGATE_JNI_INTERFACE "Builds a library to allow accessing the Arm NN delegate from Java code. |
| 18 | This is an experimental feature." ON) |
| 19 | |
Kevin May | 2c2f3aa | 2024-05-10 15:40:08 +0100 | [diff] [blame] | 20 | ## Do not include flatbuffers::ClassicLocale which can cause abort when destroyed |
| 21 | add_definitions(-DFLATBUFFERS_LOCALE_INDEPENDENT=0) |
| 22 | |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 23 | set(armnnDelegate_sources) |
| 24 | list(APPEND armnnDelegate_sources |
Teresa Charlin | ad1b3d7 | 2023-03-14 12:10:28 +0000 | [diff] [blame] | 25 | common/include/DelegateOptions.hpp |
| 26 | common/src/DelegateOptions.cpp |
David Monahan | 6c53f9f | 2023-04-27 15:21:19 +0100 | [diff] [blame] | 27 | common/src/DelegateUtils.hpp |
| 28 | common/src/MultiLayerFacade.hpp) |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 29 | |
| 30 | ## Add Armnn as a Dependency |
Finn Williams | bbbefec | 2020-11-25 14:32:42 +0000 | [diff] [blame] | 31 | if(NOT ARMNN_SUB_PROJECT) |
| 32 | find_package(Armnn REQUIRED CONFIG HINTS ${Armnn_DIR}) |
| 33 | endif() |
Teresa Charlin | ad1b3d7 | 2023-03-14 12:10:28 +0000 | [diff] [blame] | 34 | |
| 35 | if (BUILD_CLASSIC_DELEGATE) |
| 36 | add_subdirectory(classic) |
| 37 | add_library(armnnDelegate ${armnnDelegate_sources}) |
| 38 | |
| 39 | target_include_directories(armnnDelegate |
| 40 | PUBLIC |
| 41 | $<INSTALL_INTERFACE:include> |
| 42 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/common/include> |
| 43 | PRIVATE |
| 44 | ${CMAKE_CURRENT_SOURCE_DIR}/common/src) |
| 45 | endif() |
| 46 | if (BUILD_OPAQUE_DELEGATE) |
| 47 | add_subdirectory(opaque) |
| 48 | add_library(armnnOpaqueDelegate ${armnnDelegate_sources}) |
| 49 | |
| 50 | target_include_directories(armnnOpaqueDelegate |
| 51 | PUBLIC |
| 52 | $<INSTALL_INTERFACE:include> |
| 53 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/common/include> |
| 54 | PRIVATE |
| 55 | ${CMAKE_CURRENT_SOURCE_DIR}/common/src) |
| 56 | endif() |
| 57 | |
| 58 | include(GNUInstallDirs) |
| 59 | |
| 60 | if (BUILD_CLASSIC_DELEGATE) |
| 61 | target_link_libraries(armnnDelegate PUBLIC Armnn::Armnn) |
| 62 | |
| 63 | ## Add armnnClassicDelegateObject as a Dependency |
| 64 | target_link_libraries(armnnDelegate PUBLIC armnnClassicDelegateObject) |
| 65 | endif() |
| 66 | if (BUILD_OPAQUE_DELEGATE) |
| 67 | target_link_libraries(armnnOpaqueDelegate PUBLIC Armnn::Armnn) |
| 68 | |
| 69 | ## Add armnnOpaqueDelegateObject as a Dependency |
| 70 | target_link_libraries(armnnOpaqueDelegate PUBLIC armnnOpaqueDelegateObject) |
| 71 | endif() |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 72 | |
Keith Davis | 9a701c8 | 2021-09-28 16:43:24 +0100 | [diff] [blame] | 73 | ## Add TfLite dependency |
Jim Flynn | fca233e | 2021-09-23 12:16:53 +0100 | [diff] [blame] | 74 | find_package(TfLiteSrc REQUIRED MODULE) |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 75 | find_package(TfLite REQUIRED MODULE) |
Teresa Charlin | ad1b3d7 | 2023-03-14 12:10:28 +0000 | [diff] [blame] | 76 | if (BUILD_CLASSIC_DELEGATE) |
| 77 | target_link_libraries(armnnDelegate PUBLIC ${TfLite_LIB}) |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 78 | |
Teresa Charlin | ad1b3d7 | 2023-03-14 12:10:28 +0000 | [diff] [blame] | 79 | # lpthread and ldl are not required for Android |
| 80 | if(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL Android) |
| 81 | target_link_libraries(armnnDelegate PUBLIC -lpthread) |
| 82 | target_link_libraries(armnnDelegate PUBLIC -ldl) |
| 83 | endif() |
Keith Davis | d62eef9 | 2021-09-20 18:17:33 +0100 | [diff] [blame] | 84 | endif() |
Teresa Charlin | ad1b3d7 | 2023-03-14 12:10:28 +0000 | [diff] [blame] | 85 | if (BUILD_OPAQUE_DELEGATE) |
| 86 | target_link_libraries(armnnOpaqueDelegate PUBLIC ${TfLite_LIB}) |
Keith Davis | d62eef9 | 2021-09-20 18:17:33 +0100 | [diff] [blame] | 87 | |
Teresa Charlin | ad1b3d7 | 2023-03-14 12:10:28 +0000 | [diff] [blame] | 88 | # lpthread and ldl are not required for Android |
| 89 | if(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL Android) |
| 90 | target_link_libraries(armnnOpaqueDelegate PUBLIC -lpthread) |
| 91 | target_link_libraries(armnnOpaqueDelegate PUBLIC -ldl) |
| 92 | endif() |
| 93 | endif() |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 94 | |
Narumol Prangnawarat | 4cf0fe3 | 2020-12-18 16:13:06 +0000 | [diff] [blame] | 95 | # Add libraries from armnn third-party libraries |
| 96 | # Third-party header files are not warning clean |
| 97 | # We can't change compilation flags on header files directly, so we need to add them to an interface library first |
| 98 | add_library(thirdparty_headers INTERFACE) |
| 99 | target_include_directories(thirdparty_headers INTERFACE $<BUILD_INTERFACE:${ARMNN_SOURCE_DIR}/third-party> |
| 100 | $<INSTALL_INTERFACE:include/thirdparty_headers>) |
| 101 | |
| 102 | target_compile_options(thirdparty_headers INTERFACE -Wno-old-style-cast) |
Teresa Charlin | ad1b3d7 | 2023-03-14 12:10:28 +0000 | [diff] [blame] | 103 | if (BUILD_CLASSIC_DELEGATE) |
| 104 | target_link_libraries(armnnDelegate PUBLIC thirdparty_headers) |
| 105 | endif() |
| 106 | if (BUILD_OPAQUE_DELEGATE) |
| 107 | target_link_libraries(armnnOpaqueDelegate PUBLIC thirdparty_headers) |
| 108 | endif() |
Narumol Prangnawarat | 4cf0fe3 | 2020-12-18 16:13:06 +0000 | [diff] [blame] | 109 | |
Jim Flynn | fca233e | 2021-09-23 12:16:53 +0100 | [diff] [blame] | 110 | add_library(profiling_library_headers INTERFACE) |
| 111 | target_include_directories(profiling_library_headers INTERFACE $<BUILD_INTERFACE:${ARMNN_SOURCE_DIR}/profiling> |
| 112 | $<INSTALL_INTERFACE:include/profiling_library_headers>) |
Jim Flynn | fca233e | 2021-09-23 12:16:53 +0100 | [diff] [blame] | 113 | |
Teresa Charlin | ad1b3d7 | 2023-03-14 12:10:28 +0000 | [diff] [blame] | 114 | if (BUILD_CLASSIC_DELEGATE) |
| 115 | target_link_libraries(armnnDelegate PUBLIC profiling_library_headers) |
| 116 | target_link_libraries(armnnDelegate PUBLIC Armnn::armnnUtils) |
Matthew Sloyan | ac001ee | 2021-02-03 10:43:04 +0000 | [diff] [blame] | 117 | |
Teresa Charlin | ad1b3d7 | 2023-03-14 12:10:28 +0000 | [diff] [blame] | 118 | set_target_properties(armnnDelegate PROPERTIES VERSION ${DELEGATE_LIB_VERSION} SOVERSION ${DELEGATE_LIB_SOVERSION}) |
| 119 | endif() |
| 120 | if (BUILD_OPAQUE_DELEGATE) |
| 121 | target_link_libraries(armnnOpaqueDelegate PUBLIC profiling_library_headers) |
| 122 | target_link_libraries(armnnOpaqueDelegate PUBLIC Armnn::armnnUtils) |
| 123 | |
| 124 | set_target_properties(armnnOpaqueDelegate PROPERTIES VERSION ${OPAQUE_DELEGATE_LIB_VERSION} SOVERSION ${OPAQUE_DELEGATE_LIB_SOVERSION}) |
| 125 | endif() |
| 126 | |
Matthew Sloyan | 65c21a1 | 2023-04-04 12:06:14 +0100 | [diff] [blame] | 127 | if(BUILD_UNIT_TESTS) |
| 128 | set(commonDelegate_unittest_sources) |
| 129 | list(APPEND commonDelegate_unittest_sources |
| 130 | common/src/test/DelegateTestInterpreter.hpp |
| 131 | common/src/test/DelegateTestInterpreterUtils.hpp |
Teresa Charlin | ad1b3d7 | 2023-03-14 12:10:28 +0000 | [diff] [blame] | 132 | test/ActivationTest.cpp |
| 133 | test/ActivationTestHelper.hpp |
| 134 | test/ArgMinMaxTest.cpp |
| 135 | test/ArgMinMaxTestHelper.hpp |
Teresa Charlin | ad1b3d7 | 2023-03-14 12:10:28 +0000 | [diff] [blame] | 136 | test/BatchMatMulTest.cpp |
| 137 | test/BatchMatMulTestHelper.hpp |
| 138 | test/BatchSpaceTest.cpp |
| 139 | test/BatchSpaceTestHelper.hpp |
Idriss Chaouch | cbf7929 | 2023-09-08 11:18:16 +0100 | [diff] [blame] | 140 | test/BroadcastToTest.cpp |
| 141 | test/BroadcastToTestHelper.hpp |
Teresa Charlin | ad1b3d7 | 2023-03-14 12:10:28 +0000 | [diff] [blame] | 142 | test/CastTest.cpp |
| 143 | test/CastTestHelper.hpp |
| 144 | test/ComparisonTest.cpp |
| 145 | test/ComparisonTestHelper.hpp |
| 146 | test/ControlTest.cpp |
| 147 | test/ControlTestHelper.hpp |
| 148 | test/Convolution2dTest.cpp |
| 149 | test/Convolution3dTest.cpp |
| 150 | test/ConvolutionTestHelper.hpp |
Teresa Charlin | ad1b3d7 | 2023-03-14 12:10:28 +0000 | [diff] [blame] | 151 | test/DepthwiseConvolution2dTest.cpp |
| 152 | test/ElementwiseBinaryTest.cpp |
| 153 | test/ElementwiseBinaryTestHelper.hpp |
| 154 | test/ElementwiseUnaryTest.cpp |
| 155 | test/ElementwiseUnaryTestHelper.hpp |
Matthew Sloyan | 3504e42 | 2023-05-03 13:53:02 +0100 | [diff] [blame] | 156 | test/ExpandDimsTest.cpp |
Teresa Charlin | ad1b3d7 | 2023-03-14 12:10:28 +0000 | [diff] [blame] | 157 | test/FillTest.cpp |
| 158 | test/FillTestHelper.hpp |
| 159 | test/FullyConnectedTest.cpp |
| 160 | test/FullyConnectedTestHelper.hpp |
| 161 | test/GatherTest.cpp |
| 162 | test/GatherTestHelper.hpp |
| 163 | test/GatherNdTest.cpp |
| 164 | test/GatherNdTestHelper.hpp |
| 165 | test/LogicalTest.cpp |
| 166 | test/LogicalTestHelper.hpp |
| 167 | test/LstmTest.cpp |
| 168 | test/LstmTestHelper.hpp |
| 169 | test/MirrorPadTest.cpp |
| 170 | test/NormalizationTest.cpp |
| 171 | test/NormalizationTestHelper.hpp |
| 172 | test/PackTest.cpp |
| 173 | test/PackTestHelper.hpp |
| 174 | test/PadTest.cpp |
| 175 | test/PadTestHelper.hpp |
| 176 | test/Pooling2dTest.cpp |
| 177 | test/Pooling2dTestHelper.hpp |
| 178 | test/Pooling3dTest.cpp |
| 179 | test/Pooling3dTestHelper.hpp |
| 180 | test/PreluTest.cpp |
| 181 | test/PreluTestHelper.hpp |
| 182 | test/QuantizationTest.cpp |
| 183 | test/QuantizationTestHelper.hpp |
| 184 | test/RedefineTestHelper.hpp |
| 185 | test/ReduceTest.cpp |
| 186 | test/ReduceTestHelper.hpp |
| 187 | test/ReshapeTest.cpp |
| 188 | test/ResizeTest.cpp |
| 189 | test/ResizeTestHelper.hpp |
Tracy Narine | 7306bbe | 2023-07-17 16:06:26 +0100 | [diff] [blame] | 190 | test/ReverseV2Test.cpp |
| 191 | test/ReverseV2TestHelper.hpp |
Teresa Charlin | ad1b3d7 | 2023-03-14 12:10:28 +0000 | [diff] [blame] | 192 | test/RoundTest.cpp |
| 193 | test/RoundTestHelper.hpp |
Kevin May | 93bbf00 | 2024-03-11 09:31:10 +0000 | [diff] [blame] | 194 | test/ScatterNdTest.cpp |
| 195 | test/ScatterNdTestHelper.hpp |
Teresa Charlin | ad1b3d7 | 2023-03-14 12:10:28 +0000 | [diff] [blame] | 196 | test/SoftmaxTest.cpp |
| 197 | test/SoftmaxTestHelper.hpp |
| 198 | test/SpaceDepthTest.cpp |
| 199 | test/SpaceDepthTestHelper.hpp |
| 200 | test/ShapeTest.cpp |
| 201 | test/ShapeTestHelper.hpp |
| 202 | test/SliceTest.cpp |
| 203 | test/SliceTestHelper.hpp |
Matthew Sloyan | 3504e42 | 2023-05-03 13:53:02 +0100 | [diff] [blame] | 204 | test/SqueezeTest.cpp |
Teresa Charlin | ad1b3d7 | 2023-03-14 12:10:28 +0000 | [diff] [blame] | 205 | test/StridedSliceTest.cpp |
| 206 | test/StridedSliceTestHelper.hpp |
| 207 | test/SplitTest.cpp |
| 208 | test/SplitTestHelper.hpp |
| 209 | test/TestUtils.hpp |
| 210 | test/TestUtils.cpp |
Tianle Cheng | 92ce35c | 2023-07-25 16:41:00 +0100 | [diff] [blame] | 211 | test/TileTest.cpp |
| 212 | test/TileTestHelper.hpp |
Matthew Sloyan | 080ffd8 | 2023-04-24 12:53:04 +0100 | [diff] [blame] | 213 | test/TransposeConvolution2dTest.cpp |
Teresa Charlin | ad1b3d7 | 2023-03-14 12:10:28 +0000 | [diff] [blame] | 214 | test/TransposeTest.cpp |
| 215 | test/TransposeTestHelper.hpp |
| 216 | test/UnidirectionalSequenceLstmTest.cpp |
| 217 | test/UnidirectionalSequenceLstmTestHelper.hpp |
| 218 | test/UnpackTest.cpp |
| 219 | test/UnpackTestHelper.hpp) |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 220 | |
Matthew Sloyan | 65c21a1 | 2023-04-04 12:06:14 +0100 | [diff] [blame] | 221 | # There's a known Android NDK bug which causes a subset of NeonLayerTests to |
| 222 | # fail. We'll exclude these tests in NeonLayerTests_NDK_Bug.cpp if we're doing |
| 223 | # a debug build and NDK is less than r21. |
| 224 | # https://github.com/android/ndk/issues/1135 |
Keith Davis | 7c67fab | 2021-04-08 11:47:23 +0100 | [diff] [blame] | 225 | |
Matthew Sloyan | 65c21a1 | 2023-04-04 12:06:14 +0100 | [diff] [blame] | 226 | # Default to always including these tests. |
| 227 | set(INCLUDE_NDK_BUG_TESTS "ON") |
| 228 | # Reconsider if we in a debug build. |
| 229 | string( TOLOWER ${CMAKE_BUILD_TYPE} BUILD_TYPE_LOWERCASE ) |
| 230 | if ( NOT BUILD_TYPE_LOWERCASE STREQUAL "release" ) |
| 231 | message("CMAKE:: BUILD TYPE IS ${CMAKE_BUILD_TYPE}") |
| 232 | # And NDK_VERSION has been set. |
| 233 | if ( DEFINED NDK_VERSION ) |
| 234 | message("CMAKE:: NDK DEFINED") |
| 235 | # And the version is less than r21. |
| 236 | if ( ${NDK_VERSION} STRLESS "r21" ) |
| 237 | message("CMAKE:: BUG TESTS OFF") |
| 238 | set(INCLUDE_NDK_BUG_TESTS "OFF") |
Keith Davis | 7c67fab | 2021-04-08 11:47:23 +0100 | [diff] [blame] | 239 | endif() |
| 240 | endif() |
Matthew Sloyan | 65c21a1 | 2023-04-04 12:06:14 +0100 | [diff] [blame] | 241 | endif() |
Keith Davis | 7c67fab | 2021-04-08 11:47:23 +0100 | [diff] [blame] | 242 | |
Matthew Sloyan | 65c21a1 | 2023-04-04 12:06:14 +0100 | [diff] [blame] | 243 | if ( INCLUDE_NDK_BUG_TESTS STREQUAL "ON" ) |
| 244 | list(APPEND commonDelegate_unittest_sources |
| 245 | test/NeonDelegateTests_NDK_Issue.cpp) |
| 246 | endif() |
Keith Davis | 7c67fab | 2021-04-08 11:47:23 +0100 | [diff] [blame] | 247 | |
Matthew Sloyan | 65c21a1 | 2023-04-04 12:06:14 +0100 | [diff] [blame] | 248 | if (BUILD_CLASSIC_DELEGATE) |
| 249 | set(classicDelegate_unittest_sources) |
| 250 | list(APPEND classicDelegate_unittest_sources |
| 251 | classic/src/test/ArmnnClassicDelegateTest.cpp |
Ryan OShea | 59f8f65 | 2023-05-11 20:37:53 +0100 | [diff] [blame] | 252 | classic/src/test/DelegateTestInterpreter.cpp |
| 253 | test/DelegateOptionsTest.cpp |
| 254 | test/DelegateOptionsTestHelper.hpp) |
Matthew Sloyan | 65c21a1 | 2023-04-04 12:06:14 +0100 | [diff] [blame] | 255 | |
| 256 | add_executable(DelegateUnitTests ${commonDelegate_unittest_sources} ${classicDelegate_unittest_sources}) |
Keith Davis | 7c67fab | 2021-04-08 11:47:23 +0100 | [diff] [blame] | 257 | |
Teresa Charlin | ad1b3d7 | 2023-03-14 12:10:28 +0000 | [diff] [blame] | 258 | target_include_directories(DelegateUnitTests SYSTEM PRIVATE "${TF_LITE_SCHEMA_INCLUDE_PATH}") |
Matthew Sloyan | ebe392d | 2023-03-30 10:12:08 +0100 | [diff] [blame] | 259 | target_include_directories(DelegateUnitTests SYSTEM PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/common/src/test") |
Matthew Sloyan | 65c21a1 | 2023-04-04 12:06:14 +0100 | [diff] [blame] | 260 | target_include_directories(DelegateUnitTests PUBLIC ${PROJECT_SOURCE_DIR}) |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 261 | |
Teresa Charlin | ad1b3d7 | 2023-03-14 12:10:28 +0000 | [diff] [blame] | 262 | # Add half library from armnn third-party libraries |
| 263 | target_link_libraries(DelegateUnitTests PRIVATE thirdparty_headers) |
Ryan OShea | ac9607f | 2023-04-03 11:33:33 +0100 | [diff] [blame] | 264 | target_link_libraries(DelegateUnitTests PRIVATE armnnDelegate) |
Teresa Charlin | ad1b3d7 | 2023-03-14 12:10:28 +0000 | [diff] [blame] | 265 | target_link_libraries(DelegateUnitTests PRIVATE Armnn::armnnUtils) |
Teresa Charlin | ad1b3d7 | 2023-03-14 12:10:28 +0000 | [diff] [blame] | 266 | target_link_libraries(DelegateUnitTests PRIVATE profiling_library_headers) |
Matthew Sloyan | 65c21a1 | 2023-04-04 12:06:14 +0100 | [diff] [blame] | 267 | endif() |
| 268 | |
| 269 | if (BUILD_OPAQUE_DELEGATE) |
| 270 | set(opaqueDelegate_unittest_sources) |
| 271 | list(APPEND opaqueDelegate_unittest_sources |
Matthew Sloyan | 65c21a1 | 2023-04-04 12:06:14 +0100 | [diff] [blame] | 272 | opaque/src/test/ArmnnOpaqueDelegateTest.cpp |
Ryan OShea | 59f8f65 | 2023-05-11 20:37:53 +0100 | [diff] [blame] | 273 | opaque/src/test/DelegateTestInterpreter.cpp) |
Matthew Sloyan | 65c21a1 | 2023-04-04 12:06:14 +0100 | [diff] [blame] | 274 | |
| 275 | # Until all operators are supported, we have to add tests one by one above to opaqueDelegate_unittest_sources. |
| 276 | # After we add can add commonDelegate_unittest_sources to the add_executable below. |
Ryan OShea | 59f8f65 | 2023-05-11 20:37:53 +0100 | [diff] [blame] | 277 | add_executable(OpaqueDelegateUnitTests ${opaqueDelegate_unittest_sources} ${commonDelegate_unittest_sources}) |
Matthew Sloyan | 65c21a1 | 2023-04-04 12:06:14 +0100 | [diff] [blame] | 278 | |
| 279 | target_include_directories(OpaqueDelegateUnitTests SYSTEM PRIVATE "${TF_LITE_SCHEMA_INCLUDE_PATH}") |
| 280 | target_include_directories(OpaqueDelegateUnitTests SYSTEM PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/common/src/test") |
| 281 | target_include_directories(OpaqueDelegateUnitTests PUBLIC ${PROJECT_SOURCE_DIR}) |
| 282 | |
| 283 | # Add half library from armnn third-party libraries |
| 284 | target_link_libraries(OpaqueDelegateUnitTests PRIVATE thirdparty_headers) |
| 285 | target_link_libraries(OpaqueDelegateUnitTests PRIVATE armnnOpaqueDelegate) |
| 286 | target_link_libraries(OpaqueDelegateUnitTests PRIVATE Armnn::armnnUtils) |
| 287 | target_link_libraries(OpaqueDelegateUnitTests PRIVATE profiling_library_headers) |
| 288 | endif() |
Sadik Armagan | 4189cc5 | 2020-11-11 18:01:48 +0000 | [diff] [blame] | 289 | endif() |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 290 | |
Narumol Prangnawarat | 46e574e | 2023-05-05 16:39:05 +0100 | [diff] [blame] | 291 | if(BUILD_DELEGATE_JNI_INTERFACE AND BUILD_CLASSIC_DELEGATE) |
Jan Eilers | a96489a | 2021-12-08 10:05:47 +0000 | [diff] [blame] | 292 | add_subdirectory(armnnDelegateJNI) |
| 293 | endif() |
| 294 | |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 295 | #################################################### |
| 296 | ## Export targets |
Narumol Prangnawarat | 46e574e | 2023-05-05 16:39:05 +0100 | [diff] [blame] | 297 | if (BUILD_CLASSIC_DELEGATE) |
| 298 | set(armnn_delegate_export_targets) |
| 299 | list(APPEND armnn_delegate_export_targets |
| 300 | armnnClassicDelegateObject |
| 301 | armnnDelegate |
| 302 | tflite_headers |
| 303 | flatbuffer_headers |
| 304 | profiling_library_headers |
| 305 | thirdparty_headers) |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 306 | |
Narumol Prangnawarat | 46e574e | 2023-05-05 16:39:05 +0100 | [diff] [blame] | 307 | install( |
| 308 | TARGETS ${armnn_delegate_export_targets} |
| 309 | EXPORT armnn-delegate-targets |
| 310 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 311 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 312 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 313 | |
Narumol Prangnawarat | 46e574e | 2023-05-05 16:39:05 +0100 | [diff] [blame] | 314 | ## Set export alias |
| 315 | set_target_properties(armnnDelegate |
| 316 | PROPERTIES |
| 317 | EXPORT_NAME ArmnnDelegate) |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 318 | |
Narumol Prangnawarat | 46e574e | 2023-05-05 16:39:05 +0100 | [diff] [blame] | 319 | ## Export target scrips |
| 320 | install( |
| 321 | EXPORT armnn-delegate-targets |
| 322 | FILE ArmnnDelegateTargets.cmake |
| 323 | NAMESPACE ArmnnDelegate:: |
| 324 | DESTINATION ${CMAKE_INSTALL_LIBDIR}) |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 325 | |
Narumol Prangnawarat | 46e574e | 2023-05-05 16:39:05 +0100 | [diff] [blame] | 326 | ## Create ArmnnDelegateConfig.cmake |
| 327 | include(CMakePackageConfigHelpers) |
| 328 | set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}) |
| 329 | message(STATUS "CMAKE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}" ) |
| 330 | message(STATUS "CMAKE_CURRENT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}" ) |
| 331 | SET(Armnn_DIR "${Armnn_DIR}") |
Finn Williams | bbbefec | 2020-11-25 14:32:42 +0000 | [diff] [blame] | 332 | |
Narumol Prangnawarat | 46e574e | 2023-05-05 16:39:05 +0100 | [diff] [blame] | 333 | configure_package_config_file( |
| 334 | ${CMAKE_CURRENT_LIST_DIR}/cmake/Modules/ArmnnDelegateConfig.cmake.in |
| 335 | ${CMAKE_CURRENT_BINARY_DIR}/ArmnnDelegateConfig.cmake |
| 336 | INSTALL_DESTINATION ${INSTALL_CONFIGDIR} |
| 337 | PATH_VARS Armnn_DIR) |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 338 | |
Narumol Prangnawarat | 46e574e | 2023-05-05 16:39:05 +0100 | [diff] [blame] | 339 | ## Install ArmNN Delegate config file |
| 340 | install( |
| 341 | FILES |
| 342 | ${CMAKE_CURRENT_BINARY_DIR}/ArmnnDelegateConfig.cmake |
| 343 | DESTINATION ${INSTALL_CONFIGDIR}) |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 344 | |
Narumol Prangnawarat | 46e574e | 2023-05-05 16:39:05 +0100 | [diff] [blame] | 345 | ## Export from build tree |
| 346 | export( |
| 347 | EXPORT armnn-delegate-targets |
| 348 | FILE ${CMAKE_CURRENT_BINARY_DIR}/ArmnnDelegateTargets.cmake |
| 349 | NAMESPACE ArmnnDelegate::) |
| 350 | add_library(ArmnnDelegate::ArmnnDelegate ALIAS armnnDelegate) |
| 351 | endif() |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 352 | |
Narumol Prangnawarat | 50c87d3 | 2020-11-09 18:42:11 +0000 | [diff] [blame] | 353 | #################################################### |
Narumol Prangnawarat | 46e574e | 2023-05-05 16:39:05 +0100 | [diff] [blame] | 354 | ## Export opaque delegate targets |
| 355 | |
| 356 | if(BUILD_OPAQUE_DELEGATE) |
| 357 | set(armnn_opaque_delegate_export_targets) |
| 358 | list(APPEND armnn_opaque_delegate_export_targets |
| 359 | armnnOpaqueDelegateObject |
| 360 | armnnOpaqueDelegate |
| 361 | tflite_headers |
| 362 | flatbuffer_headers |
| 363 | profiling_library_headers |
| 364 | thirdparty_headers) |
| 365 | |
| 366 | install( |
| 367 | TARGETS armnnOpaqueDelegate |
| 368 | EXPORT armnn-opaque-delegate-targets |
| 369 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 370 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 371 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) |
| 372 | |
| 373 | ## Set export alias |
| 374 | set_target_properties(armnnOpaqueDelegate |
| 375 | PROPERTIES |
| 376 | EXPORT_NAME ArmnnOpaqueDelegate) |
| 377 | |
| 378 | add_library(ArmnnDelegate::ArmnnOpaqueDelegate ALIAS armnnOpaqueDelegate) |
| 379 | endif() |
| 380 | |
| 381 | #################################################### |