-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathCMakeLists.txt
147 lines (120 loc) · 4.47 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
cmake_minimum_required(VERSION 3.14)
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 ()
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
# set the timestamps of extracted contents to the time of extraction when using FetchContent()
# in order to avoid DOWNLOAD_EXTRACT_TIMESTAMP warning
cmake_policy(SET CMP0135 NEW)
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_PACKETS "Log packet sent/received over the serial line" ON)
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_PEDANTIC "Enable extra compiler warnings" OFF)
option(RSID_PROTECT_STACK "Enable stack protection compiler flags" OFF)
option(RSID_DOXYGEN "Build doxygen docs" OFF)
option(RSID_SECURE "Enable secure communication with device" OFF)
option(RSID_TOOLS "Build additional tools" ON)
option(RSID_PY "Build python wrapper" OFF)
option(RSID_NETWORK "Enable networking. Required for license and update checker." ON)
# install option
option(RSID_INSTALL "Generate the install target and rsidConfig.cmake" OFF)
if(RSID_NETWORK)
add_compile_definitions(RSID_NETWORK)
endif()
if(RSID_TIDY)
set(CMAKE_CXX_CLANG_TIDY "clang-tidy")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
message(STATUS "Enabled clang-tidy")
endif()
# extra warning flags support if RSID_PEDANTIC is ON
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/flags.cmake")
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")
if(RSID_NETWORK)
include(cmake/libcurl.cmake)
include(cmake/restClient.cmake)
include(cmake/nlohmann-json.cmake)
include(cmake/base64_hpp.cmake)
endif()
include(cmake/OS.cmake)
include(cmake/SpdLog.cmake)
if(MSVC AND RSID_NETWORK)
include(cmake/winreg.cmake)
endif()
if(RSID_SECURE OR RSID_MOCK_LICENSE)
include(cmake/Mbedtls.cmake)
endif()
if(RSID_PREVIEW AND NOT MSVC)
include(cmake/libjepg-turbo.cmake)
if (NOT MSVC)
include(cmake/libuvc.cmake)
endif()
endif()
if(RSID_SAMPLES)
add_subdirectory(samples)
endif()
if(RSID_DOXYGEN)
include(cmake/Doxygen.cmake)
endif()
if (RSID_TOOLS)
add_subdirectory(tools)
endif ()
add_subdirectory(src)
add_subdirectory(wrappers)
if(RSID_INSTALL)
include (cmake/Install.cmake)
endif()
include(FeatureSummary)
feature_summary(WHAT ALL)