blob: 4e20cc7da5e6085a00ae501e2f3b45d3216240c9 [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 Donelana21620d2019-10-11 13:09:49 +010029option(BUILD_GATORD_MOCK "Build the Gatord simulator for external profiling testing." ON)
Sadik Armagan6f86b692020-03-09 11:04:32 +000030option(BUILD_TIMELINE_DECODER "Build the Timeline Decoder for external profiling." ON)
Matthew Benthamb4e67202019-10-31 09:55:01 +000031option(SHARED_BOOST "Use dynamic linking for boost libraries" OFF)
Finn Williams2ed809c2020-04-20 21:21:07 +010032option(BUILD_BASE_PIPE_SERVER "Build the server to handle external profiling pipe traffic" ON)
Pavel Macenauer59e057f2020-04-15 14:17:26 +000033option(BUILD_PYTHON_WHL "Build Python wheel package" OFF)
34option(BUILD_PYTHON_SRC "Build Python source package" OFF)
telsoa014fcda012018-03-09 14:13:49 +000035
36include(SelectLibraryConfigurations)
37
38set(COMPILER_IS_GNU_LIKE 0)
39if(${CMAKE_CXX_COMPILER_ID} STREQUAL GNU OR ${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
40 set(COMPILER_IS_GNU_LIKE 1)
41endif()
42
43# Enable CCache if available and not disabled
44option(USE_CCACHE "USE_CCACHE" ON)
45find_program(CCACHE_FOUND ccache)
46if(CCACHE_FOUND AND USE_CCACHE)
47 get_property(rule_launch_compile DIRECTORY PROPERTY RULE_LAUNCH_COMPILE)
48 set_property(DIRECTORY PROPERTY RULE_LAUNCH_COMPILE "CCACHE_CPP2=yes ${rule_launch_compile} ccache")
49endif()
50
51# Enable distcc if available and not disabled
52option(USE_DISTCC "USE_DISTCC" OFF)
53find_program(DISTCC_FOUND distcc)
54if(DISTCC_FOUND AND USE_DISTCC)
55 get_property(rule_launch_compile DIRECTORY PROPERTY RULE_LAUNCH_COMPILE)
56 set_property(DIRECTORY PROPERTY RULE_LAUNCH_COMPILE "${rule_launch_compile} distcc")
57endif()
58
59# Set to release configuration by default
60if(NOT CMAKE_BUILD_TYPE)
61 set(CMAKE_BUILD_TYPE "Release")
62endif()
63
64# Compiler flags that are always set
65set(CMAKE_POSITION_INDEPENDENT_CODE ON)
66if(COMPILER_IS_GNU_LIKE)
Derek Lambertiba25aee2019-12-10 22:20:54 +000067 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 +000068elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
Rob Hughesfc6bf052019-12-16 17:10:51 +000069 # Disable C4996 (use of deprecated identifier) due to https://developercommunity.visualstudio.com/content/problem/252574/deprecated-compilation-warning-for-virtual-overrid.html
70 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /MP /wd4996")
telsoa014fcda012018-03-09 14:13:49 +000071 add_definitions(-DNOMINMAX=1 -DNO_STRICT=1)
72endif()
73if("${CMAKE_SYSTEM_NAME}" STREQUAL Android)
74 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -llog")
75 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -llog")
76endif()
77
78# Compiler flags for Release builds
Matthew Benthame30054f2019-06-24 13:10:54 +010079set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG")
telsoa014fcda012018-03-09 14:13:49 +000080if(COMPILER_IS_GNU_LIKE)
81 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
82elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
83 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD /O2")
84endif()
85
86# Compiler flags for Debug builds
87if(COMPILER_IS_GNU_LIKE)
Matthew Benthame30054f2019-06-24 13:10:54 +010088 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0")
telsoa014fcda012018-03-09 14:13:49 +000089elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
Matthew Benthame30054f2019-06-24 13:10:54 +010090 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd /ZI /Od")
telsoa014fcda012018-03-09 14:13:49 +000091 # Disable SAFESEH which is necessary for Edit and Continue to work
92 set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /SAFESEH:NO")
93 set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /SAFESEH:NO")
94endif()
95
96# Modify RelWithDebInfo so that NDEBUG isn't defined.
97# This enables asserts.
98if (COMPILER_IS_GNU_LIKE)
99 string(REPLACE "-DNDEBUG" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
100elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
101 string(REPLACE "/DNDEBUG" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
102endif()
103
104# Compiler flags for code coverage measurements
105if(BUILD_FOR_COVERAGE)
106 if(NOT CMAKE_BUILD_TYPE EQUAL "Debug")
107 message(WARNING "BUILD_FOR_COVERAGE set so forcing to Debug build")
108 set(CMAKE_BUILD_TYPE "Debug")
109 endif()
110
111 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
112 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
113endif()
114
115if(BUILD_FOR_COVERAGE AND NOT BUILD_UNIT_TESTS)
116 message(WARNING "BUILD_FOR_COVERAGE set but not BUILD_UNIT_TESTS, so code coverage will not be able to run")
117endif()
118
119set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
120
121# Boost
Matthew Benthamb4e67202019-10-31 09:55:01 +0000122if(SHARED_BOOST)
123 add_definitions(-DBOOST_ALL_DYN_LINK)
124 set(Boost_USE_STATIC_LIBS OFF)
125else()
126 set(Boost_USE_STATIC_LIBS ON)
127endif()
telsoa014fcda012018-03-09 14:13:49 +0000128add_definitions("-DBOOST_ALL_NO_LIB") # Turn off auto-linking as we specify the libs manually
Francis Murtaghf8ac8292019-12-19 11:35:55 +0000129find_package(Boost 1.59 REQUIRED COMPONENTS unit_test_framework system filesystem program_options)
Matthew Bentham97fb2de2019-07-12 17:26:57 +0100130include_directories(SYSTEM "${Boost_INCLUDE_DIRS}")
131link_directories(${Boost_LIBRARY_DIRS})
telsoa014fcda012018-03-09 14:13:49 +0000132
133# pthread
134find_package (Threads)
135
136# Favour the protobuf passed on command line
telsoa01c577f2c2018-08-31 09:22:23 +0100137if(BUILD_TF_PARSER OR BUILD_CAFFE_PARSER OR BUILD_ONNX_PARSER)
telsoa014fcda012018-03-09 14:13:49 +0000138 find_library(PROTOBUF_LIBRARY_DEBUG NAMES "protobufd"
139 PATHS ${PROTOBUF_ROOT}/lib
140 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
141 find_library(PROTOBUF_LIBRARY_DEBUG NAMES "protobufd")
142
143 find_library(PROTOBUF_LIBRARY_RELEASE NAMES "protobuf"
144 PATHS ${PROTOBUF_ROOT}/lib
145 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
146 find_library(PROTOBUF_LIBRARY_RELEASE NAMES "protobuf")
147
148 select_library_configurations(PROTOBUF)
149
150 find_path(PROTOBUF_INCLUDE_DIRS "google/protobuf/message.h"
151 PATHS ${PROTOBUF_ROOT}/include
152 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
153 find_path(PROTOBUF_INCLUDE_DIRS "google/protobuf/message.h")
154
155 include_directories(SYSTEM "${PROTOBUF_INCLUDE_DIRS}")
156 add_definitions(-DPROTOBUF_USE_DLLS)
157endif()
158
159# Caffe and its dependencies
160if(BUILD_CAFFE_PARSER)
161 add_definitions(-DARMNN_CAFFE_PARSER)
162
163 find_path(CAFFE_GENERATED_SOURCES "caffe/proto/caffe.pb.h"
164 HINTS ${CAFFE_BUILD_ROOT}/include)
165 include_directories(SYSTEM "${CAFFE_GENERATED_SOURCES}")
166endif()
167
168if(BUILD_TF_PARSER)
169 add_definitions(-DARMNN_TF_PARSER)
170
171 find_path(TF_GENERATED_SOURCES "tensorflow/core/protobuf/saved_model.pb.cc")
172
173 # C++ sources generated for tf protobufs
174 file(GLOB_RECURSE TF_PROTOBUFS "${TF_GENERATED_SOURCES}/*.pb.cc")
175
176 # C++ headers generated for tf protobufs
177 include_directories(SYSTEM "${TF_GENERATED_SOURCES}")
178endif()
179
telsoa01c577f2c2018-08-31 09:22:23 +0100180if(BUILD_ONNX_PARSER)
181 add_definitions(-DARMNN_ONNX_PARSER)
182
183 find_path(ONNX_GENERATED_SOURCES "onnx/onnx.pb.cc")
184
185 # C++ headers generated for onnx protobufs
186 include_directories(SYSTEM "${ONNX_GENERATED_SOURCES}")
187endif()
188
Nattapat Chaimanowong949f1252019-01-31 15:36:39 +0000189# Flatbuffers support for TF Lite and Armnn Serializer
190if(BUILD_TF_LITE_PARSER OR BUILD_ARMNN_SERIALIZER)
telsoa01c577f2c2018-08-31 09:22:23 +0100191 # verify we have a valid flatbuffers include path
192 find_path(FLATBUFFERS_INCLUDE_PATH flatbuffers/flatbuffers.h
193 HINTS ${FLATBUFFERS_ROOT}/include /usr/local/include /usr/include)
194
Matthew Benthamd1ae3a62019-02-22 17:30:32 +0000195 message(STATUS "Flatbuffers headers are located at: ${FLATBUFFERS_INCLUDE_PATH}")
telsoa01c577f2c2018-08-31 09:22:23 +0100196
197 find_library(FLATBUFFERS_LIBRARY
198 NAMES libflatbuffers.a flatbuffers
199 HINTS ${FLATBUFFERS_ROOT}/lib /usr/local/lib /usr/lib)
200
Matthew Benthamd1ae3a62019-02-22 17:30:32 +0000201 message(STATUS "Flatbuffers library located at: ${FLATBUFFERS_LIBRARY}")
Nattapat Chaimanowong949f1252019-01-31 15:36:39 +0000202endif()
203
204# Flatbuffers schema support for TF Lite
205if(BUILD_TF_LITE_PARSER)
206 find_path(TF_LITE_SCHEMA_INCLUDE_PATH
207 schema_generated.h
208 HINTS ${TF_LITE_GENERATED_PATH})
209
Matthew Benthamd1ae3a62019-02-22 17:30:32 +0000210 message(STATUS "Tf Lite generated header found at: ${TF_LITE_SCHEMA_INCLUDE_PATH}")
Nattapat Chaimanowong949f1252019-01-31 15:36:39 +0000211
Matthew Benthamd1ae3a62019-02-22 17:30:32 +0000212 add_definitions(-DARMNN_TF_LITE_PARSER)
telsoa01c577f2c2018-08-31 09:22:23 +0100213endif()
214
Kevin May43a799c2019-02-08 16:31:42 +0000215if(BUILD_ARMNN_SERIALIZER)
Kevin May43a799c2019-02-08 16:31:42 +0000216 add_definitions(-DARMNN_SERIALIZER)
Matthew Bentham268509a2019-02-25 13:58:24 +0000217 add_definitions(-DARMNN_SERIALIZER_SCHEMA_PATH="${CMAKE_CURRENT_SOURCE_DIR}/src/armnnSerializer/ArmnnSchema.fbs")
Kevin May43a799c2019-02-08 16:31:42 +0000218endif()
219
telsoa014fcda012018-03-09 14:13:49 +0000220include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
Sadik Armagana97a0be2020-03-03 10:44:56 +0000221include_directories(${CMAKE_CURRENT_SOURCE_DIR}/profiling)
telsoa014fcda012018-03-09 14:13:49 +0000222
223# ARM Compute
224# Note that ARM Compute has a different folder layout depending on the branch but also on
225# whether it comes from a prepackaged archive (this is why we add several hints below)
226if(ARMCOMPUTENEON OR ARMCOMPUTECL)
227 find_path(ARMCOMPUTE_INCLUDE arm_compute/core/CL/ICLKernel.h
228 PATHS ${ARMCOMPUTE_ROOT}/include
229 PATHS ${ARMCOMPUTE_ROOT}/applications/arm_compute
230 PATHS ${ARMCOMPUTE_ROOT}
231 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
232 find_path(ARMCOMPUTE_INCLUDE arm_compute/core/CL/ICLKernel.h)
233 include_directories(SYSTEM "${ARMCOMPUTE_INCLUDE}")
234
235 # Find the Arm Compute libraries if not already specified (the user may have already defined this in advance,
236 # e.g. if building clframework as a dependent cmake project)
237 if (NOT DEFINED ARMCOMPUTE_LIBRARIES)
238 # We link to the static variant so that customers don't need to find and build a compatible version of clframework.
239 # First try the folders specified ARMCOMPUTE_BUILD_DIR (with PATH_SUFFIXES for
240 # Windows builds)
Matthew Bentham2624dd72020-05-20 10:44:18 +0100241 if ((NOT DEFINED ARMCOMPUTE_BUILD_DIR) AND (DEFINED ARMCOMPUTE_ROOT))
242 # Default build directory for ComputeLibrary is under the root
243 set(ARMCOMPUTE_BUILD_DIR ${ARMCOMPUTE_ROOT}/build)
244 endif()
245
telsoa014fcda012018-03-09 14:13:49 +0000246 find_library(ARMCOMPUTE_LIBRARY_DEBUG NAMES arm_compute-static
247 PATHS ${ARMCOMPUTE_BUILD_DIR}
248 PATH_SUFFIXES "Debug"
249 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
250 find_library(ARMCOMPUTE_LIBRARY_RELEASE NAMES arm_compute-static
251 PATHS ${ARMCOMPUTE_BUILD_DIR}
252 PATH_SUFFIXES "Release"
253 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
254 find_library(ARMCOMPUTE_CORE_LIBRARY_DEBUG NAMES arm_compute_core-static
255 PATHS ${ARMCOMPUTE_BUILD_DIR}
256 PATH_SUFFIXES "Debug"
257 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
258 find_library(ARMCOMPUTE_CORE_LIBRARY_RELEASE NAMES arm_compute_core-static
259 PATHS ${ARMCOMPUTE_BUILD_DIR}
260 PATH_SUFFIXES "Release"
261 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
262
263 # In case it wasn't there, try a default search (will work in cases where
264 # the library has been installed into a standard location)
265 find_library(ARMCOMPUTE_LIBRARY_DEBUG NAMES arm_compute-static)
266 find_library(ARMCOMPUTE_LIBRARY_RELEASE NAMES arm_compute-static)
267 find_library(ARMCOMPUTE_CORE_LIBRARY_DEBUG NAMES arm_compute_core-static)
268 find_library(ARMCOMPUTE_CORE_LIBRARY_RELEASE NAMES arm_compute_core-static)
269
Matthew Bentham6445cff2020-03-10 11:13:17 +0000270 # In case it wasn't there, try the dynamic libraries
271 # This case will get used in a linux setup where the Compute Library
272 # has been installed in a standard system library path as a dynamic library
273 find_library(ARMCOMPUTE_LIBRARY_DEBUG NAMES arm_compute)
274 find_library(ARMCOMPUTE_LIBRARY_RELEASE NAMES arm_compute)
275 find_library(ARMCOMPUTE_CORE_LIBRARY_DEBUG NAMES arm_compute_core)
276 find_library(ARMCOMPUTE_CORE_LIBRARY_RELEASE NAMES arm_compute_core)
277
telsoa014fcda012018-03-09 14:13:49 +0000278 set(ARMCOMPUTE_LIBRARIES
279 debug ${ARMCOMPUTE_LIBRARY_DEBUG} ${ARMCOMPUTE_CORE_LIBRARY_DEBUG}
280 optimized ${ARMCOMPUTE_LIBRARY_RELEASE} ${ARMCOMPUTE_CORE_LIBRARY_RELEASE} )
281 endif()
282endif()
283
284# ARM Compute NEON backend
285if(ARMCOMPUTENEON)
286 # Add preprocessor definition for ARM Compute NEON
287 add_definitions(-DARMCOMPUTENEON_ENABLED)
288 # The ARM Compute headers contain some NEON intrinsics, so we need to build armnn with NEON support on armv7
289 if(${CMAKE_SYSTEM_PROCESSOR} MATCHES armv7 AND COMPILER_IS_GNU_LIKE)
290 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=neon")
291 endif()
292endif()
293
294# ARM Compute OpenCL backend
295if(ARMCOMPUTECL)
296 # Always use Arm compute library OpenCL headers
297 find_path(OPENCL_INCLUDE CL/cl2.hpp
298 PATHS ${ARMCOMPUTE_ROOT}/include
299 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
300
Matthew Bentham3b72db02018-10-11 09:47:01 +0100301 # Link against libOpenCL in opencl-1.2-stubs, but don't search there at runtime
302 link_libraries(-L${ARMCOMPUTE_BUILD_DIR}/opencl-1.2-stubs)
303 set(OPENCL_LIBRARIES OpenCL)
telsoa014fcda012018-03-09 14:13:49 +0000304
Matthew Bentham416b41d2020-02-05 22:15:26 +0000305 include_directories(SYSTEM ${OPENCL_INCLUDE})
telsoa014fcda012018-03-09 14:13:49 +0000306
307 # Add preprocessor definition for ARM Compute OpenCL
308 add_definitions(-DARMCOMPUTECL_ENABLED)
309
310 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DARM_COMPUTE_DEBUG_ENABLED")
311endif()
312
313# Used by both Arm Compute backends, but should be added
314# to the search path after the system directories if necessary
315if(ARMCOMPUTENEON OR ARMCOMPUTECL)
316 find_path(HALF_INCLUDE half/half.hpp)
317 find_path(HALF_INCLUDE half/half.hpp
318 PATHS ${ARMCOMPUTE_ROOT}/include
319 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
telsoa01c577f2c2018-08-31 09:22:23 +0100320 include_directories(SYSTEM ${HALF_INCLUDE})
telsoa014fcda012018-03-09 14:13:49 +0000321endif()
322
Matteo Martincighdb16dd32019-08-27 16:41:11 +0100323# ArmNN reference backend
324if(ARMNNREF)
325 add_definitions(-DARMNNREF_ENABLED)
Matteo Martincighe67edb22019-08-14 14:05:46 +0100326endif()
327
Narumol Prangnawarat60a20fb2019-12-09 17:24:41 +0000328# ArmNN dynamic backend
329if(DYNAMIC_BACKEND_PATHS)
330 add_definitions(-DARMNN_DYNAMIC_BACKEND_ENABLED)
331endif()
332
Narumol Prangnawarat867eba52020-02-03 12:29:56 +0000333if(SAMPLE_DYNAMIC_BACKEND)
334 add_definitions(-DSAMPLE_DYNAMIC_BACKEND_ENABLED)
335endif()
336
telsoa014fcda012018-03-09 14:13:49 +0000337# Streamline annotate
338if(PROFILING_BACKEND_STREAMLINE)
339 include_directories("${GATOR_ROOT}/annotate")
340 add_definitions(-DARMNN_STREAMLINE_ENABLED)
341endif()
342
telsoa01c577f2c2018-08-31 09:22:23 +0100343if(HEAP_PROFILING OR LEAK_CHECKING)
surmeh013537c2c2018-05-18 16:31:43 +0100344 # enable heap profiling for everything except for referencetests
345 if(NOT ${PROJECT_NAME} STREQUAL "referencetests")
346 find_path(HEAP_PROFILER_INCLUDE gperftools/heap-profiler.h
347 PATHS ${GPERFTOOLS_ROOT}/include
348 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
349 include_directories(SYSTEM "${HEAP_PROFILER_INCLUDE}")
350 find_library(GPERF_TOOLS_LIBRARY
351 NAMES tcmalloc_debug
352 HINTS ${GPERFTOOLS_ROOT}/lib)
353 link_directories(${GPERFTOOLS_ROOT}/lib)
354
355 link_libraries(${GPERF_TOOLS_LIBRARY})
telsoa01c577f2c2018-08-31 09:22:23 +0100356 if (HEAP_PROFILING)
357 add_definitions("-DARMNN_HEAP_PROFILING_ENABLED=1")
358 endif()
359 if (LEAK_CHECKING)
360 add_definitions("-DARMNN_LEAK_CHECKING_ENABLED=1")
361 endif()
surmeh013537c2c2018-05-18 16:31:43 +0100362 else()
Rob Hughes721b82f2019-11-15 09:04:17 +0000363 message(STATUS "Heap profiling and leak checking are disabled for referencetests")
surmeh013537c2c2018-05-18 16:31:43 +0100364 endif()
365else()
366 # Valgrind only works with gperftools version number <= 2.4
367 CHECK_INCLUDE_FILE(valgrind/memcheck.h VALGRIND_FOUND)
368endif()
369
370
371if(NOT BUILD_CAFFE_PARSER)
372 message(STATUS "Caffe parser support is disabled")
373endif()
374
375if(NOT BUILD_TF_PARSER)
376 message(STATUS "Tensorflow parser support is disabled")
377endif()
378
telsoa01c577f2c2018-08-31 09:22:23 +0100379if(NOT BUILD_TF_LITE_PARSER)
380 message(STATUS "Tensorflow Lite parser support is disabled")
381endif()
David Beck10b4dfd2018-09-19 12:03:20 +0100382
Nattapat Chaimanowong949f1252019-01-31 15:36:39 +0000383if(NOT BUILD_ARMNN_SERIALIZER)
384 message(STATUS "Armnn Serializer support is disabled")
385endif()
386
Jim Flynn3091b062019-02-15 14:45:04 +0000387if(NOT BUILD_ARMNN_QUANTIZER)
388 message(STATUS "ArmNN Quantizer support is disabled")
389endif()
390
Pavel Macenauer59e057f2020-04-15 14:17:26 +0000391if(NOT BUILD_PYTHON_WHL)
392 message(STATUS "PyArmNN wheel package is disabled")
393endif()
394
395if(NOT BUILD_PYTHON_SRC)
396 message(STATUS "PyArmNN source package is disabled")
397endif()
398
399if(BUILD_PYTHON_WHL OR BUILD_PYTHON_SRC)
400 find_package(PythonInterp 3 REQUIRED)
401 if(NOT ${PYTHONINTERP_FOUND})
402 message(FATAL_ERROR "Python 3.x required to build PyArmNN, but not found")
403 endif()
404
405 find_package(PythonLibs 3 REQUIRED)
406 if(NOT ${PYTHONLIBS_FOUND})
407 message(FATAL_ERROR "Python 3.x development package required to build PyArmNN, but not found")
408 endif()
409
410 find_package(SWIG 4 REQUIRED)
411 if(NOT ${SWIG_FOUND})
412 message(FATAL_ERROR "SWIG 4.x requried to build PyArmNN, but not found")
413 endif()
414endif()
415
David Beck10b4dfd2018-09-19 12:03:20 +0100416# ArmNN source files required for all build options
417include_directories(SYSTEM third-party)