forked from ForWard-Technologies-LLC/Pylux
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
executable file
·371 lines (331 loc) · 14.4 KB
/
Copy pathCMakeLists.txt
File metadata and controls
executable file
·371 lines (331 loc) · 14.4 KB
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
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
cmake_minimum_required(VERSION 3.10)
project(chiaki)
# Fix for 16 KB page size compatibility (required for Android devices with 16 KB pages)
# This ensures ELF LOAD segments are aligned to 16 KB boundaries for shared libraries
# Note: Static libraries don't need this - they're archived, not linked
# With NDK r28+ and ANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON, alignment should be automatic
if(ANDROID)
# NDK r28+ treats warnings as errors. Disable problematic warnings for external libraries like mbedTLS
# Use -Wno-error= to make specific warnings non-fatal even if -Werror is present
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=documentation -Wno-error=unused-but-set-variable")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=documentation -Wno-error=unused-but-set-variable")
# For 16KB alignment: NDK r28+ should handle this automatically with ANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON
# However, we explicitly add the flag as a backup to ensure alignment
# Check if flag is already present (NDK may add it automatically)
string(REGEX MATCH "max-page-size" _has_max_page_size "${CMAKE_SHARED_LINKER_FLAGS}")
if(NOT _has_max_page_size)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,max-page-size=16384")
endif()
string(REGEX MATCH "max-page-size" _has_max_page_size_exe "${CMAKE_EXE_LINKER_FLAGS}")
if(NOT _has_max_page_size_exe)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,max-page-size=16384")
endif()
unset(_has_max_page_size)
unset(_has_max_page_size_exe)
endif()
# Like option(), but the value can also be AUTO
macro(tri_option name desc default)
set("${name}" "${default}" CACHE STRING "${desc}")
set_property(CACHE "${name}" PROPERTY STRINGS AUTO ON OFF)
endmacro()
option(CHIAKI_ENABLE_TESTS "Enable tests for Chiaki" ON)
option(CHIAKI_ENABLE_CLI "Enable CLI for Chiaki" ON)
option(CHIAKI_ENABLE_GUI "Enable Qt GUI" ON)
option(CHIAKI_ENABLE_ANDROID "Enable Android (Use only as part of the Gradle Project)" OFF)
option(CHIAKI_ENABLE_IOS "Enable iOS build (lib only, use from ios/ folder)" OFF)
option(CHIAKI_ENABLE_BOREALIS "Enable Borealis GUI (For Nintendo Switch or PC)" OFF)
tri_option(CHIAKI_ENABLE_SETSU "Enable libsetsu for touchpad input from controller" AUTO)
tri_option(CHIAKI_ENABLE_STEAMDECK_NATIVE "Enable sdeck for native gyro and haptic feedback from Steam Deck" ON)
option(CHIAKI_LIB_ENABLE_OPUS "Use Opus as part of Chiaki Lib" ON)
tri_option(CHIAKI_ENABLE_SPEEX "Use speex for echo cancelling mic playback" AUTO)
tri_option(CHIAKI_ENABLE_RUDP "Enable Remote Play over Internet" AUTO)
if(CHIAKI_ENABLE_GUI OR CHIAKI_ENABLE_BOREALIS)
set(CHIAKI_FFMPEG_DEFAULT ON)
else()
set(CHIAKI_FFMPEG_DEFAULT AUTO)
endif()
tri_option(CHIAKI_ENABLE_FFMPEG_DECODER "Enable FFMPEG video decoder" ${CHIAKI_FFMPEG_DEFAULT})
tri_option(CHIAKI_ENABLE_PI_DECODER "Enable Raspberry Pi-specific video decoder (requires libraspberrypi0 and libraspberrypi-doc)" AUTO)
option(CHIAKI_LIB_ENABLE_MBEDTLS "Use mbedtls instead of OpenSSL as part of Chiaki Lib" OFF)
option(CHIAKI_LIB_MBEDTLS_EXTERNAL_PROJECT "Fetch Mbed TLS instead of using system-provided libs" OFF)
option(CHIAKI_LIB_OPENSSL_EXTERNAL_PROJECT "Use OpenSSL as CMake external project" OFF)
option(CHIAKI_GUI_ENABLE_SDL_GAMECONTROLLER "Use SDL Gamecontroller for Input" ON)
option(CHIAKI_CLI_ARGP_STANDALONE "Search for standalone argp lib for CLI" OFF)
option(CHIAKI_ENABLE_STEAM_SHORTCUT "Add ability to create Steam shortcut" ON)
# Qt WebEngine in GUI: same switch for all platforms; Linux builds force OFF (historically no WebEngine link there).
option(CHIAKI_ENABLE_GUI_WEBENGINE "Link Qt WebEngineQuick in GUI (PSN can use external browser when OFF)" ON)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(CHIAKI_ENABLE_GUI_WEBENGINE OFF CACHE BOOL "" FORCE)
endif()
option(CHIAKI_ENABLE_STEAMWORKS "Enable Steamworks SDK integration for Steam overlay" OFF)
option(CHIAKI_IS_MAC_APPSTORE "Build for Mac App Store (disables Stripe donation prompt, enables future macOS IAP)" OFF)
tri_option(CHIAKI_USE_SYSTEM_JERASURE "Use system-provided jerasure instead of submodule" AUTO)
tri_option(CHIAKI_USE_SYSTEM_NANOPB "Use system-provided nanopb instead of submodule" AUTO)
tri_option(CHIAKI_USE_SYSTEM_CURL "Use system-provided curl instead of submodule. Has to be built with experimental WebSocket support!" OFF)
# Pylux semver — single source for packaging (Android, iOS CI archive, macOS App Store bundle, etc.).
# ios/Pylux.xcodeproj uses MARKETING_VERSION=0.0.0 and CURRENT_PROJECT_VERSION=0 only as local placeholders;
# CI injects real values from the CHIAKI_VERSION_* lines below at archive time (.github/workflows/deploy-ios.yml).
set(CHIAKI_VERSION_MAJOR 2)
set(CHIAKI_VERSION_MINOR 10)
set(CHIAKI_VERSION_PATCH 21)
set(CHIAKI_VERSION ${CHIAKI_VERSION_MAJOR}.${CHIAKI_VERSION_MINOR}.${CHIAKI_VERSION_PATCH})
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/lib/include/chiaki/version.h.in"
"${CMAKE_CURRENT_SOURCE_DIR}/lib/include/chiaki/version.h"
)
set(CPACK_PACKAGE_NAME "pylux")
set(CPACK_PACKAGE_DESCRIPTION "Remote Play Client")
set(CPACK_PACKAGE_VERSION_MAJOR ${CHIAKI_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${CHIAKI_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${CHIAKI_VERSION_PATCH})
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION})
set(CPACK_DEBIAN_PACKAGE_SECTION "games")
include(CPack)
set(CHIAKI_IS_SWITCH ${NSWITCH})
if(CHIAKI_ENABLE_IOS)
set(IOS TRUE)
set(CHIAKI_ENABLE_TESTS OFF CACHE BOOL "" FORCE)
set(CHIAKI_ENABLE_CLI OFF CACHE BOOL "" FORCE)
set(CHIAKI_ENABLE_GUI OFF CACHE BOOL "" FORCE)
set(CHIAKI_ENABLE_BOREALIS OFF CACHE BOOL "" FORCE)
set(CHIAKI_ENABLE_SETSU OFF CACHE STRING "" FORCE)
set(CHIAKI_ENABLE_FFMPEG_DECODER OFF CACHE STRING "" FORCE)
set(CHIAKI_ENABLE_PI_DECODER OFF CACHE STRING "" FORCE)
set(CHIAKI_ENABLE_STEAMDECK_NATIVE OFF CACHE STRING "" FORCE)
set(CHIAKI_ENABLE_STEAM_SHORTCUT OFF CACHE BOOL "" FORCE)
set(CHIAKI_ENABLE_RUDP ON CACHE STRING "" FORCE)
set(CHIAKI_LIB_ENABLE_MBEDTLS ON CACHE BOOL "" FORCE)
set(CHIAKI_LIB_MBEDTLS_EXTERNAL_PROJECT ON CACHE BOOL "" FORCE)
message(STATUS "iOS build: lib only, mbedTLS, RUDP enabled")
endif()
if(APPLE)
if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "arm64")
set(CMAKE_OSX_DEPLOYMENT_TARGET 13.0 CACHE STRING "Minimum OS X deployment version" FORCE)
else()
set(CMAKE_OSX_DEPLOYMENT_TARGET 12.0 CACHE STRING "Minimum OS X deployment version" FORCE)
endif()
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_CURRENT_SOURCE_DIR}/setsu/cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_CURRENT_SOURCE_DIR}/steamdeck_native/cmake")
set(CMAKE_CXX_STANDARD 11)
if(CHIAKI_IS_SWITCH)
# force mbedtls as crypto lib
set(CHIAKI_LIB_ENABLE_MBEDTLS ON)
add_definitions(-D__SWITCH__)
endif()
if(CHIAKI_USE_SYSTEM_JERASURE)
if(CHIAKI_USE_SYSTEM_JERASURE STREQUAL AUTO)
find_package(Jerasure QUIET)
set(CHIAKI_USE_SYSTEM_JERASURE ${Jerasure_FOUND})
else()
find_package(Jerasure REQUIRED)
set(CHIAKI_USE_SYSTEM_JERASURE ON)
endif()
endif()
if(CHIAKI_ENABLE_GUI)
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBPLACEBO REQUIRED libplacebo IMPORTED_TARGET)
endif()
if(CHIAKI_USE_SYSTEM_CURL)
if (CHIAKI_USE_SYSTEM_CURL STREQUAL AUTO)
find_package(CURL COMPONENTS HTTP HTTPS WS WSS QUIET)
set(CHIAKI_USE_SYSTEM_CURL ${CURL_FOUND})
else()
find_package(CURL REQUIRED COMPONENTS HTTP HTTPS WS WSS)
set(CHIAKI_USE_SYSTEM_CURL ON)
endif()
endif()
if(CHIAKI_ENABLE_SPEEX)
set(SpeexDSP_FOUND FALSE)
find_package(SpeexDSP QUIET)
pkg_check_modules(SpeexDSP speexdsp IMPORTED_TARGET)
if(SpeexDSP_FOUND)
set(CHIAKI_ENABLE_SPEEX ON)
message(STATUS "Speex DSP found echo cancelling and noise suppression enabled")
else()
set(CHIAKI_ENABLE_SPEEX OFF)
message(STATUS "Speex DSP not found echo cancelling and noise suppression disabled")
endif()
endif()
find_package(PythonInterp 3 REQUIRED) # Make sure nanopb doesn't find Python 2.7 because Python 2 should just die.
if(CHIAKI_USE_SYSTEM_NANOPB)
if(CHIAKI_USE_SYSTEM_NANOPB STREQUAL AUTO)
find_package(Nanopb QUIET)
set(CHIAKI_USE_SYSTEM_NANOPB ${Nanopb_FOUND})
else()
find_package(Nanopb REQUIRED)
set(CHIAKI_USE_SYSTEM_NANOPB ON)
endif()
endif()
add_definitions(-DCHIAKI_VERSION_MAJOR=${CHIAKI_VERSION_MAJOR} -DCHIAKI_VERSION_MINOR=${CHIAKI_VERSION_MINOR} -DCHIAKI_VERSION_PATCH=${CHIAKI_VERSION_PATCH} -DCHIAKI_VERSION=\"${CHIAKI_VERSION}\")
if(CHIAKI_LIB_OPENSSL_EXTERNAL_PROJECT)
include(OpenSSLExternalProject)
endif()
# mbedTLS must be fetched BEFORE third-party so curl can use it for SSL
if(CHIAKI_LIB_ENABLE_MBEDTLS)
add_definitions(-DCHIAKI_LIB_ENABLE_MBEDTLS)
if(CHIAKI_LIB_MBEDTLS_EXTERNAL_PROJECT)
set(FETCHCONTENT_QUIET CACHE BOOL FALSE)
include(FetchContent)
set(ENABLE_TESTING CACHE INTERNAL OFF)
set(ENABLE_PROGRAMS CACHE INTERNAL OFF)
set(USE_SHARED_MBEDTLS_LIBRARY CACHE INTERNAL OFF)
# Android/iOS: Disable PSA crypto to avoid crypto_sizes.h generation issues
# (Switch and other platforms can keep PSA enabled if needed)
if(ANDROID OR IOS)
set(MBEDTLS_PSA_CRYPTO_C OFF CACHE BOOL "Disable PSA Crypto API" FORCE)
endif()
FetchContent_Declare(
mbedtls
GIT_REPOSITORY https://github.com/Mbed-TLS/mbedtls.git
GIT_TAG 8b3f26a5ac38d4fdccbc5c5366229f3e01dafcc0 # v2.28.0
GIT_PROGRESS TRUE
)
if(ANDROID OR IOS)
# Android/iOS: Use manual FetchContent approach to inject compiler flags before building mbedTLS
# Android: NDK r28+ treats documentation warnings as errors
# iOS: Xcode clang treats -Wunused-but-set-variable as error with mbedTLS's -Werror
FetchContent_GetProperties(mbedtls)
if(NOT mbedtls_POPULATED)
FetchContent_Populate(mbedtls)
# Set flags that will be used when mbedTLS configures itself
set(ENABLE_TESTING OFF CACHE BOOL "Enable mbedTLS testing" FORCE)
set(ENABLE_PROGRAMS OFF CACHE BOOL "Enable mbedTLS programs" FORCE)
# Override CMAKE_C_FLAGS and CMAKE_CXX_FLAGS for mbedTLS build
set(CMAKE_C_FLAGS_BACKUP "${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS_BACKUP "${CMAKE_CXX_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-documentation -Wno-unused-but-set-variable -Wno-error=documentation -Wno-error=unused-but-set-variable")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-documentation -Wno-unused-but-set-variable -Wno-error=documentation -Wno-error=unused-but-set-variable")
endif()
# Configure mbedTLS as a subdirectory so we can control its build
add_subdirectory(${mbedtls_SOURCE_DIR} ${mbedtls_BINARY_DIR})
# Restore original flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS_BACKUP}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_BACKUP}")
else()
# Non-Android platforms: Use standard FetchContent approach
FetchContent_MakeAvailable(mbedtls)
endif()
endif()
endif()
# third-party must come after mbedTLS so curl can use mbedTLS for SSL
add_subdirectory(third-party)
if(CHIAKI_ENABLE_STEAM_SHORTCUT)
message(STATUS "Steam shortcut enabled")
else()
message(STATUS "Steam shortcut disabled")
endif()
if(CHIAKI_ENABLE_FFMPEG_DECODER)
find_package(FFMPEG COMPONENTS avcodec avutil avformat)
if(FFMPEG_FOUND)
set(CHIAKI_ENABLE_FFMPEG_DECODER ON)
else()
if(NOT CHIAKI_ENABLE_FFMPEG_DECODER STREQUAL AUTO)
message(FATAL_ERROR "CHIAKI_ENABLE_FFMPEG_DECODER is set to ON, but ffmpeg could not be found.")
endif()
set(CHIAKI_ENABLE_FFMPEG_DECODER OFF)
endif()
endif()
if(CHIAKI_ENABLE_FFMPEG_DECODER)
message(STATUS "FFMPEG Decoder enabled")
else()
message(STATUS "FFMPEG Decoder disabled")
endif()
if(CHIAKI_ENABLE_PI_DECODER)
find_package(ILClient)
if(ILClient_FOUND)
set(CHIAKI_ENABLE_PI_DECODER ON)
else()
if(NOT CHIAKI_ENABLE_PI_DECODER STREQUAL AUTO)
message(FATAL_ERROR "
CHIAKI_ENABLE_PI_DECODER is set to ON, but its dependencies (ilclient source and libs) could not be resolved.
The Raspberry Pi Decoder is only supported on Raspberry Pi OS and requires libraspberrypi0 and libraspberrypi-doc.")
endif()
set(CHIAKI_ENABLE_PI_DECODER OFF)
endif()
endif()
if(CHIAKI_ENABLE_PI_DECODER)
message(STATUS "Pi Decoder enabled")
else()
message(STATUS "Pi Decoder disabled")
endif()
add_subdirectory(lib)
if(CHIAKI_ENABLE_CLI)
add_subdirectory(cli)
endif()
if(CHIAKI_ENABLE_STEAMDECK_NATIVE AND NOT ANDROID)
find_package(HIDAPI QUIET)
find_package(PkgConfig REQUIRED)
pkg_search_module(FFTW REQUIRED fftw3 IMPORTED_TARGET)
if(HIDAPI_FOUND AND FFTW_FOUND)
set(CHIAKI_ENABLE_STEAMDECK_NATIVE ON)
else()
if(NOT CHIAKI_ENABLE_STEAMDECK_NATIVE STREQUAL AUTO)
if(NOT HIDAPI_FOUND AND NOT FFTW_FOUND)
message(FATAL_ERROR "
CHIAKI_ENABLE_STEAMDECK_NATIVE is set to ON, but its dependencies (HIDAPI & FFTW3) could not be resolved.")
endif()
if(NOT HIDAPI_FOUND)
message(FATAL_ERROR "
CHIAKI_ENABLE_STEAMDECK_NATIVE is set to ON, but its dependency (HIDAPI) could not be resolved.")
endif()
if(NOT FFTW_FOUND)
message(FATAL_ERROR "
CHIAKI_ENABLE_STEAMDECK_NATIVE is set to ON, but its dependency (FFTW3) could not be resolved.")
endif()
endif()
set(CHIAKI_ENABLE_STEAMDECK_NATIVE OFF)
endif()
if(CHIAKI_ENABLE_STEAMDECK_NATIVE)
add_subdirectory(steamdeck_native)
endif()
endif()
if(CHIAKI_ENABLE_STEAMDECK_NATIVE)
message(STATUS "Steamdeck native gyro and haptics enabled")
else()
message(STATUS "Steamdeck native gyro and hatpics disabled")
endif()
if(CHIAKI_ENABLE_GUI)
find_package(SDL2 MODULE REQUIRED)
endif()
if(CHIAKI_ENABLE_SETSU)
if(CHIAKI_ENABLE_SETSU STREQUAL AUTO AND SDL2_FOUND AND (SDL2_VERSION_MINOR GREATER 0 OR SDL2_VERSION_PATCH GREATER_EQUAL 14))
message(STATUS "SDL version ${SDL2_VERSION} is >= 2.0.14, disabling Setsu")
set(CHIAKI_ENABLE_SETSU OFF)
else()
find_package(Udev QUIET)
find_package(Evdev QUIET)
if(Udev_FOUND AND Evdev_FOUND)
set(CHIAKI_ENABLE_SETSU ON)
else()
if(NOT CHIAKI_ENABLE_SETSU STREQUAL AUTO)
message(FATAL_ERROR "
CHIAKI_ENABLE_SETSU is set to ON, but its dependencies (udev and evdev) could not be resolved.
Keep in mind that setsu is only supported on Linux!")
endif()
set(CHIAKI_ENABLE_SETSU OFF)
endif()
if(CHIAKI_ENABLE_SETSU)
add_subdirectory(setsu)
endif()
endif()
endif()
if(CHIAKI_ENABLE_SETSU)
message(STATUS "Setsu enabled")
else()
message(STATUS "Setsu disabled")
endif()
if(CHIAKI_ENABLE_GUI)
add_subdirectory(gui)
endif()
if(CHIAKI_ENABLE_TESTS)
enable_testing()
add_subdirectory(test)
endif()
if(CHIAKI_ENABLE_ANDROID)
add_subdirectory(android/app)
endif()
if(CHIAKI_ENABLE_BOREALIS)
add_subdirectory(switch)
endif()