blob: 60b6a3dae6b04bc892a15ec87929be3d543f77aa [file] [log] [blame]
Pavel Macenauer59e057f2020-04-15 14:17:26 +00001#
2# Copyright © 2020 Arm Ltd. All rights reserved.
3# Copyright 2020 NXP
4# SPDX-License-Identifier: MIT
5#
telsoa014fcda012018-03-09 14:13:49 +00006option(BUILD_CAFFE_PARSER "Build Caffe parser" OFF)
7option(BUILD_TF_PARSER "Build Tensorflow parser" OFF)
telsoa01c577f2c2018-08-31 09:22:23 +01008option(BUILD_ONNX_PARSER "Build Onnx parser" OFF)
telsoa014fcda012018-03-09 14:13:49 +00009option(BUILD_UNIT_TESTS "Build unit tests" ON)
10option(BUILD_TESTS "Build test applications" OFF)
11option(BUILD_FOR_COVERAGE "Use no optimization and output .gcno and .gcda files" OFF)
12option(ARMCOMPUTENEON "Build with ARM Compute NEON support" OFF)
13option(ARMCOMPUTECL "Build with ARM Compute OpenCL support" OFF)
Matteo Martincighf88663c2019-08-28 16:38:53 +010014option(ARMNNREF "Build with ArmNN reference support" ON)
telsoa014fcda012018-03-09 14:13:49 +000015option(PROFILING_BACKEND_STREAMLINE "Forward the armNN profiling events to DS-5/Streamline as annotations" OFF)
telsoa01c577f2c2018-08-31 09:22:23 +010016# options used for heap profiling and leak checking
surmeh013537c2c2018-05-18 16:31:43 +010017option(HEAP_PROFILING "Build with heap profiling enabled" OFF)
telsoa01c577f2c2018-08-31 09:22:23 +010018option(LEAK_CHECKING "Build with leak checking enabled" OFF)
surmeh013537c2c2018-05-18 16:31:43 +010019option(GPERFTOOLS_ROOT "Location where the gperftools 'include' and 'lib' folders to be found" Off)
telsoa01c577f2c2018-08-31 09:22:23 +010020# options used for tensorflow lite support
21option(BUILD_TF_LITE_PARSER "Build Tensorflow Lite parser" OFF)
Nattapat Chaimanowong949f1252019-01-31 15:36:39 +000022option(BUILD_ARMNN_SERIALIZER "Build Armnn Serializer" OFF)
Jim Flynn3091b062019-02-15 14:45:04 +000023option(BUILD_ARMNN_QUANTIZER "Build ArmNN quantizer" OFF)
Éanna Ó Catháina563b922019-05-09 11:34:06 +010024option(BUILD_ACCURACY_TOOL "Build Accuracy Tool" OFF)
Nattapat Chaimanowong949f1252019-01-31 15:36:39 +000025option(FLATC_DIR "Path to Flatbuffers compiler" OFF)
telsoa01c577f2c2018-08-31 09:22:23 +010026option(TF_LITE_GENERATED_PATH "Tensorflow lite generated C++ schema location" OFF)
27option(FLATBUFFERS_ROOT "Location where the flatbuffers 'include' and 'lib' folders to be found" Off)
Matteo Martincighe7d44982019-08-05 12:16:47 +010028option(DYNAMIC_BACKEND_PATHS "Colon seperated list of paths where to load the dynamic backends from" "")
Colm Donelan0dbe00a2020-06-03 08:00:28 +010029option(SAMPLE_DYNAMIC_BACKEND "Include the sample dynamic backend and its tests in the build" OFF)
Colm Donelana21620d2019-10-11 13:09:49 +010030option(BUILD_GATORD_MOCK "Build the Gatord simulator for external profiling testing." ON)
Sadik Armagan6f86b692020-03-09 11:04:32 +000031option(BUILD_TIMELINE_DECODER "Build the Timeline Decoder for external profiling." ON)
Matthew Benthamb4e67202019-10-31 09:55:01 +000032option(SHARED_BOOST "Use dynamic linking for boost libraries" OFF)
Finn Williams2ed809c2020-04-20 21:21:07 +010033option(BUILD_BASE_PIPE_SERVER "Build the server to handle external profiling pipe traffic" ON)
Pavel Macenauer59e057f2020-04-15 14:17:26 +000034option(BUILD_PYTHON_WHL "Build Python wheel package" OFF)
35option(BUILD_PYTHON_SRC "Build Python source package" OFF)
telsoa014fcda012018-03-09 14:13:49 +000036
37include(SelectLibraryConfigurations)
38
39set(COMPILER_IS_GNU_LIKE 0)
40if(${CMAKE_CXX_COMPILER_ID} STREQUAL GNU OR ${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
41 set(COMPILER_IS_GNU_LIKE 1)
42endif()
43
44# Enable CCache if available and not disabled
45option(USE_CCACHE "USE_CCACHE" ON)
46find_program(CCACHE_FOUND ccache)
47if(CCACHE_FOUND AND USE_CCACHE)
48 get_property(rule_launch_compile DIRECTORY PROPERTY RULE_LAUNCH_COMPILE)
49 set_property(DIRECTORY PROPERTY RULE_LAUNCH_COMPILE "CCACHE_CPP2=yes ${rule_launch_compile} ccache")
50endif()
51
52# Enable distcc if available and not disabled
53option(USE_DISTCC "USE_DISTCC" OFF)
54find_program(DISTCC_FOUND distcc)
55if(DISTCC_FOUND AND USE_DISTCC)
56 get_property(rule_launch_compile DIRECTORY PROPERTY RULE_LAUNCH_COMPILE)
57 set_property(DIRECTORY PROPERTY RULE_LAUNCH_COMPILE "${rule_launch_compile} distcc")
58endif()
59
60# Set to release configuration by default
61if(NOT CMAKE_BUILD_TYPE)
62 set(CMAKE_BUILD_TYPE "Release")
63endif()
64
65# Compiler flags that are always set
66set(CMAKE_POSITION_INDEPENDENT_CODE ON)
67if(COMPILER_IS_GNU_LIKE)
Derek Lambertiba25aee2019-12-10 22:20:54 +000068 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -Wextra -Werror -Wold-style-cast -Wno-missing-braces -Wconversion -Wsign-conversion")
telsoa014fcda012018-03-09 14:13:49 +000069elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
Rob Hughesfc6bf052019-12-16 17:10:51 +000070 # Disable C4996 (use of deprecated identifier) due to https://developercommunity.visualstudio.com/content/problem/252574/deprecated-compilation-warning-for-virtual-overrid.html
71 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /MP /wd4996")
Rob Hughesbc873d22020-05-20 13:11:37 +010072 add_definitions(-DNO_STRICT=1)
telsoa014fcda012018-03-09 14:13:49 +000073endif()
74if("${CMAKE_SYSTEM_NAME}" STREQUAL Android)
75 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -llog")
76 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -llog")
77endif()
78
79# Compiler flags for Release builds
Matthew Benthame30054f2019-06-24 13:10:54 +010080set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG")
telsoa014fcda012018-03-09 14:13:49 +000081if(COMPILER_IS_GNU_LIKE)
82 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
83elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
84 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD /O2")
85endif()
86
87# Compiler flags for Debug builds
88if(COMPILER_IS_GNU_LIKE)
Matthew Benthame30054f2019-06-24 13:10:54 +010089 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0")
telsoa014fcda012018-03-09 14:13:49 +000090elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
Matthew Benthame30054f2019-06-24 13:10:54 +010091 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd /ZI /Od")
telsoa014fcda012018-03-09 14:13:49 +000092 # Disable SAFESEH which is necessary for Edit and Continue to work
93 set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /SAFESEH:NO")
94 set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /SAFESEH:NO")
95endif()
96
97# Modify RelWithDebInfo so that NDEBUG isn't defined.
98# This enables asserts.
99if (COMPILER_IS_GNU_LIKE)
100 string(REPLACE "-DNDEBUG" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
101elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
102 string(REPLACE "/DNDEBUG" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
103endif()
104
105# Compiler flags for code coverage measurements
106if(BUILD_FOR_COVERAGE)
107 if(NOT CMAKE_BUILD_TYPE EQUAL "Debug")
108 message(WARNING "BUILD_FOR_COVERAGE set so forcing to Debug build")
109 set(CMAKE_BUILD_TYPE "Debug")
110 endif()
111
112 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
113 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
114endif()
115
116if(BUILD_FOR_COVERAGE AND NOT BUILD_UNIT_TESTS)
117 message(WARNING "BUILD_FOR_COVERAGE set but not BUILD_UNIT_TESTS, so code coverage will not be able to run")
118endif()
119
120set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
121
122# Boost
Matthew Benthamb4e67202019-10-31 09:55:01 +0000123if(SHARED_BOOST)
124 add_definitions(-DBOOST_ALL_DYN_LINK)
125 set(Boost_USE_STATIC_LIBS OFF)
126else()
127 set(Boost_USE_STATIC_LIBS ON)
128endif()
telsoa014fcda012018-03-09 14:13:49 +0000129add_definitions("-DBOOST_ALL_NO_LIB") # Turn off auto-linking as we specify the libs manually
Francis Murtagh532a29d2020-06-29 11:50:01 +0100130find_package(Boost 1.59 REQUIRED COMPONENTS unit_test_framework filesystem system program_options)
Matthew Bentham97fb2de2019-07-12 17:26:57 +0100131include_directories(SYSTEM "${Boost_INCLUDE_DIRS}")
132link_directories(${Boost_LIBRARY_DIRS})
telsoa014fcda012018-03-09 14:13:49 +0000133
Jan Eilers7e989832020-06-19 11:47:21 +0100134# cxxopts (Alternative to boost::program_options)
135find_path(CXXOPTS_INCLUDE cxxopts/cxxopts.hpp PATHS third-party)
136include_directories(SYSTEM "${CXXOPTS_INCLUDE}")
137
Jan Eilers307fd342020-06-23 14:16:04 +0100138# ghc (Alternative to boost::filesystem)
139find_path(GHC_INCLUDE ghc/filesystem.hpp PATHS third-party)
140include_directories(SYSTEM "${GHC_INCLUDE}")
141
telsoa014fcda012018-03-09 14:13:49 +0000142# pthread
143find_package (Threads)
144
145# Favour the protobuf passed on command line
telsoa01c577f2c2018-08-31 09:22:23 +0100146if(BUILD_TF_PARSER OR BUILD_CAFFE_PARSER OR BUILD_ONNX_PARSER)
telsoa014fcda012018-03-09 14:13:49 +0000147 find_library(PROTOBUF_LIBRARY_DEBUG NAMES "protobufd"
148 PATHS ${PROTOBUF_ROOT}/lib
149 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
150 find_library(PROTOBUF_LIBRARY_DEBUG NAMES "protobufd")
151
152 find_library(PROTOBUF_LIBRARY_RELEASE NAMES "protobuf"
153 PATHS ${PROTOBUF_ROOT}/lib
154 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
155 find_library(PROTOBUF_LIBRARY_RELEASE NAMES "protobuf")
156
157 select_library_configurations(PROTOBUF)
158
159 find_path(PROTOBUF_INCLUDE_DIRS "google/protobuf/message.h"
160 PATHS ${PROTOBUF_ROOT}/include
161 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
162 find_path(PROTOBUF_INCLUDE_DIRS "google/protobuf/message.h")
163
164 include_directories(SYSTEM "${PROTOBUF_INCLUDE_DIRS}")
165 add_definitions(-DPROTOBUF_USE_DLLS)
166endif()
167
168# Caffe and its dependencies
169if(BUILD_CAFFE_PARSER)
170 add_definitions(-DARMNN_CAFFE_PARSER)
171
172 find_path(CAFFE_GENERATED_SOURCES "caffe/proto/caffe.pb.h"
173 HINTS ${CAFFE_BUILD_ROOT}/include)
174 include_directories(SYSTEM "${CAFFE_GENERATED_SOURCES}")
175endif()
176
177if(BUILD_TF_PARSER)
178 add_definitions(-DARMNN_TF_PARSER)
179
180 find_path(TF_GENERATED_SOURCES "tensorflow/core/protobuf/saved_model.pb.cc")
181
182 # C++ sources generated for tf protobufs
183 file(GLOB_RECURSE TF_PROTOBUFS "${TF_GENERATED_SOURCES}/*.pb.cc")
184
185 # C++ headers generated for tf protobufs
186 include_directories(SYSTEM "${TF_GENERATED_SOURCES}")
187endif()
188
telsoa01c577f2c2018-08-31 09:22:23 +0100189if(BUILD_ONNX_PARSER)
190 add_definitions(-DARMNN_ONNX_PARSER)
191
192 find_path(ONNX_GENERATED_SOURCES "onnx/onnx.pb.cc")
193
194 # C++ headers generated for onnx protobufs
195 include_directories(SYSTEM "${ONNX_GENERATED_SOURCES}")
196endif()
197
Nattapat Chaimanowong949f1252019-01-31 15:36:39 +0000198# Flatbuffers support for TF Lite and Armnn Serializer
199if(BUILD_TF_LITE_PARSER OR BUILD_ARMNN_SERIALIZER)
telsoa01c577f2c2018-08-31 09:22:23 +0100200 # verify we have a valid flatbuffers include path
201 find_path(FLATBUFFERS_INCLUDE_PATH flatbuffers/flatbuffers.h
202 HINTS ${FLATBUFFERS_ROOT}/include /usr/local/include /usr/include)
203
Matthew Benthamd1ae3a62019-02-22 17:30:32 +0000204 message(STATUS "Flatbuffers headers are located at: ${FLATBUFFERS_INCLUDE_PATH}")
telsoa01c577f2c2018-08-31 09:22:23 +0100205
206 find_library(FLATBUFFERS_LIBRARY
207 NAMES libflatbuffers.a flatbuffers
208 HINTS ${FLATBUFFERS_ROOT}/lib /usr/local/lib /usr/lib)
209
Matthew Benthamd1ae3a62019-02-22 17:30:32 +0000210 message(STATUS "Flatbuffers library located at: ${FLATBUFFERS_LIBRARY}")
Nattapat Chaimanowong949f1252019-01-31 15:36:39 +0000211endif()
212
213# Flatbuffers schema support for TF Lite
214if(BUILD_TF_LITE_PARSER)
215 find_path(TF_LITE_SCHEMA_INCLUDE_PATH
216 schema_generated.h
217 HINTS ${TF_LITE_GENERATED_PATH})
218
Matthew Benthamd1ae3a62019-02-22 17:30:32 +0000219 message(STATUS "Tf Lite generated header found at: ${TF_LITE_SCHEMA_INCLUDE_PATH}")
Nattapat Chaimanowong949f1252019-01-31 15:36:39 +0000220
Matthew Benthamd1ae3a62019-02-22 17:30:32 +0000221 add_definitions(-DARMNN_TF_LITE_PARSER)
telsoa01c577f2c2018-08-31 09:22:23 +0100222endif()
223
Kevin May43a799c2019-02-08 16:31:42 +0000224if(BUILD_ARMNN_SERIALIZER)
Kevin May43a799c2019-02-08 16:31:42 +0000225 add_definitions(-DARMNN_SERIALIZER)
Matthew Bentham268509a2019-02-25 13:58:24 +0000226 add_definitions(-DARMNN_SERIALIZER_SCHEMA_PATH="${CMAKE_CURRENT_SOURCE_DIR}/src/armnnSerializer/ArmnnSchema.fbs")
Kevin May43a799c2019-02-08 16:31:42 +0000227endif()
228
telsoa014fcda012018-03-09 14:13:49 +0000229include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
Sadik Armagana97a0be2020-03-03 10:44:56 +0000230include_directories(${CMAKE_CURRENT_SOURCE_DIR}/profiling)
telsoa014fcda012018-03-09 14:13:49 +0000231
232# ARM Compute
233# Note that ARM Compute has a different folder layout depending on the branch but also on
234# whether it comes from a prepackaged archive (this is why we add several hints below)
235if(ARMCOMPUTENEON OR ARMCOMPUTECL)
236 find_path(ARMCOMPUTE_INCLUDE arm_compute/core/CL/ICLKernel.h
237 PATHS ${ARMCOMPUTE_ROOT}/include
238 PATHS ${ARMCOMPUTE_ROOT}/applications/arm_compute
239 PATHS ${ARMCOMPUTE_ROOT}
240 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
241 find_path(ARMCOMPUTE_INCLUDE arm_compute/core/CL/ICLKernel.h)
242 include_directories(SYSTEM "${ARMCOMPUTE_INCLUDE}")
243
244 # Find the Arm Compute libraries if not already specified (the user may have already defined this in advance,
245 # e.g. if building clframework as a dependent cmake project)
246 if (NOT DEFINED ARMCOMPUTE_LIBRARIES)
247 # We link to the static variant so that customers don't need to find and build a compatible version of clframework.
248 # First try the folders specified ARMCOMPUTE_BUILD_DIR (with PATH_SUFFIXES for
249 # Windows builds)
Matthew Bentham2624dd72020-05-20 10:44:18 +0100250 if ((NOT DEFINED ARMCOMPUTE_BUILD_DIR) AND (DEFINED ARMCOMPUTE_ROOT))
251 # Default build directory for ComputeLibrary is under the root
252 set(ARMCOMPUTE_BUILD_DIR ${ARMCOMPUTE_ROOT}/build)
253 endif()
254
telsoa014fcda012018-03-09 14:13:49 +0000255 find_library(ARMCOMPUTE_LIBRARY_DEBUG NAMES arm_compute-static
256 PATHS ${ARMCOMPUTE_BUILD_DIR}
257 PATH_SUFFIXES "Debug"
258 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
259 find_library(ARMCOMPUTE_LIBRARY_RELEASE NAMES arm_compute-static
260 PATHS ${ARMCOMPUTE_BUILD_DIR}
261 PATH_SUFFIXES "Release"
262 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
263 find_library(ARMCOMPUTE_CORE_LIBRARY_DEBUG NAMES arm_compute_core-static
264 PATHS ${ARMCOMPUTE_BUILD_DIR}
265 PATH_SUFFIXES "Debug"
266 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
267 find_library(ARMCOMPUTE_CORE_LIBRARY_RELEASE NAMES arm_compute_core-static
268 PATHS ${ARMCOMPUTE_BUILD_DIR}
269 PATH_SUFFIXES "Release"
270 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
271
272 # In case it wasn't there, try a default search (will work in cases where
273 # the library has been installed into a standard location)
274 find_library(ARMCOMPUTE_LIBRARY_DEBUG NAMES arm_compute-static)
275 find_library(ARMCOMPUTE_LIBRARY_RELEASE NAMES arm_compute-static)
276 find_library(ARMCOMPUTE_CORE_LIBRARY_DEBUG NAMES arm_compute_core-static)
277 find_library(ARMCOMPUTE_CORE_LIBRARY_RELEASE NAMES arm_compute_core-static)
278
Matthew Bentham6445cff2020-03-10 11:13:17 +0000279 # In case it wasn't there, try the dynamic libraries
280 # This case will get used in a linux setup where the Compute Library
281 # has been installed in a standard system library path as a dynamic library
282 find_library(ARMCOMPUTE_LIBRARY_DEBUG NAMES arm_compute)
283 find_library(ARMCOMPUTE_LIBRARY_RELEASE NAMES arm_compute)
284 find_library(ARMCOMPUTE_CORE_LIBRARY_DEBUG NAMES arm_compute_core)
285 find_library(ARMCOMPUTE_CORE_LIBRARY_RELEASE NAMES arm_compute_core)
286
telsoa014fcda012018-03-09 14:13:49 +0000287 set(ARMCOMPUTE_LIBRARIES
288 debug ${ARMCOMPUTE_LIBRARY_DEBUG} ${ARMCOMPUTE_CORE_LIBRARY_DEBUG}
289 optimized ${ARMCOMPUTE_LIBRARY_RELEASE} ${ARMCOMPUTE_CORE_LIBRARY_RELEASE} )
290 endif()
291endif()
292
293# ARM Compute NEON backend
294if(ARMCOMPUTENEON)
295 # Add preprocessor definition for ARM Compute NEON
296 add_definitions(-DARMCOMPUTENEON_ENABLED)
297 # The ARM Compute headers contain some NEON intrinsics, so we need to build armnn with NEON support on armv7
298 if(${CMAKE_SYSTEM_PROCESSOR} MATCHES armv7 AND COMPILER_IS_GNU_LIKE)
299 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=neon")
300 endif()
301endif()
302
303# ARM Compute OpenCL backend
304if(ARMCOMPUTECL)
305 # Always use Arm compute library OpenCL headers
306 find_path(OPENCL_INCLUDE CL/cl2.hpp
307 PATHS ${ARMCOMPUTE_ROOT}/include
308 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
309
Matthew Bentham3b72db02018-10-11 09:47:01 +0100310 # Link against libOpenCL in opencl-1.2-stubs, but don't search there at runtime
311 link_libraries(-L${ARMCOMPUTE_BUILD_DIR}/opencl-1.2-stubs)
312 set(OPENCL_LIBRARIES OpenCL)
telsoa014fcda012018-03-09 14:13:49 +0000313
Matthew Bentham416b41d2020-02-05 22:15:26 +0000314 include_directories(SYSTEM ${OPENCL_INCLUDE})
telsoa014fcda012018-03-09 14:13:49 +0000315
316 # Add preprocessor definition for ARM Compute OpenCL
317 add_definitions(-DARMCOMPUTECL_ENABLED)
318
319 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DARM_COMPUTE_DEBUG_ENABLED")
320endif()
321
322# Used by both Arm Compute backends, but should be added
323# to the search path after the system directories if necessary
324if(ARMCOMPUTENEON OR ARMCOMPUTECL)
325 find_path(HALF_INCLUDE half/half.hpp)
326 find_path(HALF_INCLUDE half/half.hpp
327 PATHS ${ARMCOMPUTE_ROOT}/include
328 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
telsoa01c577f2c2018-08-31 09:22:23 +0100329 include_directories(SYSTEM ${HALF_INCLUDE})
telsoa014fcda012018-03-09 14:13:49 +0000330endif()
331
Matteo Martincighdb16dd32019-08-27 16:41:11 +0100332# ArmNN reference backend
333if(ARMNNREF)
334 add_definitions(-DARMNNREF_ENABLED)
Matteo Martincighe67edb22019-08-14 14:05:46 +0100335endif()
336
Colm Donelanaa93d982020-06-28 08:16:46 +0100337# This is the root for the dynamic backend tests to search for dynamic
338# backends. By default it will be the project build directory.
339add_definitions('-DDYNAMIC_BACKEND_BUILD_DIR="${PROJECT_BINARY_DIR}"')
340
Narumol Prangnawarat60a20fb2019-12-09 17:24:41 +0000341# ArmNN dynamic backend
342if(DYNAMIC_BACKEND_PATHS)
343 add_definitions(-DARMNN_DYNAMIC_BACKEND_ENABLED)
344endif()
345
Narumol Prangnawarat867eba52020-02-03 12:29:56 +0000346if(SAMPLE_DYNAMIC_BACKEND)
347 add_definitions(-DSAMPLE_DYNAMIC_BACKEND_ENABLED)
348endif()
349
telsoa014fcda012018-03-09 14:13:49 +0000350# Streamline annotate
351if(PROFILING_BACKEND_STREAMLINE)
352 include_directories("${GATOR_ROOT}/annotate")
353 add_definitions(-DARMNN_STREAMLINE_ENABLED)
354endif()
355
telsoa01c577f2c2018-08-31 09:22:23 +0100356if(HEAP_PROFILING OR LEAK_CHECKING)
surmeh013537c2c2018-05-18 16:31:43 +0100357 # enable heap profiling for everything except for referencetests
358 if(NOT ${PROJECT_NAME} STREQUAL "referencetests")
359 find_path(HEAP_PROFILER_INCLUDE gperftools/heap-profiler.h
360 PATHS ${GPERFTOOLS_ROOT}/include
361 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
362 include_directories(SYSTEM "${HEAP_PROFILER_INCLUDE}")
363 find_library(GPERF_TOOLS_LIBRARY
364 NAMES tcmalloc_debug
365 HINTS ${GPERFTOOLS_ROOT}/lib)
366 link_directories(${GPERFTOOLS_ROOT}/lib)
367
368 link_libraries(${GPERF_TOOLS_LIBRARY})
telsoa01c577f2c2018-08-31 09:22:23 +0100369 if (HEAP_PROFILING)
370 add_definitions("-DARMNN_HEAP_PROFILING_ENABLED=1")
371 endif()
372 if (LEAK_CHECKING)
373 add_definitions("-DARMNN_LEAK_CHECKING_ENABLED=1")
374 endif()
surmeh013537c2c2018-05-18 16:31:43 +0100375 else()
Rob Hughes721b82f2019-11-15 09:04:17 +0000376 message(STATUS "Heap profiling and leak checking are disabled for referencetests")
surmeh013537c2c2018-05-18 16:31:43 +0100377 endif()
378else()
379 # Valgrind only works with gperftools version number <= 2.4
380 CHECK_INCLUDE_FILE(valgrind/memcheck.h VALGRIND_FOUND)
381endif()
382
383
384if(NOT BUILD_CAFFE_PARSER)
385 message(STATUS "Caffe parser support is disabled")
386endif()
387
388if(NOT BUILD_TF_PARSER)
389 message(STATUS "Tensorflow parser support is disabled")
390endif()
391
telsoa01c577f2c2018-08-31 09:22:23 +0100392if(NOT BUILD_TF_LITE_PARSER)
393 message(STATUS "Tensorflow Lite parser support is disabled")
394endif()
David Beck10b4dfd2018-09-19 12:03:20 +0100395
Nattapat Chaimanowong949f1252019-01-31 15:36:39 +0000396if(NOT BUILD_ARMNN_SERIALIZER)
397 message(STATUS "Armnn Serializer support is disabled")
398endif()
399
Jim Flynn3091b062019-02-15 14:45:04 +0000400if(NOT BUILD_ARMNN_QUANTIZER)
401 message(STATUS "ArmNN Quantizer support is disabled")
402endif()
403
Pavel Macenauer59e057f2020-04-15 14:17:26 +0000404if(NOT BUILD_PYTHON_WHL)
405 message(STATUS "PyArmNN wheel package is disabled")
406endif()
407
408if(NOT BUILD_PYTHON_SRC)
409 message(STATUS "PyArmNN source package is disabled")
410endif()
411
412if(BUILD_PYTHON_WHL OR BUILD_PYTHON_SRC)
413 find_package(PythonInterp 3 REQUIRED)
414 if(NOT ${PYTHONINTERP_FOUND})
415 message(FATAL_ERROR "Python 3.x required to build PyArmNN, but not found")
416 endif()
417
418 find_package(PythonLibs 3 REQUIRED)
419 if(NOT ${PYTHONLIBS_FOUND})
420 message(FATAL_ERROR "Python 3.x development package required to build PyArmNN, but not found")
421 endif()
422
423 find_package(SWIG 4 REQUIRED)
424 if(NOT ${SWIG_FOUND})
425 message(FATAL_ERROR "SWIG 4.x requried to build PyArmNN, but not found")
426 endif()
427endif()
428
David Beck10b4dfd2018-09-19 12:03:20 +0100429# ArmNN source files required for all build options
430include_directories(SYSTEM third-party)