summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
blob: 34824ff718ef8d4778228d677d65f4c49132ff57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
cmake_minimum_required(VERSION 3.1)

project(nnfw)

macro(nnfw_include PREFIX)
  include("${CMAKE_SOURCE_DIR}/cmake/modules/${PREFIX}.cmake")
endmacro(nnfw_include)

macro(nnfw_find_package PREFIX)
  find_package(${PREFIX} CONFIG NO_DEFAULT_PATH PATHS ${CMAKE_SOURCE_DIR}/cmake/packages ${ARGN})
endmacro(nnfw_find_package)

set(CMAKE_CXX_STANDARD 11)

# identify platform: HOST_PLATFORM, TARGET_PLATFORM and related
include("cmake/option/identify_platform.cmake")

# platform specific options
include("cmake/option/option_${TARGET_PLATFORM}.cmake")

# apply compilation flags
# note: this should be placed after cmake/option/option_xxx.cmake files
include("cmake/ApplyCompileFlags.cmake")

# Configuration flags
include("cmake/CfgOptionFlags.cmake")
# and besides CfgOptionFlags.cmake that can be given outside
#   OBS_BUILD: build boolean flag that tizen in OBS build
#   COVERAGE_BUILD: build boolean flag that enables converage test
#   ROOTFS_ARM: arm rootfs path for cross building
#   ROOTFS_ARM64: arm 64bit rootfs path for cross building, linux,tizen,android
#   TARGET_ARCH: target architecture string for cross building
#   TARGET_OS: target os string for cross building

# NOTE '${CMAKE_INSTALL_PREFIX}/lib' should be added as a link directory as
#      CI server places pre-built ARM compute libraries on this directory.
link_directories(${CMAKE_INSTALL_PREFIX}/lib)

# Download configuration
option(DOWNLOAD_TENSORFLOW "Download Tensorflow source" ON)
option(DOWNLOAD_ABSL "Download Absl source" ON)
option(DOWNLOAD_EIGEN "Download Eigen source" ON)
option(DOWNLOAD_FARMHASH "Download farmhash source" ON)
option(DOWNLOAD_GEMMLOWP "Download GEMM low precesion library source" ON)
option(DOWNLOAD_NEON2SSE "Download NEON2SSE library source" ON)
option(DOWNLOAD_FLATBUFFERS "Download FlatBuffers source" ON)
option(DOWNLOAD_ARMCOMPUTE "Download ARM Compute source" ON)
option(DOWNLOAD_NONIUS "Download nonius source" ON)

# GTest support
option(BUILD_GTEST "Download and build Google Test" ON)
nnfw_find_package(GTest QUIET)

# NOTE Workaround to avoid build fail by tensorflow (or acl) package version mismatch on obs build
if(OBS_BUILD)
  add_definitions(-DOBS_BUILD)
endif(OBS_BUILD)

nnfw_include(ExtendCMakeFunction)

# TODO For now Android build is being enabled incrementally so not all subdirectories are added yet.
#      However we are going to have the same subdirectories with other OS eventually.
if("${TARGET_OS}" STREQUAL "android")

  include_directories(externals/tensorflow)
  include_directories(externals/acl)
  include_directories(externals/acl/include)
  include_directories(externals/flatbuffers/include)
  include_directories(include)

  add_subdirectory(libs)
  add_subdirectory(externals)
  add_subdirectory(tests/tools/nnapi_test)
  add_subdirectory(tests/tools/tflite_benchmark)
  add_subdirectory(tests/nnapi)

  add_subdirectory(runtimes)

else("${TARGET_OS}" STREQUAL "android") # General case (non-android build)

  if(NOT OBS_BUILD)
    add_subdirectory(externals)
  endif(NOT OBS_BUILD)

  add_subdirectory(contrib)
  add_subdirectory(libs)
  add_subdirectory(runtimes)
  add_subdirectory(tests)
  add_subdirectory(tools)

endif("${TARGET_OS}" STREQUAL "android")