forked from analogdevicesinc/ToF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
162 lines (137 loc) · 5.46 KB
/
CMakeLists.txt
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
cmake_minimum_required(VERSION 3.0)
project(adi_tof_project)
####################### Disable In-source builds ##############################
if( ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR} )
message(FATAL_ERROR "In-source builds are not allowed. \
Consider making a separate build folder and run cmake \
from there using this command:
cmake ${CMAKE_SOURCE_DIR}")
endif()
############################### Version #######################################
set(ADITOF_VERSION_MAJOR 4)
set(ADITOF_VERSION_MINOR 3)
set(ADITOF_VERSION_PATCH 0)
set(VERSION "${ADITOF_VERSION_MAJOR}.${ADITOF_VERSION_MINOR}.${ADITOF_VERSION_PATCH}")
############################### Options #######################################
option(WITH_EXAMPLES "Build examples?" ON)
option(WITH_DOC "Build documentation?" OFF)
option(WITH_PYTHON "Build python bindings?" OFF)
option(WITH_OPENCV "Build opencv bindings?" OFF)
option(WITH_OPEN3D "Build open3d bindings?" OFF)
option(WITH_ROS "Build ros bindings?" OFF)
option(WITH_ROS2 "Build ros2 bindings?" OFF)
option(WITH_NETWORK "Build network interface?" ON)
option(WITH_OFFLINE "Build offline interface?" OFF)
option(USE_DEPTH_COMPUTE_STUBS "Use empty generated libs?" OFF)
option(USE_DEPTH_COMPUTE_OPENSOURCE "Use an open source implementation?" OFF)
option(WITH_GLOG_DEPENDENCY "Build with GLOG dependency to be used for logging" ON)
option(WITH_PROTOBUF_DEPENDENCY "Build with PROTOBUF dependency to be used for serializing messages" ON)
option(WITH_COMMAND_LINE_TOOLS "Build with embedded Linux command line tools" ON)
################################## Git ########################################
include(FindGit OPTIONAL)
if (GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --show-toplevel
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE ADITOFSDK_GIT_REPO
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
if ("${ADITOFSDK_GIT_REPO}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE ADITOFSDK_GIT_COMMIT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE ADITOFSDK_GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
endif()
add_definitions(-DADITOFSDK_GIT_COMMIT="${ADITOFSDK_GIT_COMMIT}")
add_definitions(-DADITOFSDK_GIT_BRANCH="${ADITOFSDK_GIT_BRANCH}")
########################## Checks and validations #############################
if (${USE_DEPTH_COMPUTE_STUBS} AND ${USE_DEPTH_COMPUTE_OPENSOURCE})
message(FATAL_ERROR "Choose only one type of depth compute. CMake will exit.")
endif()
############################## Rest of cmake ##################################
if (USE_ADSD3030)
add_definitions(-DADSD3030)
endif()
if (WITH_NETWORK)
add_definitions(-DHAS_NETWORK)
endif()
set(RESOURCES_DIR "${CMAKE_BINARY_DIR}/resources")
make_directory(${RESOURCES_DIR})
if (WITH_OFFLINE)
add_definitions(-DHAS_OFFLINE)
set(RESOURCES_OFFLINE_DIR "${RESOURCES_DIR}/offline")
make_directory(${RESOURCES_OFFLINE_DIR})
set(MODE_FILE "lr-qnative.bin" "sr-qnative.bin")
message("Downloading raw frames into ${RESOURCES_OFFLINE_DIR}")
foreach(MODE IN LISTS MODE_FILE)
set(MODE_URL "swdownloads.analog.com/cse/aditof/resources/itof/frames/${MODE}")
set(MODE_PATH "${RESOURCES_OFFLINE_DIR}/${MODE}")
if (NOT EXISTS ${MODE_PATH})
file(DOWNLOAD "${MODE_URL}" "${MODE_PATH}")
endif()
endforeach()
endif()
if(WITH_GLOG_DEPENDENCY)
add_definitions(-DUSE_GLOG)
endif()
if(NOT WITH_PROTOBUF_DEPENDENCY)
if(NOT NXP AND NOT NVIDIA)
message(FATAL_ERROR "SDK can be built without protobuf only on target builds!")
endif()
else()
add_definitions(-DUSE_PROTOBUF)
endif()
if(USE_DEPTH_COMPUTE_STUBS)
set(LIBTOFI_LIBDIR_PATH "${CMAKE_BINARY_DIR}/sdk/common/adi/depth-compute-stub")
elseif(USE_DEPTH_COMPUTE_OPENSOURCE)
set(LIBTOFI_LIBDIR_PATH "${CMAKE_BINARY_DIR}/sdk/common/adi/depth-compute-opensource")
else()
set(LIBTOFI_LIBDIR_PATH "${CMAKE_SOURCE_DIR}/../libs")
endif()
if(WIN32 AND (USE_DEPTH_COMPUTE_STUBS OR USE_DEPTH_COMPUTE_OPENSOURCE))
set(LIBTOFI_LIBDIR_PATH "${LIBTOFI_LIBDIR_PATH}/${CMAKE_BUILD_TYPE}")
endif()
set(CONFIG_DIR_NAME "config")
add_definitions(-DCONFIG_DIR_NAME="${CONFIG_DIR_NAME}")
add_definitions(-DRESOURCES="${RESOURCES_DIR}")
add_subdirectory(dependencies)
add_subdirectory(apps)
add_subdirectory(sdk)
if (WITH_EXAMPLES)
add_subdirectory(examples)
endif()
if (WITH_DOC)
add_subdirectory(doc)
endif()
if (WITH_PYTHON)
add_subdirectory(bindings/python)
endif()
if (WITH_OPENCV)
add_subdirectory(bindings/opencv)
endif()
if (WITH_OPEN3D)
add_subdirectory(bindings/open3D)
endif()
if (WITH_ROS)
add_subdirectory(bindings/ros)
endif()
if (WITH_ROS2)
add_subdirectory(bindings/ros2)
endif()
if (WITH_COMMAND_LINE_TOOLS)
add_subdirectory(tools)
endif()
############################### Installer #######################################
configure_file(cmake/aditof-setup.iss.cmakein ${CMAKE_CURRENT_BINARY_DIR}/aditof-setup.iss @ONLY)
############################### Version #######################################
configure_file(cmake/version.h.cmakein ${CMAKE_SOURCE_DIR}/sdk/include/aditof/version.h @ONLY)