forked from IntelRealSense/RealSenseID
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
120 lines (97 loc) · 3.51 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
cmake_minimum_required(VERSION 3.10.2)
include(cmake/Version.cmake)
rsid_extract_version()
project(RealSenseID VERSION ${RSID_VERSION})
# C++14 and above
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
# if msvc, make sure __cplusplus is defined and add parallel build option
if(MSVC)
string(APPEND CMAKE_CXX_FLAGS " /Zc:__cplusplus /MP")
endif()
# CCache
find_program(CCACHE_PROGRAM ccache)
if (CCACHE_PROGRAM)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
message(STATUS "CCache found!")
endif ()
# Global properties
set(LIBRSID_CPP_TARGET rsid)
set(LIBRSID_C_TARGET rsid_c)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "_build")
set(RSID_DEBUG_POSTFIX _debug)
# ---------------------------------------------------------------------------------------
# Set RSID_MASTER_PROJECT to ON if we are not used via add_subdirectory, but allow overriding
# ---------------------------------------------------------------------------------------
if(NOT DEFINED RSID_MASTER_PROJECT)
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(RSID_MASTER_PROJECT ON)
else()
set(RSID_MASTER_PROJECT OFF)
endif()
endif()
# ---------------------------------------------------------------------------------------
# Set default build to release
# ---------------------------------------------------------------------------------------
if(RSID_MASTER_PROJECT AND NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose Release or Debug" FORCE)
endif()
message(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
# Options
option(RSID_DEBUG_CONSOLE "Log everything to console" ON)
option(RSID_DEBUG_FILE "Log everything to rsid_debug.log file" OFF)
option(RSID_DEBUG_SERIAL "Log all serial communication" OFF)
option(RSID_DEBUG_VALUES "Replace default common values with debug ones" OFF)
option(RSID_PREVIEW "Enable preview" OFF)
option(RSID_SAMPLES "Build samples" OFF)
option(RSID_TIDY "Enable clang-tidy" OFF)
option(RSID_DOXYGEN "Build doxygen docs" OFF)
option(RSID_SECURE "Enable secure communication with device" OFF)
option(RSID_TOOLS "Build additional tools" ON)
# install option
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Android")
option(RSID_INSTALL "Generate the install target and rsidConfig.cmake" OFF)
endif()
if(RSID_TIDY)
set(CMAKE_CXX_CLANG_TIDY "clang-tidy")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
message(STATUS "Enabled clang-tidy")
endif()
set(THIRD_PARTY_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty")
# Paths for lib, bin, install, etc.
set(BIN_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
set(LIBS_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${BIN_OUTPUT_PATH}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${LIBS_OUTPUT_PATH}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${LIBS_OUTPUT_PATH}")
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# Add 'cmake' folder to CMake's module lookup paths.
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
include(OS)
include(SpdLog)
if(RSID_SECURE)
include(Mbedtls)
endif()
if(RSID_PREVIEW)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Android")
include(UVC)
endif()
endif()
if(RSID_SAMPLES)
add_subdirectory(samples)
endif()
if(RSID_DOXYGEN)
include(Doxygen)
endif()
if (RSID_TOOLS)
add_subdirectory(tools)
endif ()
add_subdirectory(src)
add_subdirectory(wrappers)
if(RSID_INSTALL)
include (cmake/Install.cmake)
endif()