blob: 142e5369128f09d927d176c01e085e6dfa71ef0f [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)
Jim Flynn82262f52020-07-16 11:23:45 +010040if(${CMAKE_CXX_COMPILER_ID} STREQUAL GNU OR
41 ${CMAKE_CXX_COMPILER_ID} STREQUAL Clang OR
42 ${CMAKE_CXX_COMPILER_ID} STREQUAL AppleClang)
telsoa014fcda012018-03-09 14:13:49 +000043 set(COMPILER_IS_GNU_LIKE 1)
44endif()
45
46# Enable CCache if available and not disabled
47option(USE_CCACHE "USE_CCACHE" ON)
48find_program(CCACHE_FOUND ccache)
49if(CCACHE_FOUND AND USE_CCACHE)
50 get_property(rule_launch_compile DIRECTORY PROPERTY RULE_LAUNCH_COMPILE)
51 set_property(DIRECTORY PROPERTY RULE_LAUNCH_COMPILE "CCACHE_CPP2=yes ${rule_launch_compile} ccache")
52endif()
53
54# Enable distcc if available and not disabled
55option(USE_DISTCC "USE_DISTCC" OFF)
56find_program(DISTCC_FOUND distcc)
57if(DISTCC_FOUND AND USE_DISTCC)
58 get_property(rule_launch_compile DIRECTORY PROPERTY RULE_LAUNCH_COMPILE)
59 set_property(DIRECTORY PROPERTY RULE_LAUNCH_COMPILE "${rule_launch_compile} distcc")
60endif()
61
62# Set to release configuration by default
63if(NOT CMAKE_BUILD_TYPE)
64 set(CMAKE_BUILD_TYPE "Release")
65endif()
66
67# Compiler flags that are always set
68set(CMAKE_POSITION_INDEPENDENT_CODE ON)
69if(COMPILER_IS_GNU_LIKE)
Derek Lambertiba25aee2019-12-10 22:20:54 +000070 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 +000071elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
Rob Hughesfc6bf052019-12-16 17:10:51 +000072 # Disable C4996 (use of deprecated identifier) due to https://developercommunity.visualstudio.com/content/problem/252574/deprecated-compilation-warning-for-virtual-overrid.html
73 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /MP /wd4996")
Rob Hughesbc873d22020-05-20 13:11:37 +010074 add_definitions(-DNO_STRICT=1)
telsoa014fcda012018-03-09 14:13:49 +000075endif()
76if("${CMAKE_SYSTEM_NAME}" STREQUAL Android)
77 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -llog")
78 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -llog")
79endif()
80
81# Compiler flags for Release builds
Matthew Benthame30054f2019-06-24 13:10:54 +010082set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG")
telsoa014fcda012018-03-09 14:13:49 +000083if(COMPILER_IS_GNU_LIKE)
84 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
85elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
86 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD /O2")
87endif()
88
89# Compiler flags for Debug builds
90if(COMPILER_IS_GNU_LIKE)
Matthew Benthame30054f2019-06-24 13:10:54 +010091 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0")
telsoa014fcda012018-03-09 14:13:49 +000092elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
Matthew Benthame30054f2019-06-24 13:10:54 +010093 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd /ZI /Od")
telsoa014fcda012018-03-09 14:13:49 +000094 # Disable SAFESEH which is necessary for Edit and Continue to work
95 set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /SAFESEH:NO")
96 set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /SAFESEH:NO")
97endif()
98
99# Modify RelWithDebInfo so that NDEBUG isn't defined.
100# This enables asserts.
101if (COMPILER_IS_GNU_LIKE)
102 string(REPLACE "-DNDEBUG" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
103elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
104 string(REPLACE "/DNDEBUG" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
105endif()
106
107# Compiler flags for code coverage measurements
108if(BUILD_FOR_COVERAGE)
109 if(NOT CMAKE_BUILD_TYPE EQUAL "Debug")
110 message(WARNING "BUILD_FOR_COVERAGE set so forcing to Debug build")
111 set(CMAKE_BUILD_TYPE "Debug")
112 endif()
113
114 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
115 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
116endif()
117
118if(BUILD_FOR_COVERAGE AND NOT BUILD_UNIT_TESTS)
119 message(WARNING "BUILD_FOR_COVERAGE set but not BUILD_UNIT_TESTS, so code coverage will not be able to run")
120endif()
121
122set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
123
124# Boost
Matthew Benthamb4e67202019-10-31 09:55:01 +0000125if(SHARED_BOOST)
126 add_definitions(-DBOOST_ALL_DYN_LINK)
127 set(Boost_USE_STATIC_LIBS OFF)
128else()
129 set(Boost_USE_STATIC_LIBS ON)
130endif()
telsoa014fcda012018-03-09 14:13:49 +0000131add_definitions("-DBOOST_ALL_NO_LIB") # Turn off auto-linking as we specify the libs manually
Francis Murtagh532a29d2020-06-29 11:50:01 +0100132find_package(Boost 1.59 REQUIRED COMPONENTS unit_test_framework filesystem system program_options)
Matthew Bentham97fb2de2019-07-12 17:26:57 +0100133include_directories(SYSTEM "${Boost_INCLUDE_DIRS}")
134link_directories(${Boost_LIBRARY_DIRS})
telsoa014fcda012018-03-09 14:13:49 +0000135
Jan Eilers7e989832020-06-19 11:47:21 +0100136# cxxopts (Alternative to boost::program_options)
137find_path(CXXOPTS_INCLUDE cxxopts/cxxopts.hpp PATHS third-party)
138include_directories(SYSTEM "${CXXOPTS_INCLUDE}")
139
Jan Eilers307fd342020-06-23 14:16:04 +0100140# ghc (Alternative to boost::filesystem)
141find_path(GHC_INCLUDE ghc/filesystem.hpp PATHS third-party)
142include_directories(SYSTEM "${GHC_INCLUDE}")
143
telsoa014fcda012018-03-09 14:13:49 +0000144# pthread
145find_package (Threads)
146
147# Favour the protobuf passed on command line
telsoa01c577f2c2018-08-31 09:22:23 +0100148if(BUILD_TF_PARSER OR BUILD_CAFFE_PARSER OR BUILD_ONNX_PARSER)
telsoa014fcda012018-03-09 14:13:49 +0000149 find_library(PROTOBUF_LIBRARY_DEBUG NAMES "protobufd"
150 PATHS ${PROTOBUF_ROOT}/lib
151 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
152 find_library(PROTOBUF_LIBRARY_DEBUG NAMES "protobufd")
153
154 find_library(PROTOBUF_LIBRARY_RELEASE NAMES "protobuf"
155 PATHS ${PROTOBUF_ROOT}/lib
156 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
157 find_library(PROTOBUF_LIBRARY_RELEASE NAMES "protobuf")
158
159 select_library_configurations(PROTOBUF)
160
161 find_path(PROTOBUF_INCLUDE_DIRS "google/protobuf/message.h"
162 PATHS ${PROTOBUF_ROOT}/include
163 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
164 find_path(PROTOBUF_INCLUDE_DIRS "google/protobuf/message.h")
165
166 include_directories(SYSTEM "${PROTOBUF_INCLUDE_DIRS}")
167 add_definitions(-DPROTOBUF_USE_DLLS)
168endif()
169
170# Caffe and its dependencies
171if(BUILD_CAFFE_PARSER)
172 add_definitions(-DARMNN_CAFFE_PARSER)
173
174 find_path(CAFFE_GENERATED_SOURCES "caffe/proto/caffe.pb.h"
175 HINTS ${CAFFE_BUILD_ROOT}/include)
176 include_directories(SYSTEM "${CAFFE_GENERATED_SOURCES}")
177endif()
178
179if(BUILD_TF_PARSER)
180 add_definitions(-DARMNN_TF_PARSER)
181
182 find_path(TF_GENERATED_SOURCES "tensorflow/core/protobuf/saved_model.pb.cc")
183
184 # C++ sources generated for tf protobufs
185 file(GLOB_RECURSE TF_PROTOBUFS "${TF_GENERATED_SOURCES}/*.pb.cc")
186
187 # C++ headers generated for tf protobufs
188 include_directories(SYSTEM "${TF_GENERATED_SOURCES}")
189endif()
190
telsoa01c577f2c2018-08-31 09:22:23 +0100191if(BUILD_ONNX_PARSER)
192 add_definitions(-DARMNN_ONNX_PARSER)
193
194 find_path(ONNX_GENERATED_SOURCES "onnx/onnx.pb.cc")
195
196 # C++ headers generated for onnx protobufs
197 include_directories(SYSTEM "${ONNX_GENERATED_SOURCES}")
198endif()
199
Nattapat Chaimanowong949f1252019-01-31 15:36:39 +0000200# Flatbuffers support for TF Lite and Armnn Serializer
201if(BUILD_TF_LITE_PARSER OR BUILD_ARMNN_SERIALIZER)
telsoa01c577f2c2018-08-31 09:22:23 +0100202 # verify we have a valid flatbuffers include path
203 find_path(FLATBUFFERS_INCLUDE_PATH flatbuffers/flatbuffers.h
204 HINTS ${FLATBUFFERS_ROOT}/include /usr/local/include /usr/include)
205
Matthew Benthamd1ae3a62019-02-22 17:30:32 +0000206 message(STATUS "Flatbuffers headers are located at: ${FLATBUFFERS_INCLUDE_PATH}")
telsoa01c577f2c2018-08-31 09:22:23 +0100207
208 find_library(FLATBUFFERS_LIBRARY
209 NAMES libflatbuffers.a flatbuffers
210 HINTS ${FLATBUFFERS_ROOT}/lib /usr/local/lib /usr/lib)
211
Matthew Benthamd1ae3a62019-02-22 17:30:32 +0000212 message(STATUS "Flatbuffers library located at: ${FLATBUFFERS_LIBRARY}")
Nattapat Chaimanowong949f1252019-01-31 15:36:39 +0000213endif()
214
215# Flatbuffers schema support for TF Lite
216if(BUILD_TF_LITE_PARSER)
217 find_path(TF_LITE_SCHEMA_INCLUDE_PATH
218 schema_generated.h
219 HINTS ${TF_LITE_GENERATED_PATH})
220
Matthew Benthamd1ae3a62019-02-22 17:30:32 +0000221 message(STATUS "Tf Lite generated header found at: ${TF_LITE_SCHEMA_INCLUDE_PATH}")
Nattapat Chaimanowong949f1252019-01-31 15:36:39 +0000222
Matthew Benthamd1ae3a62019-02-22 17:30:32 +0000223 add_definitions(-DARMNN_TF_LITE_PARSER)
telsoa01c577f2c2018-08-31 09:22:23 +0100224endif()
225
Kevin May43a799c2019-02-08 16:31:42 +0000226if(BUILD_ARMNN_SERIALIZER)
Kevin May43a799c2019-02-08 16:31:42 +0000227 add_definitions(-DARMNN_SERIALIZER)
Matthew Bentham268509a2019-02-25 13:58:24 +0000228 add_definitions(-DARMNN_SERIALIZER_SCHEMA_PATH="${CMAKE_CURRENT_SOURCE_DIR}/src/armnnSerializer/ArmnnSchema.fbs")
Kevin May43a799c2019-02-08 16:31:42 +0000229endif()
230
telsoa014fcda012018-03-09 14:13:49 +0000231include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
Sadik Armagana97a0be2020-03-03 10:44:56 +0000232include_directories(${CMAKE_CURRENT_SOURCE_DIR}/profiling)
telsoa014fcda012018-03-09 14:13:49 +0000233
234# ARM Compute
235# Note that ARM Compute has a different folder layout depending on the branch but also on
236# whether it comes from a prepackaged archive (this is why we add several hints below)
237if(ARMCOMPUTENEON OR ARMCOMPUTECL)
238 find_path(ARMCOMPUTE_INCLUDE arm_compute/core/CL/ICLKernel.h
239 PATHS ${ARMCOMPUTE_ROOT}/include
240 PATHS ${ARMCOMPUTE_ROOT}/applications/arm_compute
241 PATHS ${ARMCOMPUTE_ROOT}
242 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
243 find_path(ARMCOMPUTE_INCLUDE arm_compute/core/CL/ICLKernel.h)
244 include_directories(SYSTEM "${ARMCOMPUTE_INCLUDE}")
245
246 # Find the Arm Compute libraries if not already specified (the user may have already defined this in advance,
247 # e.g. if building clframework as a dependent cmake project)
248 if (NOT DEFINED ARMCOMPUTE_LIBRARIES)
249 # We link to the static variant so that customers don't need to find and build a compatible version of clframework.
250 # First try the folders specified ARMCOMPUTE_BUILD_DIR (with PATH_SUFFIXES for
251 # Windows builds)
Matthew Bentham2624dd72020-05-20 10:44:18 +0100252 if ((NOT DEFINED ARMCOMPUTE_BUILD_DIR) AND (DEFINED ARMCOMPUTE_ROOT))
253 # Default build directory for ComputeLibrary is under the root
254 set(ARMCOMPUTE_BUILD_DIR ${ARMCOMPUTE_ROOT}/build)
255 endif()
256
telsoa014fcda012018-03-09 14:13:49 +0000257 find_library(ARMCOMPUTE_LIBRARY_DEBUG NAMES arm_compute-static
258 PATHS ${ARMCOMPUTE_BUILD_DIR}
259 PATH_SUFFIXES "Debug"
260 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
261 find_library(ARMCOMPUTE_LIBRARY_RELEASE NAMES arm_compute-static
262 PATHS ${ARMCOMPUTE_BUILD_DIR}
263 PATH_SUFFIXES "Release"
264 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
265 find_library(ARMCOMPUTE_CORE_LIBRARY_DEBUG NAMES arm_compute_core-static
266 PATHS ${ARMCOMPUTE_BUILD_DIR}
267 PATH_SUFFIXES "Debug"
268 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
269 find_library(ARMCOMPUTE_CORE_LIBRARY_RELEASE NAMES arm_compute_core-static
270 PATHS ${ARMCOMPUTE_BUILD_DIR}
271 PATH_SUFFIXES "Release"
272 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
273
274 # In case it wasn't there, try a default search (will work in cases where
275 # the library has been installed into a standard location)
276 find_library(ARMCOMPUTE_LIBRARY_DEBUG NAMES arm_compute-static)
277 find_library(ARMCOMPUTE_LIBRARY_RELEASE NAMES arm_compute-static)
278 find_library(ARMCOMPUTE_CORE_LIBRARY_DEBUG NAMES arm_compute_core-static)
279 find_library(ARMCOMPUTE_CORE_LIBRARY_RELEASE NAMES arm_compute_core-static)
280
Matthew Bentham6445cff2020-03-10 11:13:17 +0000281 # In case it wasn't there, try the dynamic libraries
282 # This case will get used in a linux setup where the Compute Library
283 # has been installed in a standard system library path as a dynamic library
284 find_library(ARMCOMPUTE_LIBRARY_DEBUG NAMES arm_compute)
285 find_library(ARMCOMPUTE_LIBRARY_RELEASE NAMES arm_compute)
286 find_library(ARMCOMPUTE_CORE_LIBRARY_DEBUG NAMES arm_compute_core)
287 find_library(ARMCOMPUTE_CORE_LIBRARY_RELEASE NAMES arm_compute_core)
288
telsoa014fcda012018-03-09 14:13:49 +0000289 set(ARMCOMPUTE_LIBRARIES
290 debug ${ARMCOMPUTE_LIBRARY_DEBUG} ${ARMCOMPUTE_CORE_LIBRARY_DEBUG}
291 optimized ${ARMCOMPUTE_LIBRARY_RELEASE} ${ARMCOMPUTE_CORE_LIBRARY_RELEASE} )
292 endif()
293endif()
294
295# ARM Compute NEON backend
296if(ARMCOMPUTENEON)
297 # Add preprocessor definition for ARM Compute NEON
298 add_definitions(-DARMCOMPUTENEON_ENABLED)
299 # The ARM Compute headers contain some NEON intrinsics, so we need to build armnn with NEON support on armv7
300 if(${CMAKE_SYSTEM_PROCESSOR} MATCHES armv7 AND COMPILER_IS_GNU_LIKE)
301 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=neon")
302 endif()
303endif()
304
305# ARM Compute OpenCL backend
306if(ARMCOMPUTECL)
307 # Always use Arm compute library OpenCL headers
308 find_path(OPENCL_INCLUDE CL/cl2.hpp
309 PATHS ${ARMCOMPUTE_ROOT}/include
310 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
311
Matthew Bentham3b72db02018-10-11 09:47:01 +0100312 # Link against libOpenCL in opencl-1.2-stubs, but don't search there at runtime
313 link_libraries(-L${ARMCOMPUTE_BUILD_DIR}/opencl-1.2-stubs)
314 set(OPENCL_LIBRARIES OpenCL)
telsoa014fcda012018-03-09 14:13:49 +0000315
Matthew Bentham416b41d2020-02-05 22:15:26 +0000316 include_directories(SYSTEM ${OPENCL_INCLUDE})
telsoa014fcda012018-03-09 14:13:49 +0000317
318 # Add preprocessor definition for ARM Compute OpenCL
319 add_definitions(-DARMCOMPUTECL_ENABLED)
320
321 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DARM_COMPUTE_DEBUG_ENABLED")
322endif()
323
324# Used by both Arm Compute backends, but should be added
325# to the search path after the system directories if necessary
326if(ARMCOMPUTENEON OR ARMCOMPUTECL)
327 find_path(HALF_INCLUDE half/half.hpp)
328 find_path(HALF_INCLUDE half/half.hpp
329 PATHS ${ARMCOMPUTE_ROOT}/include
330 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
telsoa01c577f2c2018-08-31 09:22:23 +0100331 include_directories(SYSTEM ${HALF_INCLUDE})
telsoa014fcda012018-03-09 14:13:49 +0000332endif()
333
Matteo Martincighdb16dd32019-08-27 16:41:11 +0100334# ArmNN reference backend
335if(ARMNNREF)
336 add_definitions(-DARMNNREF_ENABLED)
Matteo Martincighe67edb22019-08-14 14:05:46 +0100337endif()
338
Colm Donelanaa93d982020-06-28 08:16:46 +0100339# This is the root for the dynamic backend tests to search for dynamic
340# backends. By default it will be the project build directory.
341add_definitions('-DDYNAMIC_BACKEND_BUILD_DIR="${PROJECT_BINARY_DIR}"')
342
Narumol Prangnawarat60a20fb2019-12-09 17:24:41 +0000343# ArmNN dynamic backend
344if(DYNAMIC_BACKEND_PATHS)
345 add_definitions(-DARMNN_DYNAMIC_BACKEND_ENABLED)
346endif()
347
Narumol Prangnawarat867eba52020-02-03 12:29:56 +0000348if(SAMPLE_DYNAMIC_BACKEND)
349 add_definitions(-DSAMPLE_DYNAMIC_BACKEND_ENABLED)
350endif()
351
telsoa014fcda012018-03-09 14:13:49 +0000352# Streamline annotate
353if(PROFILING_BACKEND_STREAMLINE)
354 include_directories("${GATOR_ROOT}/annotate")
355 add_definitions(-DARMNN_STREAMLINE_ENABLED)
356endif()
357
telsoa01c577f2c2018-08-31 09:22:23 +0100358if(HEAP_PROFILING OR LEAK_CHECKING)
surmeh013537c2c2018-05-18 16:31:43 +0100359 # enable heap profiling for everything except for referencetests
360 if(NOT ${PROJECT_NAME} STREQUAL "referencetests")
361 find_path(HEAP_PROFILER_INCLUDE gperftools/heap-profiler.h
362 PATHS ${GPERFTOOLS_ROOT}/include
363 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
364 include_directories(SYSTEM "${HEAP_PROFILER_INCLUDE}")
365 find_library(GPERF_TOOLS_LIBRARY
366 NAMES tcmalloc_debug
367 HINTS ${GPERFTOOLS_ROOT}/lib)
368 link_directories(${GPERFTOOLS_ROOT}/lib)
369
370 link_libraries(${GPERF_TOOLS_LIBRARY})
telsoa01c577f2c2018-08-31 09:22:23 +0100371 if (HEAP_PROFILING)
372 add_definitions("-DARMNN_HEAP_PROFILING_ENABLED=1")
373 endif()
374 if (LEAK_CHECKING)
375 add_definitions("-DARMNN_LEAK_CHECKING_ENABLED=1")
376 endif()
surmeh013537c2c2018-05-18 16:31:43 +0100377 else()
Rob Hughes721b82f2019-11-15 09:04:17 +0000378 message(STATUS "Heap profiling and leak checking are disabled for referencetests")
surmeh013537c2c2018-05-18 16:31:43 +0100379 endif()
380else()
381 # Valgrind only works with gperftools version number <= 2.4
382 CHECK_INCLUDE_FILE(valgrind/memcheck.h VALGRIND_FOUND)
383endif()
384
385
386if(NOT BUILD_CAFFE_PARSER)
387 message(STATUS "Caffe parser support is disabled")
388endif()
389
390if(NOT BUILD_TF_PARSER)
391 message(STATUS "Tensorflow parser support is disabled")
392endif()
393
telsoa01c577f2c2018-08-31 09:22:23 +0100394if(NOT BUILD_TF_LITE_PARSER)
395 message(STATUS "Tensorflow Lite parser support is disabled")
396endif()
David Beck10b4dfd2018-09-19 12:03:20 +0100397
Nattapat Chaimanowong949f1252019-01-31 15:36:39 +0000398if(NOT BUILD_ARMNN_SERIALIZER)
399 message(STATUS "Armnn Serializer support is disabled")
400endif()
401
Jim Flynn3091b062019-02-15 14:45:04 +0000402if(NOT BUILD_ARMNN_QUANTIZER)
403 message(STATUS "ArmNN Quantizer support is disabled")
404endif()
405
Pavel Macenauer59e057f2020-04-15 14:17:26 +0000406if(NOT BUILD_PYTHON_WHL)
407 message(STATUS "PyArmNN wheel package is disabled")
408endif()
409
410if(NOT BUILD_PYTHON_SRC)
411 message(STATUS "PyArmNN source package is disabled")
412endif()
413
414if(BUILD_PYTHON_WHL OR BUILD_PYTHON_SRC)
415 find_package(PythonInterp 3 REQUIRED)
416 if(NOT ${PYTHONINTERP_FOUND})
417 message(FATAL_ERROR "Python 3.x required to build PyArmNN, but not found")
418 endif()
419
420 find_package(PythonLibs 3 REQUIRED)
421 if(NOT ${PYTHONLIBS_FOUND})
422 message(FATAL_ERROR "Python 3.x development package required to build PyArmNN, but not found")
423 endif()
424
425 find_package(SWIG 4 REQUIRED)
426 if(NOT ${SWIG_FOUND})
427 message(FATAL_ERROR "SWIG 4.x requried to build PyArmNN, but not found")
428 endif()
429endif()
430
David Beck10b4dfd2018-09-19 12:03:20 +0100431# ArmNN source files required for all build options
432include_directories(SYSTEM third-party)