2019-12-03 19:23:33 +00:00
|
|
|
cmake_minimum_required(VERSION 2.8)
|
|
|
|
|
|
|
|
project(Sunshine)
|
|
|
|
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
|
2019-12-08 17:55:58 +00:00
|
|
|
|
2020-01-26 20:35:45 +00:00
|
|
|
# On MSYS2, building a stand-alone binary that links with ffmpeg is not possible,
|
|
|
|
# Therefore, ffmpeg, libx264 and libx265 must be build from source
|
|
|
|
if(WIN32)
|
|
|
|
option(SUNSHINE_STANDALONE "Compile stand-alone binary of Sunshine" OFF)
|
|
|
|
if(SUNSHINE_STANDALONE)
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
|
|
|
|
|
|
|
|
if(NOT DEFINED SUNSHINE_X265_BUILD_DIR)
|
|
|
|
message("Warning: Missing SUNSHINE_X265_BUILD_DIR")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
list(PREPEND PLATFORM_LIBRARIES
|
|
|
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/${CMAKE_CXX_COMPILER_VERSION}/libstdc++.a
|
|
|
|
C:/msys64/mingw64/x86_64-w64-mingw32/lib/libwinpthread.a
|
|
|
|
C:/msys64/mingw64/lib/libiconv.a
|
|
|
|
)
|
|
|
|
|
2020-01-26 23:33:55 +00:00
|
|
|
set(FFMPEG_INCLUDE_DIRS
|
|
|
|
C:/msys64/usr/local/include)
|
2020-01-26 20:35:45 +00:00
|
|
|
set(FFMPEG_LIBRARIES
|
|
|
|
C:/msys64/usr/local/lib/libavcodec.a
|
|
|
|
C:/msys64/usr/local/lib/libavdevice.a
|
|
|
|
C:/msys64/usr/local/lib/libavfilter.a
|
|
|
|
C:/msys64/usr/local/lib/libavformat.a
|
|
|
|
C:/msys64/usr/local/lib/libavutil.a
|
|
|
|
C:/msys64/usr/local/lib/libpostproc.a
|
|
|
|
C:/msys64/usr/local/lib/libswresample.a
|
|
|
|
C:/msys64/usr/local/lib/libswscale.a
|
|
|
|
C:/msys64/usr/local/lib/libx264.a
|
|
|
|
${SUNSHINE_X265_BUILD_DIR}/libx265.a
|
|
|
|
z lzma bcrypt)
|
|
|
|
else()
|
|
|
|
set(SUNSHINE_STANDALONE OFF)
|
|
|
|
endif()
|
|
|
|
|
2020-01-10 21:19:50 +00:00
|
|
|
add_subdirectory(Simple-Web-Server)
|
|
|
|
add_subdirectory(moonlight-common-c/enet)
|
|
|
|
|
2020-01-01 17:47:34 +00:00
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
find_package(OpenSSL REQUIRED)
|
2020-01-26 20:35:45 +00:00
|
|
|
|
|
|
|
if(NOT SUNSHINE_STANDALONE)
|
|
|
|
find_package(FFmpeg REQUIRED)
|
|
|
|
endif()
|
2019-12-08 17:55:58 +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)
|
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")
|
2020-01-18 20:16:00 +00:00
|
|
|
include_directories(
|
|
|
|
ViGEmClient/include)
|
2020-01-01 17:47:34 +00:00
|
|
|
set(PLATFORM_TARGET_FILES
|
2020-01-12 16:54:43 +00:00
|
|
|
sunshine/platform/windows.cpp
|
2020-01-15 17:31:28 +00:00
|
|
|
sunshine/platform/windows_dxgi.cpp
|
2020-01-18 20:16:00 +00:00
|
|
|
sunshine/platform/windows_wasapi.cpp
|
2020-01-18 22:52:22 +00:00
|
|
|
ViGEmClient/src/ViGEmClient.cpp
|
|
|
|
ViGEmClient/include/ViGEm/Client.h
|
|
|
|
ViGEmClient/include/ViGEm/Common.h
|
|
|
|
ViGEmClient/include/ViGEm/Util.h
|
|
|
|
ViGEmClient/include/ViGEm/km/BusShared.h)
|
2020-01-26 20:35:45 +00:00
|
|
|
list(PREPEND PLATFORM_LIBRARIES
|
2020-01-01 17:47:34 +00:00
|
|
|
winmm
|
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
|
2020-01-22 02:23:18 +00:00
|
|
|
iphlpapi
|
2020-01-15 17:31:28 +00:00
|
|
|
windowsapp
|
2020-01-18 20:16:00 +00:00
|
|
|
d3d11 dxgi
|
2020-01-26 20:35:45 +00:00
|
|
|
setupapi
|
|
|
|
)
|
|
|
|
|
2020-01-18 20:16:00 +00:00
|
|
|
set_source_files_properties(ViGEmClient/src/ViGEmClient.cpp PROPERTIES COMPILE_DEFINITIONS "UNICODE=1;ERROR_INVALID_DEVICE_OBJECT_PARAMETER=650")
|
|
|
|
set_source_files_properties(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()
|
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)
|
|
|
|
set(PLATFORM_TARGET_FILES
|
|
|
|
sunshine/platform/linux.cpp
|
|
|
|
sunshine/platform/linux_evdev.cpp)
|
|
|
|
|
|
|
|
set(PLATFORM_LIBRARIES
|
|
|
|
Xfixes
|
|
|
|
Xtst
|
|
|
|
xcb
|
|
|
|
xcb-shm
|
|
|
|
xcb-xfixes
|
|
|
|
${X11_LIBRARIES}
|
|
|
|
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}
|
|
|
|
/usr/include/libevdev-1.0)
|
|
|
|
endif()
|
2020-01-17 15:23:20 +00:00
|
|
|
|
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
|
|
|
|
moonlight-common-c/reedsolomon/rs.c
|
|
|
|
moonlight-common-c/reedsolomon/rs.h
|
|
|
|
moonlight-common-c/src/Input.h
|
|
|
|
moonlight-common-c/src/Rtsp.h
|
|
|
|
moonlight-common-c/src/RtspParser.c
|
|
|
|
moonlight-common-c/src/Video.h
|
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
|
|
|
|
sunshine/stream.cpp
|
|
|
|
sunshine/stream.h
|
|
|
|
sunshine/video.cpp
|
2019-12-14 22:57:04 +00:00
|
|
|
sunshine/video.h
|
|
|
|
sunshine/thread_safe.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
|
2019-12-08 17:55:58 +00:00
|
|
|
${PLATFORM_TARGET_FILES})
|
2019-12-03 19:23:33 +00:00
|
|
|
|
|
|
|
include_directories(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/Simple-Web-Server
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/moonlight-common-c/enet/include
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/moonlight-common-c/reedsolomon
|
|
|
|
${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-21 02:09:28 +00:00
|
|
|
if(NOT SUNSHINE_ROOT)
|
|
|
|
set(SUNSHINE_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
endif()
|
|
|
|
|
2020-01-26 20:35:45 +00:00
|
|
|
if(SUNSHINE_STANDALONE)
|
|
|
|
set(OPENSSL_LIBRARIES
|
|
|
|
C:/msys64/mingw64/lib/libssl.a
|
|
|
|
C:/msys64/mingw64/lib/libcrypto.a)
|
|
|
|
endif()
|
2019-12-03 19:23:33 +00:00
|
|
|
list(APPEND SUNSHINE_EXTERNAL_LIBRARIES
|
|
|
|
${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-23 11:46:09 +00:00
|
|
|
list(APPEND SUNSHINE_DEFINITIONS SUNSHINE_ASSETS_DIR="${SUNSHINE_ROOT}/assets")
|
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})
|