telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1 | option(BUILD_CAFFE_PARSER "Build Caffe parser" OFF) |
| 2 | option(BUILD_TF_PARSER "Build Tensorflow parser" OFF) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 3 | option(BUILD_ONNX_PARSER "Build Onnx parser" OFF) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4 | option(BUILD_UNIT_TESTS "Build unit tests" ON) |
| 5 | option(BUILD_TESTS "Build test applications" OFF) |
| 6 | option(BUILD_FOR_COVERAGE "Use no optimization and output .gcno and .gcda files" OFF) |
| 7 | option(ARMCOMPUTENEON "Build with ARM Compute NEON support" OFF) |
| 8 | option(ARMCOMPUTECL "Build with ARM Compute OpenCL support" OFF) |
Matteo Martincigh | f88663c | 2019-08-28 16:38:53 +0100 | [diff] [blame] | 9 | option(ARMNNREF "Build with ArmNN reference support" ON) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 10 | option(PROFILING_BACKEND_STREAMLINE "Forward the armNN profiling events to DS-5/Streamline as annotations" OFF) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 11 | # options used for heap profiling and leak checking |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 12 | option(HEAP_PROFILING "Build with heap profiling enabled" OFF) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 13 | option(LEAK_CHECKING "Build with leak checking enabled" OFF) |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 14 | option(GPERFTOOLS_ROOT "Location where the gperftools 'include' and 'lib' folders to be found" Off) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 15 | # options used for tensorflow lite support |
| 16 | option(BUILD_TF_LITE_PARSER "Build Tensorflow Lite parser" OFF) |
Nattapat Chaimanowong | 949f125 | 2019-01-31 15:36:39 +0000 | [diff] [blame] | 17 | option(BUILD_ARMNN_SERIALIZER "Build Armnn Serializer" OFF) |
Jim Flynn | 3091b06 | 2019-02-15 14:45:04 +0000 | [diff] [blame] | 18 | option(BUILD_ARMNN_QUANTIZER "Build ArmNN quantizer" OFF) |
Éanna Ó Catháin | a563b92 | 2019-05-09 11:34:06 +0100 | [diff] [blame] | 19 | option(BUILD_ACCURACY_TOOL "Build Accuracy Tool" OFF) |
Nattapat Chaimanowong | 949f125 | 2019-01-31 15:36:39 +0000 | [diff] [blame] | 20 | option(FLATC_DIR "Path to Flatbuffers compiler" OFF) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 21 | option(TF_LITE_GENERATED_PATH "Tensorflow lite generated C++ schema location" OFF) |
| 22 | option(FLATBUFFERS_ROOT "Location where the flatbuffers 'include' and 'lib' folders to be found" Off) |
Matteo Martincigh | e7d4498 | 2019-08-05 12:16:47 +0100 | [diff] [blame] | 23 | option(DYNAMIC_BACKEND_PATHS "Colon seperated list of paths where to load the dynamic backends from" "") |
Colm Donelan | a21620d | 2019-10-11 13:09:49 +0100 | [diff] [blame] | 24 | option(BUILD_GATORD_MOCK "Build the Gatord simulator for external profiling testing." ON) |
Matthew Bentham | b4e6720 | 2019-10-31 09:55:01 +0000 | [diff] [blame] | 25 | option(SHARED_BOOST "Use dynamic linking for boost libraries" OFF) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 26 | |
| 27 | include(SelectLibraryConfigurations) |
| 28 | |
| 29 | set(COMPILER_IS_GNU_LIKE 0) |
| 30 | if(${CMAKE_CXX_COMPILER_ID} STREQUAL GNU OR ${CMAKE_CXX_COMPILER_ID} STREQUAL Clang) |
| 31 | set(COMPILER_IS_GNU_LIKE 1) |
| 32 | endif() |
| 33 | |
| 34 | # Enable CCache if available and not disabled |
| 35 | option(USE_CCACHE "USE_CCACHE" ON) |
| 36 | find_program(CCACHE_FOUND ccache) |
| 37 | if(CCACHE_FOUND AND USE_CCACHE) |
| 38 | get_property(rule_launch_compile DIRECTORY PROPERTY RULE_LAUNCH_COMPILE) |
| 39 | set_property(DIRECTORY PROPERTY RULE_LAUNCH_COMPILE "CCACHE_CPP2=yes ${rule_launch_compile} ccache") |
| 40 | endif() |
| 41 | |
| 42 | # Enable distcc if available and not disabled |
| 43 | option(USE_DISTCC "USE_DISTCC" OFF) |
| 44 | find_program(DISTCC_FOUND distcc) |
| 45 | if(DISTCC_FOUND AND USE_DISTCC) |
| 46 | get_property(rule_launch_compile DIRECTORY PROPERTY RULE_LAUNCH_COMPILE) |
| 47 | set_property(DIRECTORY PROPERTY RULE_LAUNCH_COMPILE "${rule_launch_compile} distcc") |
| 48 | endif() |
| 49 | |
| 50 | # Set to release configuration by default |
| 51 | if(NOT CMAKE_BUILD_TYPE) |
| 52 | set(CMAKE_BUILD_TYPE "Release") |
| 53 | endif() |
| 54 | |
| 55 | # Compiler flags that are always set |
| 56 | set(CMAKE_POSITION_INDEPENDENT_CODE ON) |
| 57 | if(COMPILER_IS_GNU_LIKE) |
Derek Lamberti | ba25aee | 2019-12-10 22:20:54 +0000 | [diff] [blame] | 58 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -Wextra -Werror -Wold-style-cast -Wno-missing-braces -Wconversion -Wsign-conversion") |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 59 | elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC) |
Rob Hughes | fc6bf05 | 2019-12-16 17:10:51 +0000 | [diff] [blame] | 60 | # Disable C4996 (use of deprecated identifier) due to https://developercommunity.visualstudio.com/content/problem/252574/deprecated-compilation-warning-for-virtual-overrid.html |
| 61 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /MP /wd4996") |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 62 | add_definitions(-DNOMINMAX=1 -DNO_STRICT=1) |
| 63 | endif() |
| 64 | if("${CMAKE_SYSTEM_NAME}" STREQUAL Android) |
| 65 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -llog") |
| 66 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -llog") |
| 67 | endif() |
| 68 | |
| 69 | # Compiler flags for Release builds |
Matthew Bentham | e30054f | 2019-06-24 13:10:54 +0100 | [diff] [blame] | 70 | set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG") |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 71 | if(COMPILER_IS_GNU_LIKE) |
| 72 | set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3") |
| 73 | elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC) |
| 74 | set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD /O2") |
| 75 | endif() |
| 76 | |
| 77 | # Compiler flags for Debug builds |
| 78 | if(COMPILER_IS_GNU_LIKE) |
Matthew Bentham | e30054f | 2019-06-24 13:10:54 +0100 | [diff] [blame] | 79 | set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0") |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 80 | elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC) |
Matthew Bentham | e30054f | 2019-06-24 13:10:54 +0100 | [diff] [blame] | 81 | set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd /ZI /Od") |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 82 | # Disable SAFESEH which is necessary for Edit and Continue to work |
| 83 | set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /SAFESEH:NO") |
| 84 | set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /SAFESEH:NO") |
| 85 | endif() |
| 86 | |
| 87 | # Modify RelWithDebInfo so that NDEBUG isn't defined. |
| 88 | # This enables asserts. |
| 89 | if (COMPILER_IS_GNU_LIKE) |
| 90 | string(REPLACE "-DNDEBUG" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") |
| 91 | elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC) |
| 92 | string(REPLACE "/DNDEBUG" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") |
| 93 | endif() |
| 94 | |
| 95 | # Compiler flags for code coverage measurements |
| 96 | if(BUILD_FOR_COVERAGE) |
| 97 | if(NOT CMAKE_BUILD_TYPE EQUAL "Debug") |
| 98 | message(WARNING "BUILD_FOR_COVERAGE set so forcing to Debug build") |
| 99 | set(CMAKE_BUILD_TYPE "Debug") |
| 100 | endif() |
| 101 | |
| 102 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage") |
| 103 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") |
| 104 | endif() |
| 105 | |
| 106 | if(BUILD_FOR_COVERAGE AND NOT BUILD_UNIT_TESTS) |
| 107 | message(WARNING "BUILD_FOR_COVERAGE set but not BUILD_UNIT_TESTS, so code coverage will not be able to run") |
| 108 | endif() |
| 109 | |
| 110 | set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH}) |
| 111 | |
| 112 | # Boost |
Matthew Bentham | b4e6720 | 2019-10-31 09:55:01 +0000 | [diff] [blame] | 113 | if(SHARED_BOOST) |
| 114 | add_definitions(-DBOOST_ALL_DYN_LINK) |
| 115 | set(Boost_USE_STATIC_LIBS OFF) |
| 116 | else() |
| 117 | set(Boost_USE_STATIC_LIBS ON) |
| 118 | endif() |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 119 | add_definitions("-DBOOST_ALL_NO_LIB") # Turn off auto-linking as we specify the libs manually |
Francis Murtagh | f8ac829 | 2019-12-19 11:35:55 +0000 | [diff] [blame] | 120 | find_package(Boost 1.59 REQUIRED COMPONENTS unit_test_framework system filesystem program_options) |
Matthew Bentham | 97fb2de | 2019-07-12 17:26:57 +0100 | [diff] [blame] | 121 | include_directories(SYSTEM "${Boost_INCLUDE_DIRS}") |
| 122 | link_directories(${Boost_LIBRARY_DIRS}) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 123 | |
| 124 | # pthread |
| 125 | find_package (Threads) |
| 126 | |
| 127 | # Favour the protobuf passed on command line |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 128 | if(BUILD_TF_PARSER OR BUILD_CAFFE_PARSER OR BUILD_ONNX_PARSER) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 129 | find_library(PROTOBUF_LIBRARY_DEBUG NAMES "protobufd" |
| 130 | PATHS ${PROTOBUF_ROOT}/lib |
| 131 | NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) |
| 132 | find_library(PROTOBUF_LIBRARY_DEBUG NAMES "protobufd") |
| 133 | |
| 134 | find_library(PROTOBUF_LIBRARY_RELEASE NAMES "protobuf" |
| 135 | PATHS ${PROTOBUF_ROOT}/lib |
| 136 | NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) |
| 137 | find_library(PROTOBUF_LIBRARY_RELEASE NAMES "protobuf") |
| 138 | |
| 139 | select_library_configurations(PROTOBUF) |
| 140 | |
| 141 | find_path(PROTOBUF_INCLUDE_DIRS "google/protobuf/message.h" |
| 142 | PATHS ${PROTOBUF_ROOT}/include |
| 143 | NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) |
| 144 | find_path(PROTOBUF_INCLUDE_DIRS "google/protobuf/message.h") |
| 145 | |
| 146 | include_directories(SYSTEM "${PROTOBUF_INCLUDE_DIRS}") |
| 147 | add_definitions(-DPROTOBUF_USE_DLLS) |
| 148 | endif() |
| 149 | |
| 150 | # Caffe and its dependencies |
| 151 | if(BUILD_CAFFE_PARSER) |
| 152 | add_definitions(-DARMNN_CAFFE_PARSER) |
| 153 | |
| 154 | find_path(CAFFE_GENERATED_SOURCES "caffe/proto/caffe.pb.h" |
| 155 | HINTS ${CAFFE_BUILD_ROOT}/include) |
| 156 | include_directories(SYSTEM "${CAFFE_GENERATED_SOURCES}") |
| 157 | endif() |
| 158 | |
| 159 | if(BUILD_TF_PARSER) |
| 160 | add_definitions(-DARMNN_TF_PARSER) |
| 161 | |
| 162 | find_path(TF_GENERATED_SOURCES "tensorflow/core/protobuf/saved_model.pb.cc") |
| 163 | |
| 164 | # C++ sources generated for tf protobufs |
| 165 | file(GLOB_RECURSE TF_PROTOBUFS "${TF_GENERATED_SOURCES}/*.pb.cc") |
| 166 | |
| 167 | # C++ headers generated for tf protobufs |
| 168 | include_directories(SYSTEM "${TF_GENERATED_SOURCES}") |
| 169 | endif() |
| 170 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 171 | if(BUILD_ONNX_PARSER) |
| 172 | add_definitions(-DARMNN_ONNX_PARSER) |
| 173 | |
| 174 | find_path(ONNX_GENERATED_SOURCES "onnx/onnx.pb.cc") |
| 175 | |
| 176 | # C++ headers generated for onnx protobufs |
| 177 | include_directories(SYSTEM "${ONNX_GENERATED_SOURCES}") |
| 178 | endif() |
| 179 | |
Nattapat Chaimanowong | 949f125 | 2019-01-31 15:36:39 +0000 | [diff] [blame] | 180 | # Flatbuffers support for TF Lite and Armnn Serializer |
| 181 | if(BUILD_TF_LITE_PARSER OR BUILD_ARMNN_SERIALIZER) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 182 | # verify we have a valid flatbuffers include path |
| 183 | find_path(FLATBUFFERS_INCLUDE_PATH flatbuffers/flatbuffers.h |
| 184 | HINTS ${FLATBUFFERS_ROOT}/include /usr/local/include /usr/include) |
| 185 | |
Matthew Bentham | d1ae3a6 | 2019-02-22 17:30:32 +0000 | [diff] [blame] | 186 | message(STATUS "Flatbuffers headers are located at: ${FLATBUFFERS_INCLUDE_PATH}") |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 187 | |
| 188 | find_library(FLATBUFFERS_LIBRARY |
| 189 | NAMES libflatbuffers.a flatbuffers |
| 190 | HINTS ${FLATBUFFERS_ROOT}/lib /usr/local/lib /usr/lib) |
| 191 | |
Matthew Bentham | d1ae3a6 | 2019-02-22 17:30:32 +0000 | [diff] [blame] | 192 | message(STATUS "Flatbuffers library located at: ${FLATBUFFERS_LIBRARY}") |
Nattapat Chaimanowong | 949f125 | 2019-01-31 15:36:39 +0000 | [diff] [blame] | 193 | endif() |
| 194 | |
| 195 | # Flatbuffers schema support for TF Lite |
| 196 | if(BUILD_TF_LITE_PARSER) |
| 197 | find_path(TF_LITE_SCHEMA_INCLUDE_PATH |
| 198 | schema_generated.h |
| 199 | HINTS ${TF_LITE_GENERATED_PATH}) |
| 200 | |
Matthew Bentham | d1ae3a6 | 2019-02-22 17:30:32 +0000 | [diff] [blame] | 201 | message(STATUS "Tf Lite generated header found at: ${TF_LITE_SCHEMA_INCLUDE_PATH}") |
Nattapat Chaimanowong | 949f125 | 2019-01-31 15:36:39 +0000 | [diff] [blame] | 202 | |
Matthew Bentham | d1ae3a6 | 2019-02-22 17:30:32 +0000 | [diff] [blame] | 203 | add_definitions(-DARMNN_TF_LITE_PARSER) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 204 | endif() |
| 205 | |
Kevin May | 43a799c | 2019-02-08 16:31:42 +0000 | [diff] [blame] | 206 | if(BUILD_ARMNN_SERIALIZER) |
Kevin May | 43a799c | 2019-02-08 16:31:42 +0000 | [diff] [blame] | 207 | add_definitions(-DARMNN_SERIALIZER) |
Matthew Bentham | 268509a | 2019-02-25 13:58:24 +0000 | [diff] [blame] | 208 | add_definitions(-DARMNN_SERIALIZER_SCHEMA_PATH="${CMAKE_CURRENT_SOURCE_DIR}/src/armnnSerializer/ArmnnSchema.fbs") |
Kevin May | 43a799c | 2019-02-08 16:31:42 +0000 | [diff] [blame] | 209 | endif() |
| 210 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 211 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) |
| 212 | |
| 213 | # ARM Compute |
| 214 | # Note that ARM Compute has a different folder layout depending on the branch but also on |
| 215 | # whether it comes from a prepackaged archive (this is why we add several hints below) |
| 216 | if(ARMCOMPUTENEON OR ARMCOMPUTECL) |
| 217 | find_path(ARMCOMPUTE_INCLUDE arm_compute/core/CL/ICLKernel.h |
| 218 | PATHS ${ARMCOMPUTE_ROOT}/include |
| 219 | PATHS ${ARMCOMPUTE_ROOT}/applications/arm_compute |
| 220 | PATHS ${ARMCOMPUTE_ROOT} |
| 221 | NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) |
| 222 | find_path(ARMCOMPUTE_INCLUDE arm_compute/core/CL/ICLKernel.h) |
| 223 | include_directories(SYSTEM "${ARMCOMPUTE_INCLUDE}") |
| 224 | |
| 225 | # Find the Arm Compute libraries if not already specified (the user may have already defined this in advance, |
| 226 | # e.g. if building clframework as a dependent cmake project) |
| 227 | if (NOT DEFINED ARMCOMPUTE_LIBRARIES) |
| 228 | # We link to the static variant so that customers don't need to find and build a compatible version of clframework. |
| 229 | # First try the folders specified ARMCOMPUTE_BUILD_DIR (with PATH_SUFFIXES for |
| 230 | # Windows builds) |
| 231 | find_library(ARMCOMPUTE_LIBRARY_DEBUG NAMES arm_compute-static |
| 232 | PATHS ${ARMCOMPUTE_BUILD_DIR} |
| 233 | PATH_SUFFIXES "Debug" |
| 234 | NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) |
| 235 | find_library(ARMCOMPUTE_LIBRARY_RELEASE NAMES arm_compute-static |
| 236 | PATHS ${ARMCOMPUTE_BUILD_DIR} |
| 237 | PATH_SUFFIXES "Release" |
| 238 | NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) |
| 239 | find_library(ARMCOMPUTE_CORE_LIBRARY_DEBUG NAMES arm_compute_core-static |
| 240 | PATHS ${ARMCOMPUTE_BUILD_DIR} |
| 241 | PATH_SUFFIXES "Debug" |
| 242 | NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) |
| 243 | find_library(ARMCOMPUTE_CORE_LIBRARY_RELEASE NAMES arm_compute_core-static |
| 244 | PATHS ${ARMCOMPUTE_BUILD_DIR} |
| 245 | PATH_SUFFIXES "Release" |
| 246 | NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) |
| 247 | |
| 248 | # In case it wasn't there, try a default search (will work in cases where |
| 249 | # the library has been installed into a standard location) |
| 250 | find_library(ARMCOMPUTE_LIBRARY_DEBUG NAMES arm_compute-static) |
| 251 | find_library(ARMCOMPUTE_LIBRARY_RELEASE NAMES arm_compute-static) |
| 252 | find_library(ARMCOMPUTE_CORE_LIBRARY_DEBUG NAMES arm_compute_core-static) |
| 253 | find_library(ARMCOMPUTE_CORE_LIBRARY_RELEASE NAMES arm_compute_core-static) |
| 254 | |
| 255 | set(ARMCOMPUTE_LIBRARIES |
| 256 | debug ${ARMCOMPUTE_LIBRARY_DEBUG} ${ARMCOMPUTE_CORE_LIBRARY_DEBUG} |
| 257 | optimized ${ARMCOMPUTE_LIBRARY_RELEASE} ${ARMCOMPUTE_CORE_LIBRARY_RELEASE} ) |
| 258 | endif() |
| 259 | endif() |
| 260 | |
| 261 | # ARM Compute NEON backend |
| 262 | if(ARMCOMPUTENEON) |
| 263 | # Add preprocessor definition for ARM Compute NEON |
| 264 | add_definitions(-DARMCOMPUTENEON_ENABLED) |
| 265 | # The ARM Compute headers contain some NEON intrinsics, so we need to build armnn with NEON support on armv7 |
| 266 | if(${CMAKE_SYSTEM_PROCESSOR} MATCHES armv7 AND COMPILER_IS_GNU_LIKE) |
| 267 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=neon") |
| 268 | endif() |
| 269 | endif() |
| 270 | |
| 271 | # ARM Compute OpenCL backend |
| 272 | if(ARMCOMPUTECL) |
| 273 | # Always use Arm compute library OpenCL headers |
| 274 | find_path(OPENCL_INCLUDE CL/cl2.hpp |
| 275 | PATHS ${ARMCOMPUTE_ROOT}/include |
| 276 | NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) |
| 277 | |
Matthew Bentham | 3b72db0 | 2018-10-11 09:47:01 +0100 | [diff] [blame] | 278 | # Link against libOpenCL in opencl-1.2-stubs, but don't search there at runtime |
| 279 | link_libraries(-L${ARMCOMPUTE_BUILD_DIR}/opencl-1.2-stubs) |
| 280 | set(OPENCL_LIBRARIES OpenCL) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 281 | |
Matthew Bentham | 416b41d | 2020-02-05 22:15:26 +0000 | [diff] [blame] | 282 | include_directories(SYSTEM ${OPENCL_INCLUDE}) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 283 | |
| 284 | # Add preprocessor definition for ARM Compute OpenCL |
| 285 | add_definitions(-DARMCOMPUTECL_ENABLED) |
| 286 | |
| 287 | set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DARM_COMPUTE_DEBUG_ENABLED") |
| 288 | endif() |
| 289 | |
| 290 | # Used by both Arm Compute backends, but should be added |
| 291 | # to the search path after the system directories if necessary |
| 292 | if(ARMCOMPUTENEON OR ARMCOMPUTECL) |
| 293 | find_path(HALF_INCLUDE half/half.hpp) |
| 294 | find_path(HALF_INCLUDE half/half.hpp |
| 295 | PATHS ${ARMCOMPUTE_ROOT}/include |
| 296 | NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 297 | include_directories(SYSTEM ${HALF_INCLUDE}) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 298 | endif() |
| 299 | |
Matteo Martincigh | db16dd3 | 2019-08-27 16:41:11 +0100 | [diff] [blame] | 300 | # ArmNN reference backend |
| 301 | if(ARMNNREF) |
| 302 | add_definitions(-DARMNNREF_ENABLED) |
Matteo Martincigh | e67edb2 | 2019-08-14 14:05:46 +0100 | [diff] [blame] | 303 | endif() |
| 304 | |
Narumol Prangnawarat | 60a20fb | 2019-12-09 17:24:41 +0000 | [diff] [blame] | 305 | # ArmNN dynamic backend |
| 306 | if(DYNAMIC_BACKEND_PATHS) |
| 307 | add_definitions(-DARMNN_DYNAMIC_BACKEND_ENABLED) |
| 308 | endif() |
| 309 | |
Narumol Prangnawarat | 867eba5 | 2020-02-03 12:29:56 +0000 | [diff] [blame] | 310 | if(SAMPLE_DYNAMIC_BACKEND) |
| 311 | add_definitions(-DSAMPLE_DYNAMIC_BACKEND_ENABLED) |
| 312 | endif() |
| 313 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 314 | # Streamline annotate |
| 315 | if(PROFILING_BACKEND_STREAMLINE) |
| 316 | include_directories("${GATOR_ROOT}/annotate") |
| 317 | add_definitions(-DARMNN_STREAMLINE_ENABLED) |
| 318 | endif() |
| 319 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 320 | if(HEAP_PROFILING OR LEAK_CHECKING) |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 321 | # enable heap profiling for everything except for referencetests |
| 322 | if(NOT ${PROJECT_NAME} STREQUAL "referencetests") |
| 323 | find_path(HEAP_PROFILER_INCLUDE gperftools/heap-profiler.h |
| 324 | PATHS ${GPERFTOOLS_ROOT}/include |
| 325 | NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) |
| 326 | include_directories(SYSTEM "${HEAP_PROFILER_INCLUDE}") |
| 327 | find_library(GPERF_TOOLS_LIBRARY |
| 328 | NAMES tcmalloc_debug |
| 329 | HINTS ${GPERFTOOLS_ROOT}/lib) |
| 330 | link_directories(${GPERFTOOLS_ROOT}/lib) |
| 331 | |
| 332 | link_libraries(${GPERF_TOOLS_LIBRARY}) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 333 | if (HEAP_PROFILING) |
| 334 | add_definitions("-DARMNN_HEAP_PROFILING_ENABLED=1") |
| 335 | endif() |
| 336 | if (LEAK_CHECKING) |
| 337 | add_definitions("-DARMNN_LEAK_CHECKING_ENABLED=1") |
| 338 | endif() |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 339 | else() |
Rob Hughes | 721b82f | 2019-11-15 09:04:17 +0000 | [diff] [blame] | 340 | message(STATUS "Heap profiling and leak checking are disabled for referencetests") |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 341 | endif() |
| 342 | else() |
| 343 | # Valgrind only works with gperftools version number <= 2.4 |
| 344 | CHECK_INCLUDE_FILE(valgrind/memcheck.h VALGRIND_FOUND) |
| 345 | endif() |
| 346 | |
| 347 | |
| 348 | if(NOT BUILD_CAFFE_PARSER) |
| 349 | message(STATUS "Caffe parser support is disabled") |
| 350 | endif() |
| 351 | |
| 352 | if(NOT BUILD_TF_PARSER) |
| 353 | message(STATUS "Tensorflow parser support is disabled") |
| 354 | endif() |
| 355 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 356 | if(NOT BUILD_TF_LITE_PARSER) |
| 357 | message(STATUS "Tensorflow Lite parser support is disabled") |
| 358 | endif() |
David Beck | 10b4dfd | 2018-09-19 12:03:20 +0100 | [diff] [blame] | 359 | |
Nattapat Chaimanowong | 949f125 | 2019-01-31 15:36:39 +0000 | [diff] [blame] | 360 | if(NOT BUILD_ARMNN_SERIALIZER) |
| 361 | message(STATUS "Armnn Serializer support is disabled") |
| 362 | endif() |
| 363 | |
Jim Flynn | 3091b06 | 2019-02-15 14:45:04 +0000 | [diff] [blame] | 364 | if(NOT BUILD_ARMNN_QUANTIZER) |
| 365 | message(STATUS "ArmNN Quantizer support is disabled") |
| 366 | endif() |
| 367 | |
David Beck | 10b4dfd | 2018-09-19 12:03:20 +0100 | [diff] [blame] | 368 | # ArmNN source files required for all build options |
| 369 | include_directories(SYSTEM third-party) |