2021-04-26 14:46:57 +02:00
cmake_minimum_required ( VERSION 3.0 )
2019-12-03 20:23:33 +01:00
2022-12-12 21:16:19 -05:00
project ( Sunshine VERSION 0.16.0
2022-05-06 14:39:26 -04:00
D E S C R I P T I O N " S u n s h i n e i s a G a m e s t r e a m h o s t f o r M o o n l i g h t . "
2022-07-29 09:45:26 -04:00
H O M E P A G E _ U R L " h t t p s : / / a p p . l i z a r d b y t e . d e v "
2022-05-06 14:24:39 -04:00
)
2019-12-03 20:23:33 +01:00
2022-06-20 22:53:40 -04:00
set ( PROJECT_LONG_DESCRIPTION " Sunshine is a self hosted, low latency, cloud gaming solution with support for AMD, \
2022-06-28 19:16:24 -04:00
I n t e l , a n d N v i d i a G P U s . I t i s a n o p e n s o u r c e i m p l e m e n t a t i o n o f N V I D I A ' s G a m e S t r e a m , a s u s e d b y t h e N V I D I A S h i e l d . \
2022-06-20 22:53:40 -04:00
C o n n e c t t o S u n s h i n e f r o m a n y M o o n l i g h t c l i e n t , a v a i l a b l e f o r n e a r l y a n y d e v i c e i m a g i n a b l e . " )
2022-08-23 20:08:14 -04:00
option ( SUNSHINE_CONFIGURE_APPIMAGE "Configuration specific for AppImage." OFF )
2022-06-18 20:46:59 -04:00
option ( SUNSHINE_CONFIGURE_AUR "Configure files required for AUR." OFF )
2022-08-23 20:08:14 -04:00
option ( SUNSHINE_CONFIGURE_FLATPAK_MAN "Configure manifest file required for Flatpak build." OFF )
option ( SUNSHINE_CONFIGURE_FLATPAK "Configuration specific for Flatpak." OFF )
2022-06-28 19:16:24 -04:00
option ( SUNSHINE_CONFIGURE_PORTFILE "Configure macOS Portfile." OFF )
2022-06-17 16:30:59 -04:00
option ( SUNSHINE_CONFIGURE_ONLY "Configure special files only, then exit." OFF )
2022-06-15 21:50:02 -04:00
if ( ${ SUNSHINE_CONFIGURE_APPIMAGE } )
configure_file ( packaging/linux/sunshine.desktop sunshine.desktop @ONLY )
2022-06-18 20:46:59 -04:00
elseif ( ${ SUNSHINE_CONFIGURE_AUR } )
2022-06-19 16:20:25 -04:00
configure_file ( packaging/linux/aur/PKGBUILD PKGBUILD @ONLY )
2022-08-23 20:08:14 -04:00
elseif ( ${ SUNSHINE_CONFIGURE_FLATPAK_MAN } )
2022-07-29 09:45:26 -04:00
configure_file ( packaging/linux/flatpak/dev.lizardbyte.sunshine.yml dev.lizardbyte.sunshine.yml @ONLY )
2022-06-15 21:50:02 -04:00
elseif ( ${ SUNSHINE_CONFIGURE_PORTFILE } )
configure_file ( packaging/macos/Portfile Portfile @ONLY )
endif ( )
# return if configure only is set
if ( ${ SUNSHINE_CONFIGURE_ONLY } )
return ( )
endif ( )
2021-08-03 20:31:27 +02:00
set ( CMAKE_MODULE_PATH ${ CMAKE_CURRENT_SOURCE_DIR } /cmake )
2022-05-11 21:31:31 -04:00
set ( SUNSHINE_SOURCE_ASSETS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src_assets" )
2019-12-08 18:55:58 +01:00
2022-02-24 21:09:00 +01:00
if ( APPLE )
macro ( ADD_FRAMEWORK fwname appname )
find_library ( FRAMEWORK_ ${ fwname }
N A M E S $ { f w n a m e }
P A T H S $ { C M A K E _ O S X _ S Y S R O O T } / S y s t e m / L i b r a r y
P A T H _ S U F F I X E S F r a m e w o r k s
N O _ D E F A U L T _ P A T H )
if ( ${ FRAMEWORK_${fwname } } STREQUAL FRAMEWORK_ ${ fwname } -NOTFOUND )
MESSAGE ( ERROR ": Framework ${fwname} not found" )
else ( )
TARGET_LINK_LIBRARIES ( ${ appname } "${FRAMEWORK_${fwname}}/${fwname}" )
MESSAGE ( STATUS "Framework ${fwname} found at ${FRAMEWORK_${fwname}}" )
endif ( )
endmacro ( ADD_FRAMEWORK )
endif ( )
2021-06-11 11:59:19 +02:00
add_subdirectory ( third-party/moonlight-common-c/enet )
2021-09-19 20:40:34 +02:00
add_subdirectory ( third-party/Simple-Web-Server )
set ( UPNPC_BUILD_SHARED OFF CACHE BOOL "no shared libraries" )
set ( UPNPC_BUILD_TESTS OFF CACHE BOOL "Don't build tests for miniupnpc" )
set ( UPNPC_BUILD_SAMPLE OFF CACHE BOOL "Don't build samples for miniupnpc" )
set ( UPNPC_NO_INSTALL ON CACHE BOOL "Don't install any libraries build for miniupnpc" )
add_subdirectory ( third-party/miniupnp/miniupnpc )
2022-12-16 18:48:09 -05:00
include_directories ( third-party/miniupnp/miniupnpc/include )
2020-01-10 22:19:50 +01:00
2020-01-01 18:47:34 +01:00
find_package ( Threads REQUIRED )
find_package ( OpenSSL REQUIRED )
2022-11-19 01:07:22 +09:00
find_package ( PkgConfig REQUIRED )
pkg_check_modules ( CURL REQUIRED libcurl )
2022-02-24 21:09:00 +01:00
if ( NOT APPLE )
set ( Boost_USE_STATIC_LIBS ON )
endif ( )
2021-09-19 20:40:34 +02:00
find_package ( Boost COMPONENTS log filesystem REQUIRED )
2020-01-26 21:35:45 +01:00
2021-09-25 22:31:39 +02:00
list ( APPEND SUNSHINE_COMPILE_OPTIONS -Wall -Wno-missing-braces -Wno-maybe-uninitialized -Wno-sign-compare )
2020-01-26 21:35:45 +01:00
2020-01-01 18:47:34 +01:00
if ( WIN32 )
2021-10-03 21:12:06 +02:00
enable_language ( RC )
set ( CMAKE_RC_COMPILER windres )
2021-04-26 14:46:57 +02:00
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static" )
2022-11-19 01:07:22 +09:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CURL_STATIC_LDFLAGS} ${CURL_STATIC_CFLAGS}" )
2022-04-23 15:13:27 +01:00
2022-12-27 04:20:46 +00:00
# WORKAROUND: /mingw64/include/_mingw.h r186 defines _WIN32_WINNT=0x601, but boost
# is built against version 0x603 (BOOST_WINAPI_VERSION_WINBLUE) from r157 header.
ADD_DEFINITIONS ( -DBOOST_USE_WINAPI_VERSION=BOOST_WINAPI_VERSION_WINBLUE )
2021-05-17 21:30:03 +02:00
add_compile_definitions ( SUNSHINE_PLATFORM= "windows" )
2022-08-12 19:26:17 -04:00
add_subdirectory ( tools ) # This is temporary, only tools for Windows are needed, for now
2020-01-23 23:43:39 +01:00
2021-06-12 19:51:58 +02:00
include_directories ( third-party/ViGEmClient/include )
2021-04-26 14:46:57 +02:00
2021-10-03 21:12:06 +02:00
if ( NOT DEFINED SUNSHINE_ICON_PATH )
set ( SUNSHINE_ICON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/sunshine.ico" )
endif ( )
2022-08-07 23:37:57 -04:00
configure_file ( src/platform/windows/windows.rs.in windows.rc @ONLY )
2020-01-01 18:47:34 +01:00
set ( PLATFORM_TARGET_FILES
2021-10-03 21:12:06 +02:00
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / w i n d o w s . r c "
2022-08-07 23:37:57 -04:00
s r c / p l a t f o r m / w i n d o w s / p u b l i s h . c p p
s r c / p l a t f o r m / w i n d o w s / m i s c . h
s r c / p l a t f o r m / w i n d o w s / m i s c . c p p
s r c / p l a t f o r m / w i n d o w s / i n p u t . c p p
s r c / p l a t f o r m / w i n d o w s / d i s p l a y . h
s r c / p l a t f o r m / w i n d o w s / d i s p l a y _ b a s e . c p p
s r c / p l a t f o r m / w i n d o w s / d i s p l a y _ v r a m . c p p
s r c / p l a t f o r m / w i n d o w s / d i s p l a y _ r a m . c p p
s r c / p l a t f o r m / w i n d o w s / a u d i o . c p p
2021-06-11 11:59:19 +02:00
t h i r d - p a r t y / V i G E m C l i e n t / s r c / V i G E m C l i e n t . c p p
t h i r d - p a r t y / V i G E m C l i e n t / i n c l u d e / V i G E m / C l i e n t . h
t h i r d - p a r t y / V i G E m C l i e n t / i n c l u d e / V i G E m / C o m m o n . h
t h i r d - p a r t y / V i G E m C l i e n t / i n c l u d e / V i G E m / U t i l . h
t h i r d - p a r t y / V i G E m C l i e n t / i n c l u d e / V i G E m / k m / B u s S h a r e d . h )
2021-04-26 14:46:57 +02:00
2021-04-26 20:36:54 +02:00
set ( OPENSSL_LIBRARIES
l i b s s l . a
l i b c r y p t o . a )
2020-01-26 21:35:45 +01:00
list ( PREPEND PLATFORM_LIBRARIES
2021-04-26 14:46:57 +02:00
l i b s t d c + + . a
l i b w i n p t h r e a d . a
l i b s s p . a
2020-01-15 18:31:28 +01:00
k s u s e r
2020-01-01 18:47:34 +01:00
w s o c k 3 2
2020-01-07 23:15:55 +01:00
w s 2 _ 3 2
2021-04-30 20:01:15 +02:00
d 3 d 1 1 d x g i D 3 D C o m p i l e r
2020-01-26 21:35:45 +01:00
s e t u p a p i
2022-05-18 18:20:33 +01:00
d w m a p i
2022-12-17 20:16:35 +00:00
s y n c h r o n i z a t i o n . l i b
2022-11-19 01:07:22 +09:00
$ { C U R L _ S T A T I C _ L I B R A R I E S }
2020-01-26 21:35:45 +01:00
)
2021-06-12 19:51:58 +02:00
set_source_files_properties ( third-party/ViGEmClient/src/ViGEmClient.cpp PROPERTIES COMPILE_DEFINITIONS "UNICODE=1;ERROR_INVALID_DEVICE_OBJECT_PARAMETER=650" )
set_source_files_properties ( third-party/ViGEmClient/src/ViGEmClient.cpp PROPERTIES COMPILE_FLAGS "-Wno-unknown-pragmas -Wno-misleading-indentation -Wno-class-memaccess" )
2022-02-24 21:09:00 +01:00
elseif ( APPLE )
add_compile_definitions ( SUNSHINE_PLATFORM= "macos" )
2022-06-22 19:20:04 -04:00
option ( SUNSHINE_MACOS_PACKAGE "Should only be used when creating a MACOS package/dmg." OFF )
2022-02-24 21:09:00 +01:00
link_directories ( /opt/local/lib )
2022-04-30 19:20:16 -04:00
link_directories ( /usr/local/lib )
2022-02-24 21:09:00 +01:00
ADD_DEFINITIONS ( -DBOOST_LOG_DYN_LINK )
FIND_LIBRARY ( APP_SERVICES_LIBRARY ApplicationServices )
FIND_LIBRARY ( AV_FOUNDATION_LIBRARY AVFoundation )
FIND_LIBRARY ( CORE_MEDIA_LIBRARY CoreMedia )
FIND_LIBRARY ( CORE_VIDEO_LIBRARY CoreVideo )
2022-12-11 17:46:19 -05:00
FIND_LIBRARY ( VIDEO_TOOLBOX_LIBRARY VideoToolbox )
2022-02-24 21:09:00 +01:00
FIND_LIBRARY ( FOUNDATION_LIBRARY Foundation )
list ( APPEND SUNSHINE_EXTERNAL_LIBRARIES
$ { A P P _ S E R V I C E S _ L I B R A R Y }
$ { A V _ F O U N D A T I O N _ L I B R A R Y }
$ { C O R E _ M E D I A _ L I B R A R Y }
$ { C O R E _ V I D E O _ L I B R A R Y }
2022-12-11 17:46:19 -05:00
$ { V I D E O _ T O O L B O X _ L I B R A R Y }
2022-02-24 21:09:00 +01:00
$ { F O U N D A T I O N _ L I B R A R Y } )
set ( PLATFORM_INCLUDE_DIRS
$ { B o o s t _ I N C L U D E _ D I R } )
2022-05-11 21:31:31 -04:00
set ( APPLE_PLIST_FILE ${ SUNSHINE_SOURCE_ASSETS_DIR } /macos/assets/Info.plist )
2022-02-24 21:09:00 +01:00
set ( PLATFORM_TARGET_FILES
2022-08-07 23:37:57 -04:00
s r c / p l a t f o r m / m a c o s / a v _ a u d i o . h
s r c / p l a t f o r m / m a c o s / a v _ a u d i o . m
s r c / p l a t f o r m / m a c o s / a v _ i m g _ t . h
s r c / p l a t f o r m / m a c o s / a v _ v i d e o . h
s r c / p l a t f o r m / m a c o s / a v _ v i d e o . m
s r c / p l a t f o r m / m a c o s / d i s p l a y . m m
s r c / p l a t f o r m / m a c o s / i n p u t . c p p
s r c / p l a t f o r m / m a c o s / m i c r o p h o n e . m m
s r c / p l a t f o r m / m a c o s / m i s c . c p p
s r c / p l a t f o r m / m a c o s / m i s c . h
s r c / p l a t f o r m / m a c o s / n v 1 2 _ z e r o _ d e v i c e . c p p
s r c / p l a t f o r m / m a c o s / n v 1 2 _ z e r o _ d e v i c e . h
s r c / p l a t f o r m / m a c o s / p u b l i s h . c p p
2022-08-07 23:13:19 -04:00
t h i r d - p a r t y / T P C i r c u l a r B u f f e r / T P C i r c u l a r B u f f e r . c
t h i r d - p a r t y / T P C i r c u l a r B u f f e r / T P C i r c u l a r B u f f e r . h
2022-05-11 21:31:31 -04:00
$ { A P P L E _ P L I S T _ F I L E } )
2020-01-01 18:47:34 +01:00
else ( )
2021-05-17 21:30:03 +02:00
add_compile_definitions ( SUNSHINE_PLATFORM= "linux" )
2020-01-23 12:46:09 +01:00
2021-08-12 21:11:40 +02:00
option ( SUNSHINE_ENABLE_DRM "Enable KMS grab if available" ON )
option ( SUNSHINE_ENABLE_X11 "Enable X11 grab if available" ON )
2021-08-23 18:22:59 +02:00
option ( SUNSHINE_ENABLE_WAYLAND "Enable building wayland specific code" ON )
2021-09-22 14:17:08 +02:00
option ( SUNSHINE_ENABLE_CUDA "Enable cuda specific code" ON )
2021-09-19 20:40:34 +02:00
2021-08-12 21:11:40 +02:00
if ( ${ SUNSHINE_ENABLE_X11 } )
2021-08-06 15:55:38 +02:00
find_package ( X11 )
2021-08-31 21:19:02 +02:00
else ( )
set ( X11_FOUND OFF )
2021-08-06 15:55:38 +02:00
endif ( )
2021-09-22 14:17:08 +02:00
set ( CUDA_FOUND OFF )
if ( ${ SUNSHINE_ENABLE_CUDA } )
include ( CheckLanguage )
check_language ( CUDA )
if ( CMAKE_CUDA_COMPILER )
if ( NOT DEFINED CMAKE_CUDA_ARCHITECTURES )
2021-09-22 14:49:49 +02:00
set ( CMAKE_CUDA_ARCHITECTURES 35 )
2021-09-22 14:17:08 +02:00
endif ( )
set ( CUDA_FOUND ON )
enable_language ( CUDA )
endif ( )
endif ( )
2021-08-12 21:11:40 +02:00
if ( ${ SUNSHINE_ENABLE_DRM } )
2021-08-06 15:55:38 +02:00
find_package ( LIBDRM )
2021-09-04 11:45:57 +02:00
find_package ( LIBCAP )
2021-08-31 21:19:02 +02:00
else ( )
set ( LIBDRM_FOUND OFF )
2021-09-04 11:45:57 +02:00
set ( LIBCAP_FOUND OFF )
2021-08-06 15:55:38 +02:00
endif ( )
2021-08-23 18:22:59 +02:00
if ( ${ SUNSHINE_ENABLE_WAYLAND } )
find_package ( Wayland )
2021-08-31 21:19:02 +02:00
else ( )
set ( WAYLAND_FOUND OFF )
2021-08-23 18:22:59 +02:00
endif ( )
2021-08-05 21:24:52 +02:00
2021-08-03 20:31:27 +02:00
if ( X11_FOUND )
2021-08-06 15:55:38 +02:00
add_compile_definitions ( SUNSHINE_BUILD_X11 )
2021-08-03 20:31:27 +02:00
include_directories ( ${ X11_INCLUDE_DIR } )
2022-08-07 23:37:57 -04:00
list ( APPEND PLATFORM_TARGET_FILES src/platform/linux/x11grab.cpp )
2021-08-06 15:55:38 +02:00
endif ( )
2021-09-22 14:17:08 +02:00
if ( CUDA_FOUND )
include_directories ( third-party/nvfbc )
list ( APPEND PLATFORM_TARGET_FILES
2022-08-07 23:37:57 -04:00
s r c / p l a t f o r m / l i n u x / c u d a . c u
s r c / p l a t f o r m / l i n u x / c u d a . c p p
2021-09-22 14:17:08 +02:00
t h i r d - p a r t y / n v f b c / N v F B C . h )
add_compile_definitions ( SUNSHINE_BUILD_CUDA )
endif ( )
2021-09-04 11:45:57 +02:00
if ( LIBDRM_FOUND AND LIBCAP_FOUND )
2021-08-06 15:55:38 +02:00
add_compile_definitions ( SUNSHINE_BUILD_DRM )
2021-09-04 11:45:57 +02:00
include_directories ( ${ LIBDRM_INCLUDE_DIRS } ${ LIBCAP_INCLUDE_DIRS } )
list ( APPEND PLATFORM_LIBRARIES ${ LIBDRM_LIBRARIES } ${ LIBCAP_LIBRARIES } )
2022-08-07 23:37:57 -04:00
list ( APPEND PLATFORM_TARGET_FILES src/platform/linux/kmsgrab.cpp )
2021-08-03 20:31:27 +02:00
list ( APPEND SUNSHINE_DEFINITIONS EGL_NO_X11=1 )
2021-09-04 20:15:08 +02:00
elseif ( LIBDRM_FOUND )
message ( WARNING "Found libdrm, yet there is no libcap" )
elseif ( LIBDRM_FOUND )
message ( WARNING "Found libcap, yet there is no libdrm" )
2021-08-06 15:55:38 +02:00
endif ( )
2021-09-04 20:15:08 +02:00
2021-08-23 18:22:59 +02:00
if ( WAYLAND_FOUND )
2021-08-25 16:09:42 +02:00
add_compile_definitions ( SUNSHINE_BUILD_WAYLAND )
macro ( genWayland FILENAME )
2021-08-31 20:46:50 +02:00
make_directory ( ${ CMAKE_BINARY_DIR } /generated-src )
2021-08-25 16:09:42 +02:00
message ( "wayland-scanner private-code ${CMAKE_SOURCE_DIR}/third-party/wayland-protocols/${FILENAME}.xml ${CMAKE_BINARY_DIR}/generated-src/${FILENAME}.c" )
message ( "wayland-scanner client-header ${CMAKE_SOURCE_DIR}/third-party/wayland-protocols/${FILENAME}.xml ${CMAKE_BINARY_DIR}/generated-src/${FILENAME}.h" )
2021-08-23 18:22:59 +02:00
execute_process (
2021-08-25 16:09:42 +02:00
C O M M A N D w a y l a n d - s c a n n e r p r i v a t e - c o d e $ { C M A K E _ S O U R C E _ D I R } / t h i r d - p a r t y / w a y l a n d - p r o t o c o l s / $ { F I L E N A M E } . x m l $ { C M A K E _ B I N A R Y _ D I R } / g e n e r a t e d - s r c / $ { F I L E N A M E } . c
C O M M A N D w a y l a n d - s c a n n e r c l i e n t - h e a d e r $ { C M A K E _ S O U R C E _ D I R } / t h i r d - p a r t y / w a y l a n d - p r o t o c o l s / $ { F I L E N A M E } . x m l $ { C M A K E _ B I N A R Y _ D I R } / g e n e r a t e d - s r c / $ { F I L E N A M E } . h
2021-08-23 18:22:59 +02:00
R E S U L T _ V A R I A B L E E X I T _ I N T
)
if ( NOT ${ EXIT_INT } EQUAL 0 )
message ( FATAL_ERROR "wayland-scanner failed" )
endif ( )
list ( APPEND PLATFORM_TARGET_FILES
$ { C M A K E _ B I N A R Y _ D I R } / g e n e r a t e d - s r c / $ { F I L E N A M E } . c
$ { C M A K E _ B I N A R Y _ D I R } / g e n e r a t e d - s r c / $ { F I L E N A M E } . h
)
endmacro ( )
2021-08-25 16:09:42 +02:00
genWayland ( xdg-output-unstable-v1 )
genWayland ( wlr-export-dmabuf-unstable-v1 )
2021-08-23 18:22:59 +02:00
include_directories (
$ { W A Y L A N D _ I N C L U D E _ D I R S }
$ { C M A K E _ B I N A R Y _ D I R } / g e n e r a t e d - s r c
)
list ( APPEND PLATFORM_LIBRARIES ${ WAYLAND_LIBRARIES } )
2021-08-25 16:09:42 +02:00
list ( APPEND PLATFORM_TARGET_FILES
2022-08-07 23:37:57 -04:00
s r c / p l a t f o r m / l i n u x / w l g r a b . c p p
s r c / p l a t f o r m / l i n u x / w a y l a n d . c p p )
2021-08-23 18:22:59 +02:00
endif ( )
2021-09-22 14:17:08 +02:00
if ( NOT ${ X11_FOUND } AND NOT ( ${ LIBDRM_FOUND } AND ${ LIBCAP_FOUND } ) AND NOT ${ WAYLAND_FOUND } AND NOT $ {} )
message ( FATAL_ERROR "Couldn't find either x11, wayland, cuda or (libdrm and libcap)" )
2021-08-03 20:31:27 +02:00
endif ( )
list ( APPEND PLATFORM_TARGET_FILES
2022-08-07 23:37:57 -04:00
s r c / p l a t f o r m / l i n u x / p u b l i s h . c p p
s r c / p l a t f o r m / l i n u x / v a a p i . h
s r c / p l a t f o r m / l i n u x / v a a p i . c p p
s r c / p l a t f o r m / l i n u x / c u d a . h
s r c / p l a t f o r m / l i n u x / g r a p h i c s . h
s r c / p l a t f o r m / l i n u x / g r a p h i c s . c p p
s r c / p l a t f o r m / l i n u x / m i s c . h
s r c / p l a t f o r m / l i n u x / m i s c . c p p
s r c / p l a t f o r m / l i n u x / a u d i o . c p p
s r c / p l a t f o r m / l i n u x / i n p u t . c p p
s r c / p l a t f o r m / l i n u x / x 1 1 g r a b . h
s r c / p l a t f o r m / l i n u x / w a y l a n d . h
2021-06-11 11:59:19 +02:00
t h i r d - p a r t y / g l a d / s r c / e g l . c
t h i r d - p a r t y / g l a d / s r c / g l . c
t h i r d - p a r t y / g l a d / i n c l u d e / E G L / e g l p l a t f o r m . h
t h i r d - p a r t y / g l a d / i n c l u d e / K H R / k h r p l a t f o r m . h
t h i r d - p a r t y / g l a d / i n c l u d e / g l a d / g l . h
2021-09-22 14:17:08 +02:00
t h i r d - p a r t y / g l a d / i n c l u d e / g l a d / e g l . h )
2022-04-23 15:13:27 +01:00
2021-08-05 21:24:52 +02:00
list ( APPEND PLATFORM_LIBRARIES
2021-06-06 18:45:45 +02:00
d l
2020-01-01 18:47:34 +01:00
e v d e v
2022-12-11 17:46:19 -05:00
n u m a
2020-01-01 18:47:34 +01:00
p u l s e
2020-01-03 20:25:21 +01:00
p u l s e - s i m p l e
)
2022-04-23 15:13:27 +01:00
2021-08-03 20:31:27 +02:00
include_directories (
2021-06-04 21:12:06 +02:00
/ u s r / i n c l u d e / l i b e v d e v - 1 . 0
2021-09-14 11:58:21 +02:00
t h i r d - p a r t y / n v - c o d e c - h e a d e r s / i n c l u d e
2021-09-22 14:17:08 +02:00
t h i r d - p a r t y / g l a d / i n c l u d e )
2020-01-29 16:54:53 -05:00
2020-01-30 16:09:13 +01:00
if ( NOT DEFINED SUNSHINE_EXECUTABLE_PATH )
2021-07-03 18:13:05 +02:00
set ( SUNSHINE_EXECUTABLE_PATH "sunshine" )
2020-01-30 16:09:13 +01:00
endif ( )
configure_file ( sunshine.service.in sunshine.service @ONLY )
2020-01-01 18:47:34 +01:00
endif ( )
2020-01-17 16:23:20 +01:00
2022-01-23 13:05:35 -05:00
configure_file ( version.h.in version.h @ONLY )
include_directories ( ${ CMAKE_CURRENT_BINARY_DIR } )
2019-12-03 20:23:33 +01:00
set ( SUNSHINE_TARGET_FILES
2021-06-11 11:59:19 +02:00
t h i r d - p a r t y / m o o n l i g h t - c o m m o n - c / r e e d s o l o m o n / r s . c
t h i r d - p a r t y / m o o n l i g h t - c o m m o n - c / r e e d s o l o m o n / r s . h
t h i r d - p a r t y / m o o n l i g h t - c o m m o n - c / s r c / I n p u t . h
t h i r d - p a r t y / m o o n l i g h t - c o m m o n - c / s r c / R t s p . h
t h i r d - p a r t y / m o o n l i g h t - c o m m o n - c / s r c / R t s p P a r s e r . c
t h i r d - p a r t y / m o o n l i g h t - c o m m o n - c / s r c / V i d e o . h
2022-08-07 23:37:57 -04:00
s r c / u p n p . c p p
s r c / u p n p . h
s r c / c b s . c p p
s r c / u t i l i t y . h
s r c / u u i d . h
s r c / c o n f i g . h
s r c / c o n f i g . c p p
s r c / m a i n . c p p
s r c / m a i n . h
s r c / c r y p t o . c p p
s r c / c r y p t o . h
s r c / n v h t t p . c p p
s r c / n v h t t p . h
s r c / h t t p c o m m o n . c p p
s r c / h t t p c o m m o n . h
s r c / c o n f i g h t t p . c p p
s r c / c o n f i g h t t p . h
s r c / r t s p . c p p
s r c / r t s p . h
s r c / s t r e a m . c p p
s r c / s t r e a m . h
s r c / v i d e o . c p p
s r c / v i d e o . h
s r c / i n p u t . c p p
s r c / i n p u t . h
s r c / a u d i o . c p p
s r c / a u d i o . h
s r c / p l a t f o r m / c o m m o n . h
s r c / p r o c e s s . c p p
s r c / p r o c e s s . h
s r c / n e t w o r k . c p p
s r c / n e t w o r k . h
s r c / m o v e _ b y _ c o p y . h
s r c / t a s k _ p o o l . h
s r c / t h r e a d _ p o o l . h
s r c / t h r e a d _ s a f e . h
s r c / s y n c . h
s r c / r o u n d _ r o b i n . h
2019-12-08 18:55:58 +01:00
$ { P L A T F O R M _ T A R G E T _ F I L E S } )
2019-12-03 20:23:33 +01:00
2022-08-07 23:37:57 -04:00
set_source_files_properties ( src/upnp.cpp PROPERTIES COMPILE_FLAGS -Wno-pedantic )
2021-06-29 22:42:06 +02:00
2022-12-11 17:46:19 -05:00
# Pre-compiled binaries
if ( WIN32 )
set ( FFMPEG_PREPARED_BINARIES "${CMAKE_CURRENT_SOURCE_DIR}/third-party/ffmpeg-windows-x86_64" )
set ( FFMPEG_PLATFORM_LIBRARIES mfplat ole32 strmiids mfuuid )
elseif ( APPLE )
2022-12-20 14:38:50 -05:00
if ( CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64" )
set ( FFMPEG_PREPARED_BINARIES "${CMAKE_CURRENT_SOURCE_DIR}/third-party/ffmpeg-macos-aarch64" )
else ( )
set ( FFMPEG_PREPARED_BINARIES "${CMAKE_CURRENT_SOURCE_DIR}/third-party/ffmpeg-macos-x86_64" )
endif ( )
2022-12-11 17:46:19 -05:00
else ( )
if ( CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" )
set ( FFMPEG_PREPARED_BINARIES "${CMAKE_CURRENT_SOURCE_DIR}/third-party/ffmpeg-linux-aarch64" )
else ( )
set ( FFMPEG_PREPARED_BINARIES "${CMAKE_CURRENT_SOURCE_DIR}/third-party/ffmpeg-linux-x86_64" )
endif ( )
set ( FFMPEG_PLATFORM_LIBRARIES va va-drm va-x11 vdpau X11 )
endif ( )
set ( FFMPEG_INCLUDE_DIRS
$ { F F M P E G _ P R E P A R E D _ B I N A R I E S } / i n c l u d e )
if ( EXISTS ${ FFMPEG_PREPARED_BINARIES } /lib/libhdr10plus.a )
set ( HDR10_PLUS_LIBRARY
$ { F F M P E G _ P R E P A R E D _ B I N A R I E S } / l i b / l i b h d r 1 0 p l u s . a )
endif ( )
set ( FFMPEG_LIBRARIES
$ { F F M P E G _ P R E P A R E D _ B I N A R I E S } / l i b / l i b a v c o d e c . a
$ { F F M P E G _ P R E P A R E D _ B I N A R I E S } / l i b / l i b a v u t i l . a
2022-12-27 09:13:54 -05:00
$ { F F M P E G _ P R E P A R E D _ B I N A R I E S } / l i b / l i b c b s . a
$ { F F M P E G _ P R E P A R E D _ B I N A R I E S } / l i b / l i b S v t A v 1 E n c . a
2022-12-11 17:46:19 -05:00
$ { F F M P E G _ P R E P A R E D _ B I N A R I E S } / l i b / l i b s w s c a l e . a
$ { F F M P E G _ P R E P A R E D _ B I N A R I E S } / l i b / l i b x 2 6 4 . a
$ { F F M P E G _ P R E P A R E D _ B I N A R I E S } / l i b / l i b x 2 6 5 . a
$ { H D R 1 0 _ P L U S _ L I B R A R Y }
$ { F F M P E G _ P L A T F O R M _ L I B R A R I E S } )
2019-12-03 20:23:33 +01:00
include_directories (
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R }
2021-06-11 11:59:19 +02:00
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / t h i r d - p a r t y
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / t h i r d - p a r t y / m o o n l i g h t - c o m m o n - c / e n e t / i n c l u d e
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / t h i r d - p a r t y / m o o n l i g h t - c o m m o n - c / r e e d s o l o m o n
2019-12-03 20:23:33 +01:00
$ { F F M P E G _ I N C L U D E _ D I R S }
2019-12-08 18:55:58 +01:00
$ { P L A T F O R M _ I N C L U D E _ D I R S }
2019-12-03 20:23:33 +01:00
)
2020-01-17 15:44:47 +01:00
string ( TOUPPER "x${CMAKE_BUILD_TYPE}" BUILD_TYPE )
if ( "${BUILD_TYPE}" STREQUAL "XDEBUG" )
2021-09-19 20:40:34 +02:00
list ( APPEND SUNSHINE_COMPILE_OPTIONS -O0 -ggdb3 )
2020-01-03 20:25:21 +01:00
if ( WIN32 )
2022-08-07 23:37:57 -04:00
set_source_files_properties ( src/nvhttp.cpp PROPERTIES COMPILE_FLAGS -O2 )
2020-01-03 20:25:21 +01:00
endif ( )
2019-12-08 18:55:58 +01:00
else ( )
2019-12-03 20:23:33 +01:00
add_definitions ( -DNDEBUG )
list ( APPEND SUNSHINE_COMPILE_OPTIONS -O3 )
endif ( )
2022-08-12 19:26:17 -04:00
# setup assets directory
2020-01-30 06:39:12 -05:00
if ( NOT SUNSHINE_ASSETS_DIR )
2022-08-12 19:26:17 -04:00
set ( SUNSHINE_ASSETS_DIR "assets" )
2020-01-20 18:09:28 -08:00
endif ( )
2022-08-12 19:26:17 -04:00
if ( UNIX )
2022-06-17 16:30:59 -04:00
set ( SUNSHINE_ASSETS_DIR "${CMAKE_INSTALL_PREFIX}/${SUNSHINE_ASSETS_DIR}" )
2022-06-17 15:30:56 -04:00
endif ( )
2022-08-12 19:26:17 -04:00
# use relative assets path for AppImage... maybe for all unix
if ( ${ SUNSHINE_CONFIGURE_APPIMAGE } )
string ( REPLACE "${CMAKE_INSTALL_PREFIX}" ".${CMAKE_INSTALL_PREFIX}" SUNSHINE_ASSETS_DIR_DEF ${ SUNSHINE_ASSETS_DIR } )
else ( )
set ( SUNSHINE_ASSETS_DIR_DEF "${SUNSHINE_ASSETS_DIR}" )
endif ( )
list ( APPEND SUNSHINE_DEFINITIONS SUNSHINE_ASSETS_DIR= "${SUNSHINE_ASSETS_DIR_DEF}" )
2019-12-03 20:23:33 +01:00
list ( APPEND SUNSHINE_EXTERNAL_LIBRARIES
2021-06-29 22:42:06 +02:00
l i b m i n i u p n p c - s t a t i c
2019-12-03 20:23:33 +01:00
$ { C M A K E _ T H R E A D _ L I B S _ I N I T }
e n e t
2019-12-06 00:13:16 +01:00
o p u s
2019-12-08 18:55:58 +01:00
$ { F F M P E G _ L I B R A R I E S }
2020-01-01 18:47:34 +01:00
$ { B o o s t _ L I B R A R I E S }
2020-01-26 21:35:45 +01:00
$ { O P E N S S L _ L I B R A R I E S }
2022-11-19 01:07:22 +09:00
$ { C U R L _ L I B R A R I E S }
2019-12-08 18:55:58 +01:00
$ { P L A T F O R M _ L I B R A R I E S } )
2019-12-03 20:23:33 +01:00
2022-06-17 16:30:59 -04:00
if ( NOT WIN32 )
2021-10-02 23:42:43 +02:00
list ( APPEND SUNSHINE_EXTERNAL_LIBRARIES Boost::log )
endif ( )
2019-12-03 20:23:33 +01:00
add_executable ( sunshine ${ SUNSHINE_TARGET_FILES } )
2022-11-19 01:07:22 +09:00
if ( WIN32 )
set_target_properties ( sunshine PROPERTIES LINK_SEARCH_START_STATIC 1 )
endif ( )
2022-02-24 21:09:00 +01:00
target_link_libraries ( sunshine ${ SUNSHINE_EXTERNAL_LIBRARIES } ${ EXTRA_LIBS } )
2019-12-03 20:23:33 +01:00
target_compile_definitions ( sunshine PUBLIC ${ SUNSHINE_DEFINITIONS } )
2022-01-23 13:05:35 -05:00
set_target_properties ( sunshine PROPERTIES CXX_STANDARD 17
V E R S I O N $ { P R O J E C T _ V E R S I O N }
S O V E R S I O N $ { P R O J E C T _ V E R S I O N _ M A J O R }
)
2019-12-03 20:23:33 +01:00
2021-09-26 16:01:59 +05:30
if ( NOT DEFINED CMAKE_CUDA_STANDARD )
set ( CMAKE_CUDA_STANDARD 17 )
set ( CMAKE_CUDA_STANDARD_REQUIRED ON )
endif ( )
2022-02-24 21:09:00 +01:00
if ( APPLE )
2022-05-11 21:31:31 -04:00
target_link_options ( sunshine PRIVATE LINKER:-sectcreate,__TEXT,__info_plist, ${ APPLE_PLIST_FILE } )
2022-02-24 21:09:00 +01:00
endif ( )
2021-09-26 16:01:59 +05:30
foreach ( flag IN LISTS SUNSHINE_COMPILE_OPTIONS )
list ( APPEND SUNSHINE_COMPILE_OPTIONS_CUDA "$<$<COMPILE_LANGUAGE:CUDA>:--compiler-options=${flag}>" )
endforeach ( )
target_compile_options ( sunshine PRIVATE $< $<COMPILE_LANGUAGE:CXX > : ${ SUNSHINE_COMPILE_OPTIONS } >; $< $<COMPILE_LANGUAGE:CUDA > : ${ SUNSHINE_COMPILE_OPTIONS_CUDA } ;-std=c++17> )
2022-04-23 10:48:05 +01:00
2022-05-05 21:05:57 -04:00
# CPACK / Packaging
2022-04-23 10:48:05 +01:00
2022-04-27 20:50:30 +01:00
# Common options
2022-07-29 09:45:26 -04:00
set ( CPACK_PACKAGE_NAME "Sunshine" )
set ( CPACK_PACKAGE_VENDOR "LizardByte" )
2022-05-06 12:55:43 -04:00
set ( CPACK_PACKAGE_DIRECTORY ${ CMAKE_CURRENT_BINARY_DIR } /cpack_artifacts )
2022-07-29 09:45:26 -04:00
set ( CPACK_PACKAGE_CONTACT "https://app.lizardbyte.dev" )
set ( CPACK_DEBIAN_PACKAGE_MAINTAINER "https://github.com/LizardByte" )
2022-05-06 14:24:39 -04:00
set ( CPACK_PACKAGE_DESCRIPTION ${ CMAKE_PROJECT_DESCRIPTION } )
set ( CPACK_PACKAGE_HOMEPAGE_URL ${ CMAKE_PROJECT_HOMEPAGE_URL } )
2022-04-27 20:50:30 +01:00
set ( CPACK_RESOURCE_FILE_LICENSE ${ PROJECT_SOURCE_DIR } /LICENSE )
set ( CPACK_PACKAGE_ICON ${ PROJECT_SOURCE_DIR } /sunshine.png )
2022-04-30 19:06:19 -04:00
set ( CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}" )
2022-04-27 20:50:30 +01:00
set ( CPACK_STRIP_FILES YES )
2022-12-27 14:03:00 -05:00
# install npm modules
install ( DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/node_modules" DESTINATION "${SUNSHINE_ASSETS_DIR}/web" )
2022-04-27 20:50:30 +01:00
# Platform specific options
if ( WIN32 ) # see options at: https://cmake.org/cmake/help/latest/cpack_gen/nsis.html
install ( TARGETS sunshine RUNTIME DESTINATION "." COMPONENT application )
# Adding tools
install ( TARGETS dxgi-info RUNTIME DESTINATION "tools" COMPONENT dxgi )
install ( TARGETS audio-info RUNTIME DESTINATION "tools" COMPONENT audio )
2022-08-20 21:12:37 -04:00
install ( TARGETS sunshinesvc RUNTIME DESTINATION "tools" COMPONENT sunshinesvc )
2022-04-27 20:50:30 +01:00
2022-08-14 20:53:38 -04:00
# scripts
2022-08-17 14:41:04 -04:00
install ( DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/windows/misc/firewall/" DESTINATION "scripts" COMPONENT firewall )
2022-08-14 20:53:38 -04:00
install ( DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/windows/misc/service/" DESTINATION "scripts" COMPONENT service )
# Sunshine assets
2022-05-11 21:31:31 -04:00
install ( DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/common/assets/" DESTINATION "${SUNSHINE_ASSETS_DIR}" COMPONENT assets )
install ( DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/windows/assets/" DESTINATION "${SUNSHINE_ASSETS_DIR}" COMPONENT assets )
2022-05-06 10:04:29 -04:00
# set(CPACK_NSIS_MUI_HEADERIMAGE "") # TODO: image should be 150x57 bmp
2022-05-05 23:58:08 -04:00
set ( CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\sunshine.ico" )
set ( CPACK_NSIS_INSTALLED_ICON_NAME "${PROJECT__DIR}\\\\${PROJECT_EXE}" )
2022-08-12 19:26:17 -04:00
set ( CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}" ) # The name of the directory that will be created in C:/Program files/
string ( APPEND CPACK_NSIS_DEFINES "\n RequestExecutionLevel admin" ) # TODO: Not sure if this is needed but it took me a while to figure out where to put this option so I'm leaving it here
2022-04-27 20:50:30 +01:00
2022-08-14 20:53:38 -04:00
# Extra install commands
2022-04-27 20:50:30 +01:00
# Sets permissions on the installed folder so that we can write in it
2022-08-14 20:53:38 -04:00
# Install service
2022-04-27 20:50:30 +01:00
SET ( CPACK_NSIS_EXTRA_INSTALL_COMMANDS
2022-08-20 21:12:37 -04:00
" $ { C P A C K _ N S I S _ E X T R A _ I N S T A L L _ C O M M A N D S }
E x e c W a i t ' i c a c l s \ \ \ " $ I N S T D I R \ \ \ " / g r a n t : r U s e r s : \ \ \ ( O I \ \ \ ) \ \ \ ( C I \ \ \ ) \ \ \ ( F \ \ \ ) '
E x e c W a i t ' \ \ \ " $ I N S T D I R \ \ \ \ s c r i p t s \ \ \ \ a d d - f i r e w a l l - r u l e . b a t \ \ \ " '
E x e c W a i t ' \ \ \ " $ I N S T D I R \ \ \ \ s c r i p t s \ \ \ \ i n s t a l l - s e r v i c e . b a t \ \ \ " '
" )
2022-08-14 20:53:38 -04:00
# Extra uninstall commands
# Uninstall service
set ( CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS
2022-08-20 21:12:37 -04:00
" $ { C P A C K _ N S I S _ E X T R A _ U N I N S T A L L _ C O M M A N D S }
E x e c W a i t ' \ \ \ " $ I N S T D I R \ \ \ \ s c r i p t s \ \ \ \ d e l e t e - f i r e w a l l - r u l e . b a t \ \ \ " '
E x e c W a i t ' \ \ \ " $ I N S T D I R \ \ \ \ s c r i p t s \ \ \ \ u n i n s t a l l - s e r v i c e . b a t \ \ \ " '
M e s s a g e B o x M B _ Y E S N O | M B _ I C O N Q U E S T I O N ' D o y o u w a n t t o c o m p l e t e l y r e m o v e t h e d i r e c t o r y $ I N S T D I R a n d a l l o f i t s c o n t e n t s ? ' I D N O N o D e l e t e
R M D i r / r \ \ \ " $ I N S T D I R \ \ \ " ; s k i p p e d i f n o
N o D e l e t e :
" )
2022-04-27 20:50:30 +01:00
# Adding an option for the start menu and PATH
2022-05-06 12:55:43 -04:00
set ( CPACK_NSIS_MODIFY_PATH "OFF" ) # TODO: it asks to add it to the PATH but is not working https://gitlab.kitware.com/cmake/cmake/-/issues/15635
2022-04-27 20:50:30 +01:00
set ( CPACK_NSIS_EXECUTABLES_DIRECTORY "." )
2022-04-30 19:06:19 -04:00
set ( CPACK_NSIS_MUI_FINISHPAGE_RUN "${CMAKE_PROJECT_NAME}.exe" )
2022-08-12 19:26:17 -04:00
set ( CPACK_NSIS_INSTALLED_ICON_NAME "${CMAKE_PROJECT_NAME}.exe" ) # This will be shown on the installed apps Windows settings
2022-08-20 21:12:37 -04:00
set ( CPACK_NSIS_CREATE_ICONS_EXTRA
" $ { C P A C K _ N S I S _ C R E A T E _ I C O N S _ E X T R A }
C r e a t e S h o r t C u t ' \ $ S M P R O G R A M S \ \ \ \ $ S T A R T M E N U _ F O L D E R \ \ \ \ $ { C M A K E _ P R O J E C T _ N A M E } . l n k ' ' \ $ I N S T D I R \ \ \ \ $ { C M A K E _ P R O J E C T _ N A M E } . e x e '
" )
set ( CPACK_NSIS_DELETE_ICONS_EXTRA
" $ { C P A C K _ N S I S _ D E L E T E _ I C O N S _ E X T R A }
D e l e t e ' \ $ S M P R O G R A M S \ \ \ \ $ M U I _ T E M P \ \ \ \ $ { C M A K E _ P R O J E C T _ N A M E } . l n k '
" )
2022-04-27 20:50:30 +01:00
# Checking for previous installed versions
2022-08-12 19:26:17 -04:00
# set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL "ON") # TODO: doesn't work on my machine when Sunshine is already installed
2022-04-27 20:50:30 +01:00
2022-08-20 21:12:37 -04:00
set ( CPACK_NSIS_HELP_LINK "https://docs.lizardbyte.dev/projects/sunshine/en/latest/about/installation.html" )
set ( CPACK_NSIS_URL_INFO_ABOUT "${CMAKE_PROJECT_HOMEPAGE_URL}" )
set ( CPACK_NSIS_CONTACT "${CMAKE_PROJECT_HOMEPAGE_URL}/support" )
2022-04-27 20:50:30 +01:00
# Setting components groups and dependencies
2022-05-05 23:58:08 -04:00
# sunshine binary
2022-04-30 19:06:19 -04:00
set ( CPACK_COMPONENT_APPLICATION_DISPLAY_NAME "${CMAKE_PROJECT_NAME}" )
2022-08-15 17:41:27 -04:00
set ( CPACK_COMPONENT_APPLICATION_DESCRIPTION "${CMAKE_PROJECT_NAME} main application." )
set ( CPACK_COMPONENT_APPLICATION_GROUP "core" )
2022-05-05 23:58:08 -04:00
set ( CPACK_COMPONENT_APPLICATION_REQUIRED true )
2022-05-06 12:55:43 -04:00
set ( CPACK_COMPONENT_APPLICATION_DEPENDS assets )
2022-05-05 23:58:08 -04:00
# assets
2022-08-15 17:41:27 -04:00
set ( CPACK_COMPONENT_ASSETS_DISPLAY_NAME "assets" )
2022-05-11 21:31:31 -04:00
set ( CPACK_COMPONENT_ASSETS_DESCRIPTION "Shaders, default box art, and web ui." )
2022-08-15 17:41:27 -04:00
set ( CPACK_COMPONENT_ASSETS_GROUP "core" )
2022-05-05 23:58:08 -04:00
set ( CPACK_COMPONENT_ASSETS_REQUIRED true )
# audio tool
2022-08-14 20:53:38 -04:00
set ( CPACK_COMPONENT_AUDIO_DISPLAY_NAME "audio-info" )
set ( CPACK_COMPONENT_AUDIO_DESCRIPTION "CLI tool providing information about sound devices." )
2022-08-15 17:41:27 -04:00
set ( CPACK_COMPONENT_AUDIO_GROUP "tools" )
2022-04-27 20:50:30 +01:00
2022-05-05 23:58:08 -04:00
# display tool
2022-08-14 20:53:38 -04:00
set ( CPACK_COMPONENT_DXGI_DISPLAY_NAME "dxgi-info" )
set ( CPACK_COMPONENT_DXGI_DESCRIPTION "CLI tool providing information about graphics cards and displays." )
2022-08-15 17:41:27 -04:00
set ( CPACK_COMPONENT_DXGI_GROUP "tools" )
2022-04-27 20:50:30 +01:00
2022-08-14 20:53:38 -04:00
# service
2022-08-20 21:12:37 -04:00
set ( CPACK_COMPONENT_SUNSHINESVC_DISPLAY_NAME "sunshinesvc" )
set ( CPACK_COMPONENT_SUNSHINESVC_DESCRIPTION "CLI tool providing ability to enable/disable the Sunshine service." )
set ( CPACK_COMPONENT_SUNSHINESVC_GROUP "tools" )
2022-08-14 20:53:38 -04:00
# service scripts
set ( CPACK_COMPONENT_SERVICE_DISPLAY_NAME "service-scripts" )
2022-08-15 17:41:27 -04:00
set ( CPACK_COMPONENT_SERVICE_DESCRIPTION "Scripts to enable/disable the service." )
set ( CPACK_COMPONENT_SERVICE_GROUP "scripts" )
2022-08-20 21:12:37 -04:00
set ( CPACK_COMPONENT_SERVICE_DEPENDS sunshinesvc )
2022-08-14 20:53:38 -04:00
# firewall scripts
2022-08-17 14:41:04 -04:00
set ( CPACK_COMPONENT_FIREWALL_DISPLAY_NAME "firewall-scripts" )
set ( CPACK_COMPONENT_FIREWALL_DESCRIPTION "Scripts to enable or disable firewall rules." )
set ( CPACK_COMPONENT_FIREWALL_GROUP "scripts" )
2022-04-23 10:48:05 +01:00
endif ( )
2022-06-22 19:20:04 -04:00
if ( APPLE )
# TODO: bundle doesn't produce a valid .app use cpack -G DragNDrop
set ( CPACK_BUNDLE_NAME "${CMAKE_PROJECT_NAME}" )
set ( CPACK_BUNDLE_PLIST "${APPLE_PLIST_FILE}" )
set ( CPACK_BUNDLE_ICON "${PROJECT_SOURCE_DIR}/sunshine.icns" )
# set(CPACK_BUNDLE_STARTUP_COMMAND "${INSTALL_RUNTIME_DIR}/sunshine")
2022-05-11 21:31:31 -04:00
endif ( )
2022-08-12 19:26:17 -04:00
if ( APPLE AND SUNSHINE_MACOS_PACKAGE ) # TODO
2022-04-23 15:13:27 +01:00
set ( prefix "${CMAKE_PROJECT_NAME}.app/Contents" )
set ( INSTALL_RUNTIME_DIR "${prefix}/MacOS" )
2022-06-22 19:20:04 -04:00
install ( DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/common/assets/" DESTINATION "${SUNSHINE_ASSETS_DIR}" )
install ( DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/macos/assets/" DESTINATION "${SUNSHINE_ASSETS_DIR}" )
2022-04-23 15:13:27 +01:00
install ( TARGETS sunshine
B U N D L E D E S T I N A T I O N . C O M P O N E N T R u n t i m e
R U N T I M E D E S T I N A T I O N $ { I N S T A L L _ R U N T I M E _ D I R } C O M P O N E N T R u n t i m e )
2022-06-22 19:20:04 -04:00
elseif ( UNIX )
# Installation destination dir
set ( CPACK_SET_DESTDIR true )
if ( NOT CMAKE_INSTALL_PREFIX )
2022-08-12 19:26:17 -04:00
set ( CMAKE_INSTALL_PREFIX "/usr/share/sunshine" )
2022-06-22 19:20:04 -04:00
endif ( )
2022-04-23 15:13:27 +01:00
2022-06-22 19:20:04 -04:00
install ( TARGETS sunshine RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" )
2022-05-05 22:17:07 -04:00
2022-06-22 19:20:04 -04:00
install ( DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/common/assets/" DESTINATION "${SUNSHINE_ASSETS_DIR}" )
2022-04-23 15:13:27 +01:00
2022-06-22 19:20:04 -04:00
if ( APPLE )
install ( DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/macos/assets/" DESTINATION "${SUNSHINE_ASSETS_DIR}" )
2022-06-22 21:42:10 -04:00
install ( FILES "${SUNSHINE_SOURCE_ASSETS_DIR}/macos/misc/uninstall_pkg.sh" DESTINATION "${SUNSHINE_ASSETS_DIR}" )
2022-06-22 19:20:04 -04:00
else ( )
install ( DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/assets/" DESTINATION "${SUNSHINE_ASSETS_DIR}" )
2022-08-23 20:08:14 -04:00
if ( ${ SUNSHINE_CONFIGURE_APPIMAGE } OR ${ SUNSHINE_CONFIGURE_FLATPAK } )
2022-08-12 19:26:17 -04:00
install ( FILES "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/misc/85-sunshine.rules" DESTINATION "${SUNSHINE_ASSETS_DIR}/udev/rules.d" )
install ( FILES "${CMAKE_CURRENT_BINARY_DIR}/sunshine.service" DESTINATION "${SUNSHINE_ASSETS_DIR}/systemd/user" )
else ( )
2022-12-14 03:19:44 +00:00
install ( FILES "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/misc/85-sunshine.rules" DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/udev/rules.d" )
install ( FILES "${CMAKE_CURRENT_BINARY_DIR}/sunshine.service" DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/systemd/user" )
2022-08-12 19:26:17 -04:00
endif ( )
2022-06-22 19:20:04 -04:00
2022-08-12 16:13:04 -04:00
# Post install
set ( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/misc/postinst" )
2022-06-22 19:20:04 -04:00
set ( CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/misc/postinst" )
# Dependencies
set ( CPACK_DEB_COMPONENT_INSTALL ON )
2022-12-11 17:46:19 -05:00
set ( CPACK_DEBIAN_PACKAGE_DEPENDS "openssl, libboost-thread1.67.0 | libboost-thread1.71.0 | libboost-thread1.74.0, libboost-filesystem1.67.0 | libboost-filesystem1.71.0 | libboost-filesystem1.74.0, libboost-log1.67.0 | libboost-log1.71.0 | libboost-log1.74.0, libcurl4, libpulse0, libopus0, libxcb-shm0, libxcb-xfixes0, libxtst6, libevdev2, libdrm2, libcap2" )
set ( CPACK_RPM_PACKAGE_REQUIRES "openssl >= 1.1, boost-thread >= 1.67.0, boost-filesystem >= 1.67.0, boost-log >= 1.67.0, libcurl >= 7.0, pulseaudio-libs >= 10.0, libopusenc >= 0.2.1, libxcb >= 1.13, libXtst >= 1.2.3, libevdev >= 1.5.6, libdrm >= 2.4.97, libcap >= 2.22" )
2022-08-12 19:26:17 -04:00
set ( CPACK_DEBIAN_PACKAGE_SHLIBDEPS OFF ) # This should automatically figure out dependencies, doesn't work with the current config
2022-06-22 19:20:04 -04:00
endif ( )
2022-04-23 10:48:05 +01:00
endif ( )
2022-05-05 21:05:57 -04:00
include ( CPack )