forked from WiVRn/WiVRn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
334 lines (285 loc) · 13.7 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
cmake_minimum_required(VERSION 3.25)
project(WiVRn VERSION 0.0.0 LANGUAGES C CXX)
# Set default for FetchContent projects
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# Default to PIC code
include(CheckPIESupported)
check_pie_supported()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
include(FetchContent)
include(ExternalProject)
include(GNUInstallDirs)
include("cmake/AutoOption.cmake")
option(WIVRN_USE_SYSTEM_FREETYPE "Use system FreeType" ON)
auto_option(WIVRN_USE_SYSTEM_BOOST "Use system Boost headers" AUTO)
auto_option(WIVRN_USE_SYSTEM_OPENXR "Use system OpenXR headers" AUTO)
auto_option(WIVRN_USE_SYSTEMD "Use libsystemd" AUTO)
auto_option(WIVRN_USE_LIBKTX "Use libktx" AUTO)
option(WIVRN_USE_ANDROID_VALIDATION_LAYER "Download the android version of the Vulkan validation layer" OFF)
option(WIVRN_BUILD_CLIENT "Build WiVRn client" OFF)
option(WIVRN_BUILD_SERVER "Build WiVRn server" ON)
option(WIVRN_BUILD_DASHBOARD "Build WiVRn dashboard" OFF)
option(WIVRN_BUILD_WIVRNCTL "Build wivrnctl" ON)
option(WIVRN_BUILD_DISSECTOR "Build Wireshark dissector" OFF)
option(WIVRN_WERROR "Treat warnings as errors" OFF)
option(WIVRN_USE_NVENC "Enable nvenc (Nvidia) hardware encoder" ON)
auto_option(WIVRN_USE_VAAPI "Enable vaapi (AMD/Intel) hardware encoder" AUTO)
auto_option(WIVRN_USE_VULKAN_ENCODE "Enable vulkan video encoder" AUTO)
auto_option(WIVRN_USE_X264 "Enable x264 software encoder" AUTO)
auto_option(WIVRN_USE_PIPEWIRE "Enable pipewire backend" AUTO)
auto_option(WIVRN_USE_PULSEAUDIO "Enable pulseaudio backend" AUTO)
set(OPENCOMPOSITE_SEARCH_PATH "/usr/local/lib/OpenComposite:/usr/lib/OpenComposite:/opt/OpenComposite"
CACHE STRING "List of places to search for OpenComposite, separated by :")
option(WIVRN_FEATURE_RENDERDOC "Support renderdoc" OFF)
option(WIVRN_FEATURE_SOLARXR "Enable SolarXR driver" OFF)
option(WIVRN_FEATURE_STEAMVR_LIGHTHOUSE "Enable SteamVR Lighthouse driver" OFF)
option(WIVRN_CHECK_CAPSYSNICE "Check if CAP_SYS_NICE is available at startup" ON)
set(WIVRN_CSS "${CMAKE_SOURCE_DIR}/images/wivrn-local.css" CACHE STRING "Stylesheet to use to render SVGs" )
option(WIVRN_SHOW_IMGUI_DEMO_WINDOW "Show the Dear ImGui demo window in the client" OFF)
option(WIVRN_CLIENT_DEBUG_MENU "Enable the debug menu in the client" OFF)
set(WIVRN_OPENXR_MANIFEST_TYPE_VALUES relative absolute filename)
set(WIVRN_OPENXR_MANIFEST_TYPE "relative" CACHE STRING "How to reference libraries in OpenXR manifest: ${WIVRN_OPENXR_MANIFEST_TYPE_VALUES}")
if (NOT WIVRN_OPENXR_MANIFEST_TYPE IN_LIST WIVRN_OPENXR_MANIFEST_TYPE_VALUES)
message(FATAL_ERROR "WIVRN_OPENXR_MANIFEST_TYPE must be one of ${WIVRN_OPENXR_MANIFEST_TYPE_VALUES}")
endif()
option(ENABLE_COLOURED_OUTPUT "Always produce ANSI-coloured output (GNU/Clang only)." ON)
if(ENABLE_COLOURED_OUTPUT)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options(-fdiagnostics-color=always)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options(-fcolor-diagnostics)
endif()
endif()
find_package(PkgConfig REQUIRED)
find_package(Vulkan REQUIRED)
find_package(Git)
if (NOT ANDROID)
find_package(OpenSSL REQUIRED)
endif()
include(VulkanVersion)
if (WIVRN_USE_SYSTEM_BOOST STREQUAL "AUTO")
if(WIVRN_BUILD_DISSECTOR)
find_package(Boost 1.84.0 COMPONENTS locale url)
else()
find_package(Boost 1.75.0 COMPONENTS locale url)
endif()
elseif(WIVRN_USE_SYSTEM_BOOST STREQUAL "ON")
if(WIVRN_BUILD_DISSECTOR)
find_package(Boost 1.84.0 REQUIRED COMPONENTS locale url)
else()
find_package(Boost 1.75.0 REQUIRED COMPONENTS locale url)
endif()
endif()
if (WIVRN_BUILD_SERVER)
find_program(GDBUS_CODEGEN gdbus-codegen REQUIRED)
if (Vulkan_VERSION VERSION_LESS "1.3.261")
message(FATAL_ERROR "Vulkan version must be at least 1.3.261, found ${Vulkan_VERSION}")
endif()
if (NOT WIVRN_USE_NVENC AND NOT WIVRN_USE_VAAPI AND NOT WIVRN_USE_X264 AND NOT WIVRN_USE_VULKAN_ENCODE)
message(FATAL_ERROR "No encoder selected, use at least one of WIVRN_USE_NVENC, WIVRN_USE_VAAPI, WIVRN_USE_VULKAN_ENCODE or WIVRN_USE_X264")
endif()
if (WIVRN_USE_VAAPI STREQUAL "AUTO")
pkg_check_modules(LIBAV IMPORTED_TARGET libavcodec libavutil libswscale libavfilter)
pkg_check_modules(LIBDRM IMPORTED_TARGET libdrm)
if (LIBAV_FOUND AND LIBDRM_FOUND)
set(WIVRN_USE_VAAPI ON)
else()
set(WIVRN_USE_VAAPI OFF)
endif()
elseif (WIVRN_USE_VAAPI)
pkg_check_modules(LIBAV REQUIRED IMPORTED_TARGET libavcodec libavutil libswscale libavfilter)
pkg_check_modules(LIBDRM REQUIRED IMPORTED_TARGET libdrm)
endif()
if (WIVRN_USE_VULKAN_ENCODE STREQUAL "AUTO")
if (Vulkan_VERSION VERSION_GREATER_EQUAL 1.3.283)
set(WIVRN_USE_VULKAN_ENCODE ON)
else()
set(WIVRN_USE_VULKAN_ENCODE OFF)
endif()
elseif(WIVRN_USE_VULKAN_ENCODE)
if (Vulkan_VERSION VERSION_LESS 1.3.283)
message(FATAL_ERROR "Vulkan video encode requires 1.3.283, found ${Vulkan_VERSION}")
endif()
endif()
if (WIVRN_USE_X264 STREQUAL "AUTO")
pkg_check_modules(X264 IMPORTED_TARGET x264)
if (X264_FOUND)
set(WIVRN_USE_X264 ON)
else()
set(WIVRN_USE_X264 OFF)
endif()
elseif (WIVRN_USE_X264)
pkg_check_modules(X264 REQUIRED IMPORTED_TARGET x264)
endif()
if (WIVRN_USE_SYSTEMD STREQUAL "AUTO")
pkg_check_modules(SYSTEMD IMPORTED_TARGET libsystemd)
if (SYSTEMD_FOUND)
set(WIVRN_USE_SYSTEMD ON)
else()
set(WIVRN_USE_SYSTEMD OFF)
endif()
elseif (WIVRN_USE_SYSTEMD)
pkg_check_modules(SYSTEMD REQUIRED IMPORTED_TARGET libsystemd)
endif()
if (WIVRN_USE_PIPEWIRE STREQUAL "AUTO")
pkg_check_modules(libpipewire IMPORTED_TARGET libpipewire-0.3)
if (libpipewire_FOUND)
set(WIVRN_USE_PIPEWIRE ON)
else()
set(WIVRN_USE_PIPEWIRE OFF)
endif()
elseif (WIVRN_USE_PIPEWIRE)
pkg_check_modules(libpipewire REQUIRED IMPORTED_TARGET libpipewire-0.3)
endif()
if (WIVRN_USE_PULSEAUDIO STREQUAL "AUTO")
pkg_check_modules(libpulse IMPORTED_TARGET libpulse)
if (libpulse_FOUND)
set(WIVRN_USE_PULSEAUDIO ON)
else()
set(WIVRN_USE_PULSEAUDIO OFF)
endif()
elseif (WIVRN_USE_PULSEAUDIO)
pkg_check_modules(libpulse REQUIRED IMPORTED_TARGET libpulse)
endif()
pkg_check_modules(AVAHI REQUIRED IMPORTED_TARGET avahi-client avahi-glib)
find_package(Eigen3 REQUIRED)
find_package(nlohmann_json REQUIRED)
find_package(CLI11 REQUIRED)
pkg_check_modules(glib2 REQUIRED IMPORTED_TARGET glib-2.0 gio-2.0 gio-unix-2.0)
pkg_check_modules(libnotify REQUIRED IMPORTED_TARGET libnotify)
endif()
if (WIVRN_BUILD_DASHBOARD)
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets DBus Network LinguistTools)
find_package(nlohmann_json REQUIRED)
if (WIVRN_CHECK_CAPSYSNICE)
pkg_check_modules(libcap REQUIRED IMPORTED_TARGET libcap)
endif()
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
endif()
if (WIVRN_BUILD_CLIENT OR WIVRN_BUILD_DASHBOARD)
find_program(RSVG_CONVERT rsvg-convert REQUIRED)
endif()
if (WIVRN_BUILD_CLIENT)
find_package(Gettext REQUIRED)
if (WIVRN_USE_LIBKTX STREQUAL "AUTO")
if (ANDROID)
set(WIVRN_USE_LIBKTX ON)
else()
set(WIVRN_USE_LIBKTX OFF)
endif()
endif()
endif()
if (WIVRN_BUILD_CLIENT AND NOT ANDROID)
pkg_check_modules(LIBAV REQUIRED IMPORTED_TARGET libavcodec libavutil libswscale libavfilter)
find_package(Fontconfig REQUIRED)
if (WIVRN_USE_SYSTEM_OPENXR STREQUAL "AUTO")
find_package(OpenXR 1.0.26)
elseif(WIVRN_USE_SYSTEM_OPENXR STREQUAL "ON")
find_package(OpenXR 1.0.26 REQUIRED)
endif()
endif()
if(ANDROID)
set(ANDROID_NDK $ENV{ANDROID_NDK_ROOT})
set(CMAKE_ANDROID_NDK $ENV{ANDROID_NDK_ROOT})
include(AndroidNdkModules)
android_ndk_import_module_native_app_glue()
endif()
if (WIVRN_BUILD_DISSECTOR)
if (WIVRN_USE_SYSTEM_OPENXR STREQUAL "AUTO")
find_package(OpenXR 1.0.34)
elseif(WIVRN_USE_SYSTEM_OPENXR STREQUAL "ON")
find_package(OpenXR 1.0.34 REQUIRED)
endif()
find_package(Wireshark REQUIRED)
endif()
if (WIVRN_BUILD_WIVRNCTL)
find_package(CLI11 REQUIRED)
pkg_search_module(SYSTEMD REQUIRED IMPORTED_TARGET libsystemd libelogind)
endif()
# Common dependencies
FetchContent_Declare(boostpfr EXCLUDE_FROM_ALL SYSTEM URL https://github.com/boostorg/pfr/archive/refs/tags/2.2.0.tar.gz
URL_HASH SHA256=6f490ec1383de5855dcf801c23f0a967f888eb6e1440b6ca0bf36c12d4ae7ac7)
FetchContent_Declare(boost EXCLUDE_FROM_ALL SYSTEM URL https://github.com/boostorg/boost/releases/download/boost-1.84.0/boost-1.84.0.tar.xz
URL_HASH SHA256=2e64e5d79a738d0fa6fb546c6e5c2bd28f88d268a2a080546f74e5ff98f29d0e)
# Client dependencies
FetchContent_Declare(simdjson EXCLUDE_FROM_ALL SYSTEM URL https://github.com/simdjson/simdjson/archive/refs/tags/v3.10.1.tar.gz
URL_HASH SHA256=1e8f881cb2c0f626c56cd3665832f1e97b9d4ffc648ad9e1067c134862bba060)
FetchContent_Declare(fastgltf EXCLUDE_FROM_ALL SYSTEM URL https://github.com/spnda/fastgltf/archive/refs/tags/v0.7.1.tar.gz
URL_HASH SHA256=44bcb025dd5cd480236a3bc7a3f8c9a708a801ed773b7859677440d22e0e1e7c)
FetchContent_Declare(glm EXCLUDE_FROM_ALL SYSTEM URL https://github.com/g-truc/glm/archive/refs/tags/1.0.1.tar.gz
URL_HASH SHA256=9f3174561fd26904b23f0db5e560971cbf9b3cbda0b280f04d5c379d03bf234c)
FetchContent_Declare(openxr_loader EXCLUDE_FROM_ALL SYSTEM URL https://github.com/KhronosGroup/OpenXR-SDK/archive/refs/tags/release-1.0.34.tar.gz
URL_HASH SHA256=5fa2fac1b442a31e267ea522799a247e3aff6e6f5a418b1e31c337b8ca835b69)
FetchContent_Declare(spdlog EXCLUDE_FROM_ALL SYSTEM URL https://github.com/gabime/spdlog/archive/refs/tags/v1.14.1.tar.gz
URL_HASH SHA256=1586508029a7d0670dfcb2d97575dcdc242d3868a259742b69f100801ab4e16b)
FetchContent_Declare(stb EXCLUDE_FROM_ALL SYSTEM URL https://github.com/nothings/stb/archive/013ac3beddff3dbffafd5177e7972067cd2b5083.zip
URL_HASH SHA256=b7f476902bbef1b30f8ecc2d9d95c459c32302c8b559d09b589b5955463b7af8)
FetchContent_Declare(libktx EXCLUDE_FROM_ALL SYSTEM URL https://github.com/KhronosGroup/KTX-Software/archive/refs/tags/v4.3.0.tar.gz
URL_HASH SHA256=d892b5951cba9e938bae29eaee56a948174846c33616225eb92b6235029419b4)
FetchContent_Declare(implot EXCLUDE_FROM_ALL SYSTEM URL https://github.com/epezent/implot/archive/refs/tags/v0.16.tar.gz
URL_HASH SHA256=961df327d8a756304d1b0a67316eebdb1111d13d559f0d3415114ec0eb30abd1)
file(GLOB IMGUI_PATCHES CONFIGURE_DEPENDS patches/imgui/*)
FetchContent_Declare(imgui EXCLUDE_FROM_ALL SYSTEM URL https://github.com/ocornut/imgui/archive/refs/tags/v1.91.3.tar.gz
URL_HASH SHA256=29949d7b300c30565fbcd66398100235b63aa373acfee0b76853a7aeacd1be28
PATCH_COMMAND ${CMAKE_CURRENT_LIST_DIR}/patches/apply.sh ${IMGUI_PATCHES}
)
FetchContent_Declare(uni-algo EXCLUDE_FROM_ALL SYSTEM URL https://github.com/uni-algo/uni-algo/archive/v1.2.0.tar.gz
URL_HASH SHA256=f2a1539cd8635bc6088d05144a73ecfe7b4d74ee0361fabed6f87f9f19e74ca9)
file(GLOB MONADO_PATCHES CONFIGURE_DEPENDS patches/monado/*)
# Server dependencies
FetchContent_Declare(monado
GIT_REPOSITORY https://gitlab.freedesktop.org/monado/monado
# The flatpak manifest is updated automatically
GIT_TAG 529aa5b092b592714812b4685aa0454a3cfb120e
PATCH_COMMAND ${CMAKE_CURRENT_LIST_DIR}/patches/apply.sh ${MONADO_PATCHES}
EXCLUDE_FROM_ALL
)
add_subdirectory(external)
add_subdirectory(common)
if (WIVRN_BUILD_CLIENT)
add_subdirectory(client)
endif()
if (WIVRN_BUILD_SERVER)
add_subdirectory(server)
message("Selected encoders:")
message("\tNVENC : ${WIVRN_USE_NVENC}")
message("\tVAAPI : ${WIVRN_USE_VAAPI}")
message("\tVulkan: ${WIVRN_USE_VULKAN_ENCODE}")
message("\tx264 : ${WIVRN_USE_X264}")
message("")
message("Audio backends:")
message("\tPipewire : ${WIVRN_USE_PIPEWIRE}")
message("\tPulseaudio: ${WIVRN_USE_PULSEAUDIO}")
message("")
message("Optional features:")
message("\tsystemd: ${WIVRN_USE_SYSTEMD}")
endif()
if (WIVRN_BUILD_DASHBOARD)
add_subdirectory(dashboard)
set_target_properties(wivrn-dashboard PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/server)
endif()
add_subdirectory(tools)
foreach(TARGET_NAME wivrn wivrn-server wivrn-dashboard wivrn-common wivrn-dissector wivrnctl)
if(TARGET ${TARGET_NAME})
target_compile_options(${TARGET_NAME} PRIVATE
-fdiagnostics-color -Wall -Wextra -pedantic
-Wundef
-Wno-missing-field-initializers
-Wno-unused-parameter
-Wno-comment
-Wno-unused-variable
-Wno-sign-compare
$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-Wno-volatile -Wno-array-bounds>
$<$<COMPILE_LANG_AND_ID:CXX,Clang>:-Wno-deprecated-volatile -Wno-unneeded-internal-declaration -Wno-c99-extensions -Wno-unused-private-field>
)
if (WIVRN_WERROR)
target_compile_options(${TARGET_NAME} PRIVATE -Werror)
endif()
endif()
endforeach()