blob: 1ea0cdd6440a8e87d15611bff8b9dbdc55e6342e [file] [log] [blame]
Sadik Armagan3c24f432020-10-19 17:35:30 +01001#
2# Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
3# 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)
8
Finn Williams6f9f9902020-11-13 13:23:15 +00009set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -Wextra -Werror -Wold-style-cast -Wno-missing-braces -Wconversion -Wsign-conversion")
Sadik Armagan3c24f432020-10-19 17:35:30 +010010
11set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
12
13set(armnnDelegate_sources)
14list(APPEND armnnDelegate_sources
15 include/armnn_delegate.hpp
16 include/DelegateOptions.hpp
17 src/armnn_delegate.cpp
Sadik Armagan62483be2020-10-23 17:14:43 +010018 src/DelegateOptions.cpp
19 src/Activation.hpp
20 src/ArgMinMax.hpp
21 src/BatchSpace.hpp
22 src/Comparison.hpp
23 src/Convolution.hpp
24 src/Control.hpp
25 src/DelegateUtils.hpp
26 src/ElementwiseBinary.hpp
27 src/ElementwiseUnary.hpp
28 src/Fill.hpp
29 src/FullyConnected.hpp
30 src/Gather.hpp
31 src/Lstm.hpp
32 src/Normalization.hpp
33 src/Pad.hpp
34 src/Pooling.hpp
35 src/Quantization.hpp
36 src/Redefine.hpp
37 src/Resize.hpp
38 src/Round.hpp
39 src/Slice.hpp
40 src/Softmax.hpp
41 src/SpaceDepth.hpp
42 src/Transpose.hpp)
Sadik Armagan3c24f432020-10-19 17:35:30 +010043
44add_library(armnnDelegate SHARED ${armnnDelegate_sources})
45
46target_include_directories(armnnDelegate
47 PUBLIC
48 $<INSTALL_INTERFACE:include>
49 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
50 PRIVATE
51 ${CMAKE_CURRENT_SOURCE_DIR}/src)
52
53include(GNUInstallDirs)
54
55## Add Armnn as a Dependency
56find_package(Armnn REQUIRED)
57target_link_libraries(armnnDelegate Armnn::Armnn)
58
59## Add Tensorflow v2.3.1 dependency
60find_package(Tensorflow 2.3.1 REQUIRED MODULE)
61
62target_link_libraries(armnnDelegate
63 ${Tensorflow_LIB})
64
65target_include_directories(armnnDelegate
66 PRIVATE
67 ${Tensorflow_INCLUDE_DIR})
68
69## Add TfLite v2.3.1 dependency
70find_package(TfLite REQUIRED MODULE)
71
72target_link_libraries(armnnDelegate
73 ${TfLite_LIB})
74
Finn Williams6f9f9902020-11-13 13:23:15 +000075# Various tflite header files are not warning clean
76# We can't change compilation flags on header files directly, so we need to add them to an interface library first
77add_library(tflite_headers INTERFACE)
78target_include_directories(tflite_headers INTERFACE $<BUILD_INTERFACE:${TfLite_INCLUDE_DIR}>
79 $<INSTALL_INTERFACE:include/tflite_headers>)
80
81target_compile_options(tflite_headers INTERFACE $<$<CXX_COMPILER_ID:GNU>:-Wno-conversion
82 -Wno-sign-conversion
83 -Wno-unused-parameter
84 -Wno-unused-function>)
85
86target_link_libraries(armnnDelegate tflite_headers)
Sadik Armagan3c24f432020-10-19 17:35:30 +010087
Sadik Armagan3c24f432020-10-19 17:35:30 +010088## Add Flatbuffers dependency
89find_package(Flatbuffers REQUIRED MODULE)
90
91target_link_libraries(armnnDelegate
92 ${Flatbuffers_LIB})
93
Finn Williams6f9f9902020-11-13 13:23:15 +000094# include/flatbuffers/flatbuffers.h is not warning clean
95# We can't change compilation flags on header files directly, so we need to add them to an interface library first
96add_library(flatbuffer_headers INTERFACE)
97target_include_directories(flatbuffer_headers INTERFACE $<BUILD_INTERFACE:${Flatbuffers_INCLUDE_DIR}>
98 $<INSTALL_INTERFACE:include/flatbuffer_headers>)
99target_compile_options(flatbuffer_headers INTERFACE $<$<CXX_COMPILER_ID:GNU>:-Wno-sign-conversion>)
100
101target_link_libraries(armnnDelegate flatbuffer_headers)
Sadik Armagan3c24f432020-10-19 17:35:30 +0100102
Sadik Armagan4189cc52020-11-11 18:01:48 +0000103option(BUILD_UNIT_TESTS "Build unit tests" ON)
104if(BUILD_UNIT_TESTS)
105 set(armnnDelegate_unittest_sources)
106 list(APPEND armnnDelegate_unittest_sources
Sadik Armagan62483be2020-10-23 17:14:43 +0100107 src/test/ArmnnDelegateTest.cpp
Sadik Armagan8b9858d2020-11-09 08:26:22 +0000108 src/test/ComparisonTest.cpp
109 src/test/ComparisonTestHelper.hpp
Matthew Sloyan91c41712020-11-13 09:47:35 +0000110 src/test/ControlTest.cpp
111 src/test/ControlTestHelper.hpp
Sadik Armagan32ca1442020-11-13 17:51:56 +0000112 src/test/Convolution2dTest.cpp
113 src/test/ConvolutionTestHelper.hpp
114 src/test/DepthwiseConvolution2dTest.cpp
Sadik Armagan67e95f22020-10-29 16:14:54 +0000115 src/test/ElementwiseBinaryTest.cpp
116 src/test/ElementwiseBinaryTestHelper.hpp
Sadik Armagan0534e032020-10-27 17:30:18 +0000117 src/test/ElementwiseUnaryTest.cpp
Matthew Sloyan0d35a932020-11-09 12:25:05 +0000118 src/test/ElementwiseUnaryTestHelper.hpp
Sadik Armagan6e36a642020-11-10 21:18:41 +0000119 src/test/FullyConnectedTest.cpp
120 src/test/FullyConnectedTestHelper.hpp
Narumol Prangnawarat50c87d32020-11-09 18:42:11 +0000121 src/test/Pooling2dTest.cpp
122 src/test/Pooling2dTestHelper.hpp
Matthew Sloyan0d35a932020-11-09 12:25:05 +0000123 src/test/QuantizationTest.cpp
Jan Eilerse339bf62020-11-10 18:43:23 +0000124 src/test/QuantizationTestHelper.hpp
125 src/test/ResizeTest.cpp
126 src/test/ResizeTestHelper.hpp
James Wardf89964e2020-11-09 11:57:47 +0000127 src/test/TransposeTest.cpp
128 src/test/TransposeTestHelper.hpp
Jan Eilerse339bf62020-11-10 18:43:23 +0000129 src/test/TestUtils.hpp)
Sadik Armagan3c24f432020-10-19 17:35:30 +0100130
Sadik Armagan4189cc52020-11-11 18:01:48 +0000131 add_executable(DelegateUnitTests ${armnnDelegate_unittest_sources})
132 target_include_directories(DelegateUnitTests PRIVATE third-party)
Sadik Armagan3c24f432020-10-19 17:35:30 +0100133
Sadik Armagan4189cc52020-11-11 18:01:48 +0000134 # Add half library from armnn third-party libraries
135 target_include_directories(DelegateUnitTests PRIVATE ${ARMNN_SOURCE_DIR}/third-party)
Sadik Armagan3c24f432020-10-19 17:35:30 +0100136
Sadik Armagan4189cc52020-11-11 18:01:48 +0000137 target_link_libraries(DelegateUnitTests armnnDelegate)
138 target_link_libraries(DelegateUnitTests Armnn::armnnUtils)
139
Finn Williams6f9f9902020-11-13 13:23:15 +0000140target_link_libraries(DelegateUnitTests tflite_headers)
Sadik Armagan3c24f432020-10-19 17:35:30 +0100141
Finn Williams6f9f9902020-11-13 13:23:15 +0000142target_link_libraries(DelegateUnitTests flatbuffer_headers)
143
Sadik Armagan4189cc52020-11-11 18:01:48 +0000144endif()
Sadik Armagan3c24f432020-10-19 17:35:30 +0100145
146####################################################
147## Export targets
148set(armnn_delegate_export_targets)
149list(APPEND armnn_delegate_export_targets
Finn Williams6f9f9902020-11-13 13:23:15 +0000150 armnnDelegate
151 tflite_headers
152 flatbuffer_headers)
Sadik Armagan3c24f432020-10-19 17:35:30 +0100153
154install(
155 TARGETS ${armnn_delegate_export_targets}
156 EXPORT armnn-delegate-targets
157 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
158 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
159 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
160
161## Set export alias
162set_target_properties(armnnDelegate
163 PROPERTIES
164 EXPORT_NAME ArmnnDelegate)
165
166## Export target scrips
167install(
168 EXPORT armnn-delegate-targets
169 FILE ArmnnDelegateTargets.cmake
170 NAMESPACE ArmnnDelegate::
171 DESTINATION ${CMAKE_INSTALL_LIBDIR})
172
173## Create ArmnnDelegateConfig.cmake
174include(CMakePackageConfigHelpers)
175set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR})
176message(STATUS "CMAKE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}" )
177message(STATUS "CMAKE_CURRENT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}" )
178configure_package_config_file(
179 ${CMAKE_CURRENT_LIST_DIR}/cmake/Modules/ArmnnDelegateConfig.cmake.in
180 ${CMAKE_CURRENT_BINARY_DIR}/ArmnnDelegateConfig.cmake
181 INSTALL_DESTINATION ${INSTALL_CONFIGDIR})
182
183## Install ArmNN Delegate config file
184install(
185 FILES
186 ${CMAKE_CURRENT_BINARY_DIR}/ArmnnDelegateConfig.cmake
187 DESTINATION ${INSTALL_CONFIGDIR})
188
189## Export from build tree
190export(
191 EXPORT armnn-delegate-targets
192 FILE ${CMAKE_CURRENT_BINARY_DIR}/ArmnnDelegateTargets.cmake
193 NAMESPACE ArmnnDelegate::)
194
Narumol Prangnawarat50c87d32020-11-09 18:42:11 +0000195####################################################