2021-04-26 12:46:57 +00:00
|
|
|
cmake_minimum_required(VERSION 3.0)
|
2019-12-03 19:23:33 +00:00
|
|
|
|
|
|
|
project(Sunshine)
|
|
|
|
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
|
2019-12-08 17:55:58 +00:00
|
|
|
|
2021-06-11 09:59:19 +00:00
|
|
|
add_subdirectory(third-party/Simple-Web-Server)
|
2021-05-10 13:04:41 +00:00
|
|
|
|
2021-06-29 20:42:06 +00:00
|
|
|
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)
|
|
|
|
include_directories(third-party/miniupnp)
|
|
|
|
|
2020-01-26 20:35:45 +00:00
|
|
|
if(WIN32)
|
2021-05-10 13:04:41 +00:00
|
|
|
# Ugly hack to compile with #include <qos2.h>
|
|
|
|
add_compile_definitions(
|
|
|
|
QOS_FLOWID=UINT32
|
|
|
|
PQOS_FLOWID=UINT32*
|
|
|
|
QOS_NON_ADAPTIVE_FLOW=2)
|
2020-01-26 20:35:45 +00:00
|
|
|
endif()
|
2021-06-11 09:59:19 +00:00
|
|
|
add_subdirectory(third-party/moonlight-common-c/enet)
|
2020-01-10 21:19:50 +00:00
|
|
|
|
2020-01-01 17:47:34 +00:00
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
find_package(OpenSSL REQUIRED)
|
2020-01-26 20:35:45 +00:00
|
|
|
|
2020-01-23 22:43:39 +00:00
|
|
|
list(APPEND SUNSHINE_COMPILE_OPTIONS -fPIC -Wall -Wno-missing-braces -Wno-maybe-uninitialized -Wno-sign-compare)
|
2020-01-26 20:35:45 +00:00
|
|
|
|
2020-01-01 17:47:34 +00:00
|
|
|
if(WIN32)
|
2021-04-26 12:46:57 +00:00
|
|
|
file(
|
|
|
|
DOWNLOAD "https://github.com/TheElixZammuto/sunshine-prebuilt/releases/download/1.0.0/pre-compiled.zip" "${CMAKE_CURRENT_BINARY_DIR}/pre-compiled.zip"
|
|
|
|
TIMEOUT 60
|
|
|
|
EXPECTED_HASH SHA256=5d59986bd7f619eaaf82b2dd56b5127b747c9cbe8db61e3b898ff6b485298ed6)
|
|
|
|
|
|
|
|
file(ARCHIVE_EXTRACT
|
|
|
|
INPUT "${CMAKE_CURRENT_BINARY_DIR}/pre-compiled.zip"
|
|
|
|
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/pre-compiled)
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
|
|
|
|
|
|
|
|
if(NOT DEFINED SUNSHINE_PREPARED_BINARIES)
|
|
|
|
set(SUNSHINE_PREPARED_BINARIES "${CMAKE_CURRENT_BINARY_DIR}/pre-compiled/windows")
|
|
|
|
endif()
|
|
|
|
|
2021-05-17 19:30:03 +00:00
|
|
|
add_compile_definitions(SUNSHINE_PLATFORM="windows")
|
2020-01-23 22:43:39 +00:00
|
|
|
add_subdirectory(tools) #This is temporary, only tools for Windows are needed, for now
|
|
|
|
|
2020-01-23 11:46:09 +00:00
|
|
|
list(APPEND SUNSHINE_DEFINITIONS APPS_JSON="apps_windows.json")
|
2021-04-26 12:46:57 +00:00
|
|
|
|
2021-06-12 17:51:58 +00:00
|
|
|
include_directories(third-party/ViGEmClient/include)
|
2021-04-26 12:46:57 +00:00
|
|
|
|
2020-01-01 17:47:34 +00:00
|
|
|
set(PLATFORM_TARGET_FILES
|
2021-06-28 19:05:52 +00:00
|
|
|
sunshine/platform/windows/publish.cpp
|
2021-06-30 20:03:21 +00:00
|
|
|
sunshine/platform/windows/misc.h
|
2021-06-16 12:34:05 +00:00
|
|
|
sunshine/platform/windows/misc.cpp
|
2020-04-23 13:41:40 +00:00
|
|
|
sunshine/platform/windows/input.cpp
|
|
|
|
sunshine/platform/windows/display.h
|
|
|
|
sunshine/platform/windows/display_base.cpp
|
|
|
|
sunshine/platform/windows/display_vram.cpp
|
|
|
|
sunshine/platform/windows/display_ram.cpp
|
|
|
|
sunshine/platform/windows/audio.cpp
|
2021-06-11 09:59:19 +00:00
|
|
|
third-party/ViGEmClient/src/ViGEmClient.cpp
|
|
|
|
third-party/ViGEmClient/include/ViGEm/Client.h
|
|
|
|
third-party/ViGEmClient/include/ViGEm/Common.h
|
|
|
|
third-party/ViGEmClient/include/ViGEm/Util.h
|
|
|
|
third-party/ViGEmClient/include/ViGEm/km/BusShared.h)
|
2021-04-26 12:46:57 +00:00
|
|
|
|
2021-04-26 18:36:54 +00:00
|
|
|
set(OPENSSL_LIBRARIES
|
|
|
|
libssl.a
|
|
|
|
libcrypto.a)
|
|
|
|
|
2021-04-26 12:46:57 +00:00
|
|
|
set(FFMPEG_INCLUDE_DIRS
|
|
|
|
${SUNSHINE_PREPARED_BINARIES}/include)
|
|
|
|
set(FFMPEG_LIBRARIES
|
|
|
|
${SUNSHINE_PREPARED_BINARIES}/lib/libavcodec.a
|
|
|
|
${SUNSHINE_PREPARED_BINARIES}/lib/libavdevice.a
|
|
|
|
${SUNSHINE_PREPARED_BINARIES}/lib/libavfilter.a
|
|
|
|
${SUNSHINE_PREPARED_BINARIES}/lib/libavformat.a
|
|
|
|
${SUNSHINE_PREPARED_BINARIES}/lib/libavutil.a
|
|
|
|
${SUNSHINE_PREPARED_BINARIES}/lib/libpostproc.a
|
|
|
|
${SUNSHINE_PREPARED_BINARIES}/lib/libswresample.a
|
|
|
|
${SUNSHINE_PREPARED_BINARIES}/lib/libswscale.a
|
|
|
|
${SUNSHINE_PREPARED_BINARIES}/lib/libx264.a
|
|
|
|
${SUNSHINE_PREPARED_BINARIES}/lib/libx265.a
|
|
|
|
${SUNSHINE_PREPARED_BINARIES}/lib/libhdr10plus.a
|
|
|
|
z lzma bcrypt libiconv.a)
|
|
|
|
|
2020-01-26 20:35:45 +00:00
|
|
|
list(PREPEND PLATFORM_LIBRARIES
|
2021-04-26 12:46:57 +00:00
|
|
|
libstdc++.a
|
|
|
|
libwinpthread.a
|
|
|
|
libssp.a
|
2020-01-15 17:31:28 +00:00
|
|
|
ksuser
|
2020-01-01 17:47:34 +00:00
|
|
|
wsock32
|
2020-01-07 22:15:55 +00:00
|
|
|
ws2_32
|
2021-04-30 18:01:15 +00:00
|
|
|
d3d11 dxgi D3DCompiler
|
2020-01-26 20:35:45 +00:00
|
|
|
setupapi
|
|
|
|
)
|
|
|
|
|
2021-06-12 17:51:58 +00: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")
|
2020-01-01 17:47:34 +00:00
|
|
|
else()
|
2021-05-17 19:30:03 +00:00
|
|
|
add_compile_definitions(SUNSHINE_PLATFORM="linux")
|
2020-01-23 11:46:09 +00:00
|
|
|
list(APPEND SUNSHINE_DEFINITIONS APPS_JSON="apps_linux.json")
|
|
|
|
|
2020-01-01 17:47:34 +00:00
|
|
|
find_package(X11 REQUIRED)
|
2021-04-26 18:36:54 +00:00
|
|
|
find_package(FFmpeg REQUIRED)
|
2021-06-26 10:40:06 +00:00
|
|
|
|
2020-01-01 17:47:34 +00:00
|
|
|
set(PLATFORM_TARGET_FILES
|
2021-06-26 11:32:14 +00:00
|
|
|
sunshine/platform/linux/publish.cpp
|
2021-06-04 19:12:06 +00:00
|
|
|
sunshine/platform/linux/vaapi.h
|
|
|
|
sunshine/platform/linux/vaapi.cpp
|
2021-06-26 13:36:56 +00:00
|
|
|
sunshine/platform/linux/misc.h
|
2021-06-16 09:26:54 +00:00
|
|
|
sunshine/platform/linux/misc.cpp
|
2020-04-23 13:48:05 +00:00
|
|
|
sunshine/platform/linux/display.cpp
|
2021-05-18 11:36:12 +00:00
|
|
|
sunshine/platform/linux/audio.cpp
|
2021-06-04 19:12:06 +00:00
|
|
|
sunshine/platform/linux/input.cpp
|
2021-06-11 09:59:19 +00:00
|
|
|
third-party/glad/src/egl.c
|
|
|
|
third-party/glad/src/gl.c
|
|
|
|
third-party/glad/include/EGL/eglplatform.h
|
|
|
|
third-party/glad/include/KHR/khrplatform.h
|
|
|
|
third-party/glad/include/glad/gl.h
|
|
|
|
third-party/glad/include/glad/egl.h)
|
2021-06-04 19:12:06 +00:00
|
|
|
|
2020-01-01 17:47:34 +00:00
|
|
|
set(PLATFORM_LIBRARIES
|
|
|
|
Xfixes
|
|
|
|
Xtst
|
|
|
|
xcb
|
|
|
|
xcb-shm
|
|
|
|
xcb-xfixes
|
2021-02-28 13:52:47 +00:00
|
|
|
Xrandr
|
2020-01-01 17:47:34 +00:00
|
|
|
${X11_LIBRARIES}
|
2021-06-06 16:45:45 +00:00
|
|
|
dl
|
2020-01-01 17:47:34 +00:00
|
|
|
evdev
|
|
|
|
pulse
|
2020-01-03 19:25:21 +00:00
|
|
|
pulse-simple
|
|
|
|
)
|
2020-01-01 17:47:34 +00:00
|
|
|
|
|
|
|
set(PLATFORM_INCLUDE_DIRS
|
|
|
|
${X11_INCLUDE_DIR}
|
2021-06-04 19:12:06 +00:00
|
|
|
/usr/include/libevdev-1.0
|
2021-06-11 09:59:19 +00:00
|
|
|
third-party/glad/include)
|
2020-01-29 21:54:53 +00:00
|
|
|
|
2020-01-30 15:09:13 +00:00
|
|
|
if(NOT DEFINED SUNSHINE_EXECUTABLE_PATH)
|
2021-07-03 16:13:05 +00:00
|
|
|
set(SUNSHINE_EXECUTABLE_PATH "sunshine")
|
2020-01-30 15:09:13 +00:00
|
|
|
endif()
|
2020-01-29 21:54:53 +00:00
|
|
|
configure_file(gen-deb.in gen-deb @ONLY)
|
2020-01-30 15:09:13 +00:00
|
|
|
configure_file(sunshine.service.in sunshine.service @ONLY)
|
2020-01-01 17:47:34 +00:00
|
|
|
endif()
|
2020-01-17 15:23:20 +00:00
|
|
|
|
2021-06-14 19:09:11 +00:00
|
|
|
add_subdirectory(third-party/cbs)
|
|
|
|
|
2020-01-19 02:22:11 +00:00
|
|
|
set(Boost_USE_STATIC_LIBS ON)
|
2020-01-17 15:23:20 +00:00
|
|
|
find_package(Boost COMPONENTS log filesystem REQUIRED)
|
|
|
|
|
2019-12-03 19:23:33 +00:00
|
|
|
set(SUNSHINE_TARGET_FILES
|
2021-06-11 09:59:19 +00:00
|
|
|
third-party/moonlight-common-c/reedsolomon/rs.c
|
|
|
|
third-party/moonlight-common-c/reedsolomon/rs.h
|
|
|
|
third-party/moonlight-common-c/src/Input.h
|
|
|
|
third-party/moonlight-common-c/src/Rtsp.h
|
|
|
|
third-party/moonlight-common-c/src/RtspParser.c
|
|
|
|
third-party/moonlight-common-c/src/Video.h
|
2021-06-29 20:42:06 +00:00
|
|
|
sunshine/upnp.cpp
|
|
|
|
sunshine/upnp.h
|
2021-06-13 19:29:32 +00:00
|
|
|
sunshine/cbs.cpp
|
2019-12-08 17:55:58 +00:00
|
|
|
sunshine/utility.h
|
|
|
|
sunshine/uuid.h
|
|
|
|
sunshine/config.h
|
|
|
|
sunshine/config.cpp
|
|
|
|
sunshine/main.cpp
|
2019-12-22 22:34:12 +00:00
|
|
|
sunshine/main.h
|
2019-12-08 17:55:58 +00:00
|
|
|
sunshine/crypto.cpp
|
|
|
|
sunshine/crypto.h
|
|
|
|
sunshine/nvhttp.cpp
|
|
|
|
sunshine/nvhttp.h
|
2021-05-11 21:38:45 +00:00
|
|
|
sunshine/httpcommon.cpp
|
|
|
|
sunshine/httpcommon.h
|
2021-05-09 16:55:34 +00:00
|
|
|
sunshine/confighttp.cpp
|
|
|
|
sunshine/confighttp.h
|
2020-02-08 15:26:38 +00:00
|
|
|
sunshine/rtsp.cpp
|
|
|
|
sunshine/rtsp.h
|
2019-12-08 17:55:58 +00:00
|
|
|
sunshine/stream.cpp
|
|
|
|
sunshine/stream.h
|
|
|
|
sunshine/video.cpp
|
2019-12-14 22:57:04 +00:00
|
|
|
sunshine/video.h
|
2019-12-08 17:55:58 +00:00
|
|
|
sunshine/input.cpp
|
|
|
|
sunshine/input.h
|
|
|
|
sunshine/audio.cpp
|
|
|
|
sunshine/audio.h
|
|
|
|
sunshine/platform/common.h
|
2019-12-14 22:57:04 +00:00
|
|
|
sunshine/process.cpp
|
|
|
|
sunshine/process.h
|
2019-12-27 15:04:18 +00:00
|
|
|
sunshine/network.cpp
|
|
|
|
sunshine/network.h
|
2019-12-22 22:34:12 +00:00
|
|
|
sunshine/move_by_copy.h
|
|
|
|
sunshine/task_pool.h
|
|
|
|
sunshine/thread_pool.h
|
2020-02-12 10:28:27 +00:00
|
|
|
sunshine/thread_safe.h
|
|
|
|
sunshine/sync.h
|
2020-03-27 20:57:29 +00:00
|
|
|
sunshine/round_robin.h
|
2019-12-08 17:55:58 +00:00
|
|
|
${PLATFORM_TARGET_FILES})
|
2019-12-03 19:23:33 +00:00
|
|
|
|
2021-06-29 20:42:06 +00:00
|
|
|
set_source_files_properties(sunshine/upnp.cpp PROPERTIES COMPILE_FLAGS -Wno-pedantic)
|
|
|
|
|
2019-12-03 19:23:33 +00:00
|
|
|
include_directories(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
2021-06-11 09:59:19 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/third-party
|
2021-06-12 21:08:20 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/third-party/cbs/include
|
2021-06-11 09:59:19 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/third-party/moonlight-common-c/enet/include
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/third-party/moonlight-common-c/reedsolomon
|
2019-12-03 19:23:33 +00:00
|
|
|
${FFMPEG_INCLUDE_DIRS}
|
2019-12-08 17:55:58 +00:00
|
|
|
${PLATFORM_INCLUDE_DIRS}
|
2019-12-03 19:23:33 +00:00
|
|
|
)
|
|
|
|
|
2020-01-17 14:44:47 +00:00
|
|
|
string(TOUPPER "x${CMAKE_BUILD_TYPE}" BUILD_TYPE)
|
|
|
|
if("${BUILD_TYPE}" STREQUAL "XDEBUG")
|
2020-01-03 19:25:21 +00:00
|
|
|
list(APPEND SUNSHINE_COMPILE_OPTIONS -O0 -pedantic -ggdb3)
|
|
|
|
if(WIN32)
|
|
|
|
set_source_files_properties(sunshine/nvhttp.cpp PROPERTIES COMPILE_FLAGS -O2)
|
|
|
|
endif()
|
2019-12-08 17:55:58 +00:00
|
|
|
else()
|
2019-12-03 19:23:33 +00:00
|
|
|
add_definitions(-DNDEBUG)
|
|
|
|
list(APPEND SUNSHINE_COMPILE_OPTIONS -O3)
|
|
|
|
endif()
|
|
|
|
|
2020-01-30 11:39:12 +00:00
|
|
|
if(NOT SUNSHINE_ASSETS_DIR)
|
|
|
|
set(SUNSHINE_ASSETS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/assets")
|
2020-01-21 02:09:28 +00:00
|
|
|
endif()
|
|
|
|
|
2021-07-24 13:26:08 +00:00
|
|
|
if(NOT SUNSHINE_CONFIG_DIR)
|
2021-07-27 16:55:41 +00:00
|
|
|
set(SUNSHINE_CONFIG_DIR "${SUNSHINE_ASSETS_DIR}")
|
2021-07-24 13:26:08 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT SUNSHINE_DEFAULT_DIR)
|
2021-07-27 16:55:41 +00:00
|
|
|
set(SUNSHINE_DEFAULT_DIR "${SUNSHINE_ASSETS_DIR}")
|
2021-07-24 13:26:08 +00:00
|
|
|
endif()
|
|
|
|
|
2021-06-12 21:08:20 +00:00
|
|
|
list(APPEND CBS_EXTERNAL_LIBRARIES
|
|
|
|
cbs)
|
2020-01-27 19:10:45 +00:00
|
|
|
|
2019-12-03 19:23:33 +00:00
|
|
|
list(APPEND SUNSHINE_EXTERNAL_LIBRARIES
|
2021-06-29 20:42:06 +00:00
|
|
|
libminiupnpc-static
|
2021-06-12 21:08:20 +00:00
|
|
|
${CBS_EXTERNAL_LIBRARIES}
|
2019-12-03 19:23:33 +00:00
|
|
|
${CMAKE_THREAD_LIBS_INIT}
|
2020-01-17 15:43:19 +00:00
|
|
|
stdc++fs
|
2019-12-03 19:23:33 +00:00
|
|
|
enet
|
2019-12-05 23:13:16 +00:00
|
|
|
opus
|
2019-12-08 17:55:58 +00:00
|
|
|
${FFMPEG_LIBRARIES}
|
2020-01-01 17:47:34 +00:00
|
|
|
${Boost_LIBRARIES}
|
2020-01-26 20:35:45 +00:00
|
|
|
${OPENSSL_LIBRARIES}
|
2019-12-08 17:55:58 +00:00
|
|
|
${PLATFORM_LIBRARIES})
|
2019-12-03 19:23:33 +00:00
|
|
|
|
2020-01-30 11:39:12 +00:00
|
|
|
list(APPEND SUNSHINE_DEFINITIONS SUNSHINE_ASSETS_DIR="${SUNSHINE_ASSETS_DIR}")
|
2021-07-24 13:26:08 +00:00
|
|
|
list(APPEND SUNSHINE_DEFINITIONS SUNSHINE_CONFIG_DIR="${SUNSHINE_CONFIG_DIR}")
|
|
|
|
list(APPEND SUNSHINE_DEFINITIONS SUNSHINE_DEFAULT_DIR="${SUNSHINE_DEFAULT_DIR}")
|
2019-12-03 19:23:33 +00:00
|
|
|
add_executable(sunshine ${SUNSHINE_TARGET_FILES})
|
|
|
|
target_link_libraries(sunshine ${SUNSHINE_EXTERNAL_LIBRARIES})
|
|
|
|
target_compile_definitions(sunshine PUBLIC ${SUNSHINE_DEFINITIONS})
|
|
|
|
set_target_properties(sunshine PROPERTIES CXX_STANDARD 17)
|
|
|
|
|
|
|
|
target_compile_options(sunshine PRIVATE ${SUNSHINE_COMPILE_OPTIONS})
|