@@ -4,15 +4,6 @@ project(Sunshine)
4
4
5
5
set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} /cmake)
6
6
7
- add_subdirectory (third-party/Simple-Web-Server)
8
-
9
- set (UPNPC_BUILD_SHARED OFF CACHE BOOL "no shared libraries" )
10
- set (UPNPC_BUILD_TESTS OFF CACHE BOOL "Don't build tests for miniupnpc" )
11
- set (UPNPC_BUILD_SAMPLE OFF CACHE BOOL "Don't build samples for miniupnpc" )
12
- set (UPNPC_NO_INSTALL ON CACHE BOOL "Don't install any libraries build for miniupnpc" )
13
- add_subdirectory (third-party/miniupnp/miniupnpc)
14
- include_directories (third-party/miniupnp)
15
-
16
7
if (WIN32 )
17
8
# Ugly hack to compile with #include <qos2.h>
18
9
add_compile_definitions (
@@ -21,11 +12,21 @@ if(WIN32)
21
12
QOS_NON_ADAPTIVE_FLOW=2)
22
13
endif ()
23
14
add_subdirectory (third-party/moonlight-common-c/enet)
15
+ add_subdirectory (third-party/Simple-Web-Server)
16
+
17
+ set (UPNPC_BUILD_SHARED OFF CACHE BOOL "no shared libraries" )
18
+ set (UPNPC_BUILD_TESTS OFF CACHE BOOL "Don't build tests for miniupnpc" )
19
+ set (UPNPC_BUILD_SAMPLE OFF CACHE BOOL "Don't build samples for miniupnpc" )
20
+ set (UPNPC_NO_INSTALL ON CACHE BOOL "Don't install any libraries build for miniupnpc" )
21
+ add_subdirectory (third-party/miniupnp/miniupnpc)
22
+ include_directories (third-party/miniupnp)
24
23
25
24
find_package (Threads REQUIRED)
26
25
find_package (OpenSSL REQUIRED)
26
+ set (Boost_USE_STATIC_LIBS ON )
27
+ find_package (Boost COMPONENTS log filesystem REQUIRED)
27
28
28
- list (APPEND SUNSHINE_COMPILE_OPTIONS -fPIC - Wall -Wno-missing-braces -Wno-maybe-uninitialized -Wno-sign-compare)
29
+ list (APPEND SUNSHINE_COMPILE_OPTIONS -Wall -Wno-missing-braces -Wno-maybe-uninitialized -Wno-sign-compare)
29
30
30
31
if (WIN32 )
31
32
file (
@@ -105,12 +106,28 @@ else()
105
106
option (SUNSHINE_ENABLE_DRM "Enable KMS grab if available" ON )
106
107
option (SUNSHINE_ENABLE_X11 "Enable X11 grab if available" ON )
107
108
option (SUNSHINE_ENABLE_WAYLAND "Enable building wayland specific code" ON )
109
+ option (SUNSHINE_ENABLE_CUDA "Enable cuda specific code" ON )
108
110
109
111
if (${SUNSHINE_ENABLE_X11} )
110
112
find_package (X11)
111
113
else ()
112
114
set (X11_FOUND OFF )
113
115
endif ()
116
+
117
+ set (CUDA_FOUND OFF )
118
+ if (${SUNSHINE_ENABLE_CUDA} )
119
+ include (CheckLanguage)
120
+ check_language(CUDA)
121
+
122
+ if (CMAKE_CUDA_COMPILER)
123
+ if (NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
124
+ set (CMAKE_CUDA_ARCHITECTURES 35)
125
+ endif ()
126
+
127
+ set (CUDA_FOUND ON )
128
+ enable_language (CUDA)
129
+ endif ()
130
+ endif ()
114
131
if (${SUNSHINE_ENABLE_DRM} )
115
132
find_package (LIBDRM)
116
133
find_package (LIBCAP)
@@ -131,6 +148,17 @@ else()
131
148
include_directories (${X11_INCLUDE_DIR} )
132
149
list (APPEND PLATFORM_TARGET_FILES sunshine/platform/linux/x11grab.cpp)
133
150
endif ()
151
+
152
+ if (CUDA_FOUND)
153
+ include_directories (third-party/nvfbc)
154
+ list (APPEND PLATFORM_TARGET_FILES
155
+ sunshine/platform/linux/cuda.cu
156
+ sunshine/platform/linux/cuda.cpp
157
+ third-party/nvfbc/NvFBC.h)
158
+
159
+ add_compile_definitions (SUNSHINE_BUILD_CUDA)
160
+ endif ()
161
+
134
162
if (LIBDRM_FOUND AND LIBCAP_FOUND)
135
163
add_compile_definitions (SUNSHINE_BUILD_DRM)
136
164
include_directories (${LIBDRM_INCLUDE_DIRS} ${LIBCAP_INCLUDE_DIRS} )
@@ -180,14 +208,15 @@ else()
180
208
sunshine/platform/linux/wlgrab.cpp
181
209
sunshine/platform/linux/wayland.cpp)
182
210
endif ()
183
- if (NOT ${X11_FOUND} AND NOT (${LIBDRM_FOUND} AND ${LIBCAP_FOUND} ) AND NOT ${WAYLAND_FOUND} )
184
- message (FATAL_ERROR "Couldn't find either x11, wayland or (libdrm and libcap)" )
211
+ if (NOT ${X11_FOUND} AND NOT (${LIBDRM_FOUND} AND ${LIBCAP_FOUND} ) AND NOT ${WAYLAND_FOUND} AND NOT ${} )
212
+ message (FATAL_ERROR "Couldn't find either x11, wayland, cuda or (libdrm and libcap)" )
185
213
endif ()
186
214
187
215
list (APPEND PLATFORM_TARGET_FILES
188
216
sunshine/platform/linux/publish.cpp
189
217
sunshine/platform/linux/vaapi.h
190
218
sunshine/platform/linux/vaapi.cpp
219
+ sunshine/platform/linux/cuda.h
191
220
sunshine/platform/linux/graphics.h
192
221
sunshine/platform/linux/graphics.cpp
193
222
sunshine/platform/linux/misc.h
@@ -212,6 +241,7 @@ else()
212
241
213
242
include_directories (
214
243
/usr/include /libevdev-1.0
244
+ third-party/nv-codec-headers/include
215
245
third-party/glad/include )
216
246
217
247
if (NOT DEFINED SUNSHINE_EXECUTABLE_PATH)
@@ -221,11 +251,6 @@ else()
221
251
configure_file (sunshine.service.in sunshine.service @ONLY)
222
252
endif ()
223
253
224
- add_subdirectory (third-party/cbs)
225
-
226
- set (Boost_USE_STATIC_LIBS ON )
227
- find_package (Boost COMPONENTS log filesystem REQUIRED)
228
-
229
254
set (SUNSHINE_TARGET_FILES
230
255
third-party/moonlight-common-c/reedsolomon/rs.c
231
256
third-party/moonlight-common-c/reedsolomon/rs.h
@@ -285,9 +310,11 @@ include_directories(
285
310
${PLATFORM_INCLUDE_DIRS}
286
311
)
287
312
313
+ add_subdirectory (third-party/cbs)
314
+
288
315
string (TOUPPER "x${CMAKE_BUILD_TYPE} " BUILD_TYPE )
289
316
if ("${BUILD_TYPE} " STREQUAL "XDEBUG" )
290
- list (APPEND SUNSHINE_COMPILE_OPTIONS -O0 -pedantic - ggdb3)
317
+ list (APPEND SUNSHINE_COMPILE_OPTIONS -O0 -ggdb3)
291
318
if (WIN32 )
292
319
set_source_files_properties (sunshine/nvhttp.cpp PROPERTIES COMPILE_FLAGS -O2)
293
320
endif ()
@@ -323,12 +350,20 @@ list(APPEND SUNSHINE_EXTERNAL_LIBRARIES
323
350
${OPENSSL_LIBRARIES}
324
351
${PLATFORM_LIBRARIES} )
325
352
353
+ add_compile_options ("$<$<COMPILE_LANGUAGE:CXX>:${SUNSHINE_COMPILE_OPTIONS} >" )
354
+ add_compile_options ("$<$<COMPILE_LANGUAGE:CXX>:-std=c++17>" )
355
+ add_compile_options ("$<$<COMPILE_LANGUAGE:C>:${SUNSHINE_COMPILE_OPTIONS} >" )
356
+
357
+ foreach (flag IN LISTS SUNSHINE_COMPILE_OPTIONS)
358
+ add_compile_options ($<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=${flag} >)
359
+ endforeach ()
360
+ add_compile_options ($<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=-std=c++14>)
361
+ add_compile_options ($<$<COMPILE_LANGUAGE:CUDA>:-std=c++14>)
362
+
326
363
list (APPEND SUNSHINE_DEFINITIONS SUNSHINE_ASSETS_DIR="${SUNSHINE_ASSETS_DIR} " )
327
364
list (APPEND SUNSHINE_DEFINITIONS SUNSHINE_CONFIG_DIR="${SUNSHINE_CONFIG_DIR} " )
328
365
list (APPEND SUNSHINE_DEFINITIONS SUNSHINE_DEFAULT_DIR="${SUNSHINE_DEFAULT_DIR} " )
329
366
add_executable (sunshine ${SUNSHINE_TARGET_FILES} )
330
367
target_link_libraries (sunshine ${SUNSHINE_EXTERNAL_LIBRARIES} )
331
368
target_compile_definitions (sunshine PUBLIC ${SUNSHINE_DEFINITIONS} )
332
- set_target_properties (sunshine PROPERTIES CXX_STANDARD 17)
333
-
334
- target_compile_options (sunshine PRIVATE ${SUNSHINE_COMPILE_OPTIONS} )
369
+ # set_target_properties(sunshine PROPERTIES CXX_STANDARD 17)
0 commit comments