blob: 055ffce1c37b8c8eb98997a4da9d469618091837 [file] [log] [blame]
Sadik Armagan3c24f432020-10-19 17:35:30 +01001#
Ryan OSheab5540542022-07-06 09:52:52 +01002# Copyright © 2022-2023 Arm Ltd and Contributors. All rights reserved.
Sadik Armagan3c24f432020-10-19 17:35:30 +01003# SPDX-License-Identifier: MIT
4#
5
Jan Eilersb968a4f2020-11-15 14:44:43 +00006cmake_minimum_required (VERSION 3.7.0)
Sadik Armagan3c24f432020-10-19 17:35:30 +01007project(armnnDelegate)
Ryan OShea238ecd92023-03-07 11:44:23 +00008set(CMAKE_CXX_STANDARD 17)
9set(CMAKE_CXX_STANDARD_REQUIRED ON)
Ryan OShea238ecd92023-03-07 11:44:23 +000010set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wall -Wextra -Werror -Wold-style-cast -Wno-missing-braces -Wconversion -Wsign-conversion -Wno-comment")
Finn Williamsbbbefec2020-11-25 14:32:42 +000011set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/Modules/")
Sadik Armagan3c24f432020-10-19 17:35:30 +010012
Teresa Charlinad1b3d72023-03-14 12:10:28 +000013option(BUILD_UNIT_TESTS "Build unit tests" ON)
14option(BUILD_CLASSIC_DELEGATE "Build classic delegate" ON)
15option(BUILD_OPAQUE_DELEGATE "Build opaque delegate" OFF)
16option(BUILD_SHARED_LIBS "Build share libs" ON)
17option(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
Sadik Armagan3c24f432020-10-19 17:35:30 +010020set(armnnDelegate_sources)
21list(APPEND armnnDelegate_sources
Teresa Charlinad1b3d72023-03-14 12:10:28 +000022 common/include/DelegateOptions.hpp
23 common/src/DelegateOptions.cpp
David Monahan6c53f9f2023-04-27 15:21:19 +010024 common/src/DelegateUtils.hpp
25 common/src/MultiLayerFacade.hpp)
Sadik Armagan3c24f432020-10-19 17:35:30 +010026
27## Add Armnn as a Dependency
Finn Williamsbbbefec2020-11-25 14:32:42 +000028if(NOT ARMNN_SUB_PROJECT)
29 find_package(Armnn REQUIRED CONFIG HINTS ${Armnn_DIR})
30endif()
Teresa Charlinad1b3d72023-03-14 12:10:28 +000031
32if (BUILD_CLASSIC_DELEGATE)
33 add_subdirectory(classic)
34 add_library(armnnDelegate ${armnnDelegate_sources})
35
36 target_include_directories(armnnDelegate
37 PUBLIC
38 $<INSTALL_INTERFACE:include>
39 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/common/include>
40 PRIVATE
41 ${CMAKE_CURRENT_SOURCE_DIR}/common/src)
42endif()
43if (BUILD_OPAQUE_DELEGATE)
44 add_subdirectory(opaque)
45 add_library(armnnOpaqueDelegate ${armnnDelegate_sources})
46
47 target_include_directories(armnnOpaqueDelegate
48 PUBLIC
49 $<INSTALL_INTERFACE:include>
50 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/common/include>
51 PRIVATE
52 ${CMAKE_CURRENT_SOURCE_DIR}/common/src)
53endif()
54
55include(GNUInstallDirs)
56
57if (BUILD_CLASSIC_DELEGATE)
58 target_link_libraries(armnnDelegate PUBLIC Armnn::Armnn)
59
60 ## Add armnnClassicDelegateObject as a Dependency
61 target_link_libraries(armnnDelegate PUBLIC armnnClassicDelegateObject)
62endif()
63if (BUILD_OPAQUE_DELEGATE)
64 target_link_libraries(armnnOpaqueDelegate PUBLIC Armnn::Armnn)
65
66 ## Add armnnOpaqueDelegateObject as a Dependency
67 target_link_libraries(armnnOpaqueDelegate PUBLIC armnnOpaqueDelegateObject)
68endif()
Sadik Armagan3c24f432020-10-19 17:35:30 +010069
Keith Davis9a701c82021-09-28 16:43:24 +010070## Add TfLite dependency
Jim Flynnfca233e2021-09-23 12:16:53 +010071find_package(TfLiteSrc REQUIRED MODULE)
Sadik Armagan3c24f432020-10-19 17:35:30 +010072find_package(TfLite REQUIRED MODULE)
Teresa Charlinad1b3d72023-03-14 12:10:28 +000073if (BUILD_CLASSIC_DELEGATE)
74 target_link_libraries(armnnDelegate PUBLIC ${TfLite_LIB})
Sadik Armagan3c24f432020-10-19 17:35:30 +010075
Teresa Charlinad1b3d72023-03-14 12:10:28 +000076 # lpthread and ldl are not required for Android
77 if(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL Android)
78 target_link_libraries(armnnDelegate PUBLIC -lpthread)
79 target_link_libraries(armnnDelegate PUBLIC -ldl)
80 endif()
Keith Davisd62eef92021-09-20 18:17:33 +010081endif()
Teresa Charlinad1b3d72023-03-14 12:10:28 +000082if (BUILD_OPAQUE_DELEGATE)
83 target_link_libraries(armnnOpaqueDelegate PUBLIC ${TfLite_LIB})
Keith Davisd62eef92021-09-20 18:17:33 +010084
Teresa Charlinad1b3d72023-03-14 12:10:28 +000085 # lpthread and ldl are not required for Android
86 if(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL Android)
87 target_link_libraries(armnnOpaqueDelegate PUBLIC -lpthread)
88 target_link_libraries(armnnOpaqueDelegate PUBLIC -ldl)
89 endif()
90endif()
Sadik Armagan3c24f432020-10-19 17:35:30 +010091
Narumol Prangnawarat4cf0fe32020-12-18 16:13:06 +000092# Add libraries from armnn third-party libraries
93# Third-party header files are not warning clean
94# We can't change compilation flags on header files directly, so we need to add them to an interface library first
95add_library(thirdparty_headers INTERFACE)
96target_include_directories(thirdparty_headers INTERFACE $<BUILD_INTERFACE:${ARMNN_SOURCE_DIR}/third-party>
97 $<INSTALL_INTERFACE:include/thirdparty_headers>)
98
99target_compile_options(thirdparty_headers INTERFACE -Wno-old-style-cast)
Teresa Charlinad1b3d72023-03-14 12:10:28 +0000100if (BUILD_CLASSIC_DELEGATE)
101 target_link_libraries(armnnDelegate PUBLIC thirdparty_headers)
102endif()
103if (BUILD_OPAQUE_DELEGATE)
104 target_link_libraries(armnnOpaqueDelegate PUBLIC thirdparty_headers)
105endif()
Narumol Prangnawarat4cf0fe32020-12-18 16:13:06 +0000106
Jim Flynnfca233e2021-09-23 12:16:53 +0100107add_library(profiling_library_headers INTERFACE)
108target_include_directories(profiling_library_headers INTERFACE $<BUILD_INTERFACE:${ARMNN_SOURCE_DIR}/profiling>
109 $<INSTALL_INTERFACE:include/profiling_library_headers>)
Jim Flynnfca233e2021-09-23 12:16:53 +0100110
Teresa Charlinad1b3d72023-03-14 12:10:28 +0000111if (BUILD_CLASSIC_DELEGATE)
112 target_link_libraries(armnnDelegate PUBLIC profiling_library_headers)
113 target_link_libraries(armnnDelegate PUBLIC Armnn::armnnUtils)
Matthew Sloyanac001ee2021-02-03 10:43:04 +0000114
Teresa Charlinad1b3d72023-03-14 12:10:28 +0000115 set_target_properties(armnnDelegate PROPERTIES VERSION ${DELEGATE_LIB_VERSION} SOVERSION ${DELEGATE_LIB_SOVERSION})
116endif()
117if (BUILD_OPAQUE_DELEGATE)
118 target_link_libraries(armnnOpaqueDelegate PUBLIC profiling_library_headers)
119 target_link_libraries(armnnOpaqueDelegate PUBLIC Armnn::armnnUtils)
120
121 set_target_properties(armnnOpaqueDelegate PROPERTIES VERSION ${OPAQUE_DELEGATE_LIB_VERSION} SOVERSION ${OPAQUE_DELEGATE_LIB_SOVERSION})
122endif()
123
Matthew Sloyan65c21a12023-04-04 12:06:14 +0100124if(BUILD_UNIT_TESTS)
125 set(commonDelegate_unittest_sources)
126 list(APPEND commonDelegate_unittest_sources
127 common/src/test/DelegateTestInterpreter.hpp
128 common/src/test/DelegateTestInterpreterUtils.hpp
Teresa Charlinad1b3d72023-03-14 12:10:28 +0000129 test/ActivationTest.cpp
130 test/ActivationTestHelper.hpp
131 test/ArgMinMaxTest.cpp
132 test/ArgMinMaxTestHelper.hpp
Teresa Charlinad1b3d72023-03-14 12:10:28 +0000133 test/BatchMatMulTest.cpp
134 test/BatchMatMulTestHelper.hpp
135 test/BatchSpaceTest.cpp
136 test/BatchSpaceTestHelper.hpp
137 test/CastTest.cpp
138 test/CastTestHelper.hpp
139 test/ComparisonTest.cpp
140 test/ComparisonTestHelper.hpp
141 test/ControlTest.cpp
142 test/ControlTestHelper.hpp
143 test/Convolution2dTest.cpp
144 test/Convolution3dTest.cpp
145 test/ConvolutionTestHelper.hpp
146 test/DelegateOptionsTest.cpp
147 test/DelegateOptionsTestHelper.hpp
148 test/DepthwiseConvolution2dTest.cpp
149 test/ElementwiseBinaryTest.cpp
150 test/ElementwiseBinaryTestHelper.hpp
151 test/ElementwiseUnaryTest.cpp
152 test/ElementwiseUnaryTestHelper.hpp
Matthew Sloyan3504e422023-05-03 13:53:02 +0100153 test/ExpandDimsTest.cpp
Teresa Charlinad1b3d72023-03-14 12:10:28 +0000154 test/FillTest.cpp
155 test/FillTestHelper.hpp
156 test/FullyConnectedTest.cpp
157 test/FullyConnectedTestHelper.hpp
158 test/GatherTest.cpp
159 test/GatherTestHelper.hpp
160 test/GatherNdTest.cpp
161 test/GatherNdTestHelper.hpp
162 test/LogicalTest.cpp
163 test/LogicalTestHelper.hpp
164 test/LstmTest.cpp
165 test/LstmTestHelper.hpp
166 test/MirrorPadTest.cpp
167 test/NormalizationTest.cpp
168 test/NormalizationTestHelper.hpp
169 test/PackTest.cpp
170 test/PackTestHelper.hpp
171 test/PadTest.cpp
172 test/PadTestHelper.hpp
173 test/Pooling2dTest.cpp
174 test/Pooling2dTestHelper.hpp
175 test/Pooling3dTest.cpp
176 test/Pooling3dTestHelper.hpp
177 test/PreluTest.cpp
178 test/PreluTestHelper.hpp
179 test/QuantizationTest.cpp
180 test/QuantizationTestHelper.hpp
181 test/RedefineTestHelper.hpp
182 test/ReduceTest.cpp
183 test/ReduceTestHelper.hpp
184 test/ReshapeTest.cpp
185 test/ResizeTest.cpp
186 test/ResizeTestHelper.hpp
187 test/RoundTest.cpp
188 test/RoundTestHelper.hpp
189 test/SoftmaxTest.cpp
190 test/SoftmaxTestHelper.hpp
191 test/SpaceDepthTest.cpp
192 test/SpaceDepthTestHelper.hpp
193 test/ShapeTest.cpp
194 test/ShapeTestHelper.hpp
195 test/SliceTest.cpp
196 test/SliceTestHelper.hpp
Matthew Sloyan3504e422023-05-03 13:53:02 +0100197 test/SqueezeTest.cpp
Teresa Charlinad1b3d72023-03-14 12:10:28 +0000198 test/StridedSliceTest.cpp
199 test/StridedSliceTestHelper.hpp
200 test/SplitTest.cpp
201 test/SplitTestHelper.hpp
202 test/TestUtils.hpp
203 test/TestUtils.cpp
Matthew Sloyan080ffd82023-04-24 12:53:04 +0100204 test/TransposeConvolution2dTest.cpp
Teresa Charlinad1b3d72023-03-14 12:10:28 +0000205 test/TransposeTest.cpp
206 test/TransposeTestHelper.hpp
207 test/UnidirectionalSequenceLstmTest.cpp
208 test/UnidirectionalSequenceLstmTestHelper.hpp
209 test/UnpackTest.cpp
210 test/UnpackTestHelper.hpp)
Sadik Armagan3c24f432020-10-19 17:35:30 +0100211
Matthew Sloyan65c21a12023-04-04 12:06:14 +0100212 # There's a known Android NDK bug which causes a subset of NeonLayerTests to
213 # fail. We'll exclude these tests in NeonLayerTests_NDK_Bug.cpp if we're doing
214 # a debug build and NDK is less than r21.
215 # https://github.com/android/ndk/issues/1135
Keith Davis7c67fab2021-04-08 11:47:23 +0100216
Matthew Sloyan65c21a12023-04-04 12:06:14 +0100217 # Default to always including these tests.
218 set(INCLUDE_NDK_BUG_TESTS "ON")
219 # Reconsider if we in a debug build.
220 string( TOLOWER ${CMAKE_BUILD_TYPE} BUILD_TYPE_LOWERCASE )
221 if ( NOT BUILD_TYPE_LOWERCASE STREQUAL "release" )
222 message("CMAKE:: BUILD TYPE IS ${CMAKE_BUILD_TYPE}")
223 # And NDK_VERSION has been set.
224 if ( DEFINED NDK_VERSION )
225 message("CMAKE:: NDK DEFINED")
226 # And the version is less than r21.
227 if ( ${NDK_VERSION} STRLESS "r21" )
228 message("CMAKE:: BUG TESTS OFF")
229 set(INCLUDE_NDK_BUG_TESTS "OFF")
Keith Davis7c67fab2021-04-08 11:47:23 +0100230 endif()
231 endif()
Matthew Sloyan65c21a12023-04-04 12:06:14 +0100232 endif()
Keith Davis7c67fab2021-04-08 11:47:23 +0100233
Matthew Sloyan65c21a12023-04-04 12:06:14 +0100234 if ( INCLUDE_NDK_BUG_TESTS STREQUAL "ON" )
235 list(APPEND commonDelegate_unittest_sources
236 test/NeonDelegateTests_NDK_Issue.cpp)
237 endif()
Keith Davis7c67fab2021-04-08 11:47:23 +0100238
Matthew Sloyan65c21a12023-04-04 12:06:14 +0100239 if (BUILD_CLASSIC_DELEGATE)
240 set(classicDelegate_unittest_sources)
241 list(APPEND classicDelegate_unittest_sources
242 classic/src/test/ArmnnClassicDelegateTest.cpp
243 classic/src/test/DelegateTestInterpreter.cpp)
244
245 add_executable(DelegateUnitTests ${commonDelegate_unittest_sources} ${classicDelegate_unittest_sources})
Keith Davis7c67fab2021-04-08 11:47:23 +0100246
Teresa Charlinad1b3d72023-03-14 12:10:28 +0000247 target_include_directories(DelegateUnitTests SYSTEM PRIVATE "${TF_LITE_SCHEMA_INCLUDE_PATH}")
Matthew Sloyanebe392d2023-03-30 10:12:08 +0100248 target_include_directories(DelegateUnitTests SYSTEM PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/common/src/test")
Matthew Sloyan65c21a12023-04-04 12:06:14 +0100249 target_include_directories(DelegateUnitTests PUBLIC ${PROJECT_SOURCE_DIR})
Sadik Armagan3c24f432020-10-19 17:35:30 +0100250
Teresa Charlinad1b3d72023-03-14 12:10:28 +0000251 # Add half library from armnn third-party libraries
252 target_link_libraries(DelegateUnitTests PRIVATE thirdparty_headers)
Ryan OSheaac9607f2023-04-03 11:33:33 +0100253 target_link_libraries(DelegateUnitTests PRIVATE armnnDelegate)
Teresa Charlinad1b3d72023-03-14 12:10:28 +0000254 target_link_libraries(DelegateUnitTests PRIVATE Armnn::armnnUtils)
Teresa Charlinad1b3d72023-03-14 12:10:28 +0000255 target_link_libraries(DelegateUnitTests PRIVATE profiling_library_headers)
Matthew Sloyan65c21a12023-04-04 12:06:14 +0100256 endif()
257
258 if (BUILD_OPAQUE_DELEGATE)
259 set(opaqueDelegate_unittest_sources)
260 list(APPEND opaqueDelegate_unittest_sources
261 common/src/test/DelegateTestInterpreter.hpp
262 common/src/test/DelegateTestInterpreterUtils.hpp
263 opaque/src/test/ArmnnOpaqueDelegateTest.cpp
264 opaque/src/test/DelegateTestInterpreter.cpp
Matthew Sloyan0bd4c622023-04-27 11:48:26 +0100265 test/ActivationTest.cpp
266 test/ActivationTestHelper.hpp
John Mcloughlin559d9092023-04-26 20:14:47 +0100267 test/ArgMinMaxTest.cpp
268 test/ArgMinMaxTestHelper.hpp
John Mcloughlin0422cf22023-04-27 16:55:00 +0100269 test/BatchMatMulTest.cpp
270 test/BatchMatMulTestHelper.hpp
Kevin May81b66f32023-04-26 14:55:36 +0100271 test/BatchSpaceTest.cpp
272 test/BatchSpaceTestHelper.hpp
Ryan OSheaa37ccb02023-04-11 10:54:07 +0100273 test/CastTest.cpp
Matthew Sloyan080ffd82023-04-24 12:53:04 +0100274 test/CastTestHelper.hpp
Matthew Sloyan2b04ec32023-04-26 11:42:46 +0100275 test/ComparisonTest.cpp
276 test/ComparisonTestHelper.hpp
277 test/ControlTest.cpp
278 test/ControlTestHelper.hpp
Matthew Sloyan080ffd82023-04-24 12:53:04 +0100279 test/Convolution2dTest.cpp
Francis Murtagh3a9e7ba2023-04-26 15:58:39 +0100280 test/Convolution3dTest.cpp
Matthew Sloyan080ffd82023-04-24 12:53:04 +0100281 test/ConvolutionTestHelper.hpp
282 test/DepthwiseConvolution2dTest.cpp
Teresa Charlinf69ae562023-04-27 14:42:23 +0100283 test/ElementwiseUnaryTestHelper.hpp
284 test/ElementwiseUnaryTest.cpp
Matthew Sloyan3504e422023-05-03 13:53:02 +0100285 test/ExpandDimsTest.cpp
Matthew Sloyan0bd4c622023-04-27 11:48:26 +0100286 test/FullyConnectedTest.cpp
287 test/FullyConnectedTestHelper.hpp
Kevin Mayb2831c52023-04-26 17:27:24 +0100288 test/GatherTest.cpp
289 test/GatherTestHelper.hpp
290 test/GatherNdTest.cpp
291 test/GatherNdTestHelper.hpp
Matthew Sloyan48ec8132023-04-27 17:04:47 +0100292 test/LstmTest.cpp
293 test/LstmTestHelper.hpp
Teresa Charlinf69ae562023-04-27 14:42:23 +0100294 test/LogicalTest.cpp
295 test/LogicalTestHelper.hpp
296 test/NormalizationTest.cpp
297 test/NormalizationTestHelper.hpp
Teresa Charlinecebb0f2023-04-27 21:37:56 +0100298 test/PackTest.cpp
299 test/PackTestHelper.hpp
300 test/PadTest.cpp
301 test/PadTestHelper.hpp
Matthew Sloyan48ec8132023-04-27 17:04:47 +0100302 test/Pooling2dTest.cpp
303 test/Pooling2dTestHelper.hpp
304 test/Pooling3dTest.cpp
305 test/Pooling3dTestHelper.hpp
Matthew Sloyan0bd4c622023-04-27 11:48:26 +0100306 test/PreluTest.cpp
307 test/PreluTestHelper.hpp
John Mcloughlin083586d2023-04-28 18:36:52 +0100308 test/ReduceTest.cpp
309 test/ReduceTestHelper.hpp
Matthew Sloyanc49aacc2023-04-28 17:27:26 +0100310 test/ReshapeTest.cpp
John Mcloughlin083586d2023-04-28 18:36:52 +0100311 test/ResizeTest.cpp
312 test/ResizeTestHelper.hpp
Matthew Sloyan48ec8132023-04-27 17:04:47 +0100313 test/RoundTest.cpp
314 test/RoundTestHelper.hpp
Francis Murtagh36d94ef2023-04-28 14:05:43 +0100315 test/QuantizationTest.cpp
316 test/QuantizationTestHelper.hpp
John Mcloughlin0422cf22023-04-27 16:55:00 +0100317 test/ShapeTest.cpp
318 test/ShapeTestHelper.hpp
Teresa Charlin86b03572023-04-28 13:19:12 +0100319 test/SliceTest.cpp
320 test/SliceTestHelper.hpp
Teresa Charlin42362962023-04-28 14:23:33 +0100321 test/SoftmaxTest.cpp
322 test/SoftmaxTestHelper.hpp
323 test/SpaceDepthTest.cpp
324 test/SpaceDepthTestHelper.hpp
Matthew Sloyan3504e422023-05-03 13:53:02 +0100325 test/SqueezeTest.cpp
Teresa Charlin86b03572023-04-28 13:19:12 +0100326 test/StridedSliceTest.cpp
327 test/StridedSliceTestHelper.hpp
Matthew Sloyan080ffd82023-04-24 12:53:04 +0100328 test/TestUtils.hpp
Francis Murtagh3a9e7ba2023-04-26 15:58:39 +0100329 test/TestUtils.cpp
Teresa Charlinecebb0f2023-04-27 21:37:56 +0100330 test/TransposeConvolution2dTest.cpp
Teresa Charlin42362962023-04-28 14:23:33 +0100331 test/TransposeTest.cpp
332 test/TransposeTestHelper.hpp
Matthew Sloyan74be13e2023-05-03 17:34:00 +0100333 test/UnidirectionalSequenceLstmTest.cpp
334 test/UnidirectionalSequenceLstmTestHelper.hpp
Teresa Charlinecebb0f2023-04-27 21:37:56 +0100335 test/UnpackTest.cpp
336 test/UnpackTestHelper.hpp)
Matthew Sloyan65c21a12023-04-04 12:06:14 +0100337
338 # Until all operators are supported, we have to add tests one by one above to opaqueDelegate_unittest_sources.
339 # After we add can add commonDelegate_unittest_sources to the add_executable below.
340 add_executable(OpaqueDelegateUnitTests ${opaqueDelegate_unittest_sources})
341
342 target_include_directories(OpaqueDelegateUnitTests SYSTEM PRIVATE "${TF_LITE_SCHEMA_INCLUDE_PATH}")
343 target_include_directories(OpaqueDelegateUnitTests SYSTEM PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/common/src/test")
344 target_include_directories(OpaqueDelegateUnitTests PUBLIC ${PROJECT_SOURCE_DIR})
345
346 # Add half library from armnn third-party libraries
347 target_link_libraries(OpaqueDelegateUnitTests PRIVATE thirdparty_headers)
348 target_link_libraries(OpaqueDelegateUnitTests PRIVATE armnnOpaqueDelegate)
349 target_link_libraries(OpaqueDelegateUnitTests PRIVATE Armnn::armnnUtils)
350 target_link_libraries(OpaqueDelegateUnitTests PRIVATE profiling_library_headers)
351 endif()
Sadik Armagan4189cc52020-11-11 18:01:48 +0000352endif()
Sadik Armagan3c24f432020-10-19 17:35:30 +0100353
Narumol Prangnawarat46e574e2023-05-05 16:39:05 +0100354if(BUILD_DELEGATE_JNI_INTERFACE AND BUILD_CLASSIC_DELEGATE)
Jan Eilersa96489a2021-12-08 10:05:47 +0000355 add_subdirectory(armnnDelegateJNI)
356endif()
357
Sadik Armagan3c24f432020-10-19 17:35:30 +0100358####################################################
359## Export targets
Narumol Prangnawarat46e574e2023-05-05 16:39:05 +0100360if (BUILD_CLASSIC_DELEGATE)
361 set(armnn_delegate_export_targets)
362 list(APPEND armnn_delegate_export_targets
363 armnnClassicDelegateObject
364 armnnDelegate
365 tflite_headers
366 flatbuffer_headers
367 profiling_library_headers
368 thirdparty_headers)
Sadik Armagan3c24f432020-10-19 17:35:30 +0100369
Narumol Prangnawarat46e574e2023-05-05 16:39:05 +0100370 install(
371 TARGETS ${armnn_delegate_export_targets}
372 EXPORT armnn-delegate-targets
373 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
374 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
375 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
Sadik Armagan3c24f432020-10-19 17:35:30 +0100376
Narumol Prangnawarat46e574e2023-05-05 16:39:05 +0100377 ## Set export alias
378 set_target_properties(armnnDelegate
379 PROPERTIES
380 EXPORT_NAME ArmnnDelegate)
Sadik Armagan3c24f432020-10-19 17:35:30 +0100381
Narumol Prangnawarat46e574e2023-05-05 16:39:05 +0100382 ## Export target scrips
383 install(
384 EXPORT armnn-delegate-targets
385 FILE ArmnnDelegateTargets.cmake
386 NAMESPACE ArmnnDelegate::
387 DESTINATION ${CMAKE_INSTALL_LIBDIR})
Sadik Armagan3c24f432020-10-19 17:35:30 +0100388
Narumol Prangnawarat46e574e2023-05-05 16:39:05 +0100389 ## Create ArmnnDelegateConfig.cmake
390 include(CMakePackageConfigHelpers)
391 set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR})
392 message(STATUS "CMAKE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}" )
393 message(STATUS "CMAKE_CURRENT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}" )
394 SET(Armnn_DIR "${Armnn_DIR}")
Finn Williamsbbbefec2020-11-25 14:32:42 +0000395
Narumol Prangnawarat46e574e2023-05-05 16:39:05 +0100396 configure_package_config_file(
397 ${CMAKE_CURRENT_LIST_DIR}/cmake/Modules/ArmnnDelegateConfig.cmake.in
398 ${CMAKE_CURRENT_BINARY_DIR}/ArmnnDelegateConfig.cmake
399 INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
400 PATH_VARS Armnn_DIR)
Sadik Armagan3c24f432020-10-19 17:35:30 +0100401
Narumol Prangnawarat46e574e2023-05-05 16:39:05 +0100402 ## Install ArmNN Delegate config file
403 install(
404 FILES
405 ${CMAKE_CURRENT_BINARY_DIR}/ArmnnDelegateConfig.cmake
406 DESTINATION ${INSTALL_CONFIGDIR})
Sadik Armagan3c24f432020-10-19 17:35:30 +0100407
Narumol Prangnawarat46e574e2023-05-05 16:39:05 +0100408 ## Export from build tree
409 export(
410 EXPORT armnn-delegate-targets
411 FILE ${CMAKE_CURRENT_BINARY_DIR}/ArmnnDelegateTargets.cmake
412 NAMESPACE ArmnnDelegate::)
413 add_library(ArmnnDelegate::ArmnnDelegate ALIAS armnnDelegate)
414endif()
Sadik Armagan3c24f432020-10-19 17:35:30 +0100415
Narumol Prangnawarat50c87d32020-11-09 18:42:11 +0000416####################################################
Narumol Prangnawarat46e574e2023-05-05 16:39:05 +0100417## Export opaque delegate targets
418
419if(BUILD_OPAQUE_DELEGATE)
420 set(armnn_opaque_delegate_export_targets)
421 list(APPEND armnn_opaque_delegate_export_targets
422 armnnOpaqueDelegateObject
423 armnnOpaqueDelegate
424 tflite_headers
425 flatbuffer_headers
426 profiling_library_headers
427 thirdparty_headers)
428
429 install(
430 TARGETS armnnOpaqueDelegate
431 EXPORT armnn-opaque-delegate-targets
432 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
433 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
434 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
435
436 ## Set export alias
437 set_target_properties(armnnOpaqueDelegate
438 PROPERTIES
439 EXPORT_NAME ArmnnOpaqueDelegate)
440
441 add_library(ArmnnDelegate::ArmnnOpaqueDelegate ALIAS armnnOpaqueDelegate)
442endif()
443
444####################################################