Skip to content

Commit

Permalink
build(cmake): use CMAKE_SOURCE_DIR property
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher committed Feb 2, 2024
1 parent 190ea41 commit 6f0bbf9
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 154 deletions.
124 changes: 62 additions & 62 deletions cmake/compile_definitions/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,70 +23,70 @@ elseif(UNIX)
endif()
endif()

include_directories(SYSTEM third-party/nv-codec-headers/include)
include_directories(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/third-party/nv-codec-headers/include")
file(GLOB NVENC_SOURCES CONFIGURE_DEPENDS "src/nvenc/*.cpp" "src/nvenc/*.h")
list(APPEND PLATFORM_TARGET_FILES ${NVENC_SOURCES})

configure_file(src/version.h.in version.h @ONLY)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/version.h.in" version.h @ONLY)
include_directories("${CMAKE_CURRENT_BINARY_DIR}")

set(SUNSHINE_TARGET_FILES
third-party/nanors/rs.c
third-party/nanors/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
third-party/tray/tray.h
src/upnp.cpp
src/upnp.h
src/cbs.cpp
src/utility.h
src/uuid.h
src/config.h
src/config.cpp
src/main.cpp
src/main.h
src/crypto.cpp
src/crypto.h
src/nvhttp.cpp
src/nvhttp.h
src/httpcommon.cpp
src/httpcommon.h
src/confighttp.cpp
src/confighttp.h
src/rtsp.cpp
src/rtsp.h
src/stream.cpp
src/stream.h
src/video.cpp
src/video.h
src/video_colorspace.cpp
src/video_colorspace.h
src/input.cpp
src/input.h
src/audio.cpp
src/audio.h
src/platform/common.h
src/process.cpp
src/process.h
src/network.cpp
src/network.h
src/move_by_copy.h
src/system_tray.cpp
src/system_tray.h
src/task_pool.h
src/thread_pool.h
src/thread_safe.h
src/sync.h
src/round_robin.h
src/stat_trackers.h
src/stat_trackers.cpp
"${CMAKE_CURRENT_SOURCE_DIR}/third-party/nanors/rs.c"
"${CMAKE_CURRENT_SOURCE_DIR}/third-party/nanors/rs.h"
"${CMAKE_CURRENT_SOURCE_DIR}/third-party/moonlight-common-c/src/Input.h"
"${CMAKE_CURRENT_SOURCE_DIR}/third-party/moonlight-common-c/src/Rtsp.h"
"${CMAKE_CURRENT_SOURCE_DIR}/third-party/moonlight-common-c/src/RtspParser.c"
"${CMAKE_CURRENT_SOURCE_DIR}/third-party/moonlight-common-c/src/Video.h"
"${CMAKE_CURRENT_SOURCE_DIR}/third-party/tray/tray.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/upnp.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/upnp.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/cbs.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/utility.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/uuid.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/config.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/config.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/main.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/crypto.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/crypto.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/nvhttp.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/nvhttp.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/httpcommon.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/httpcommon.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/confighttp.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/confighttp.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/rtsp.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/rtsp.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/stream.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/stream.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/video.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/video.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/video_colorspace.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/video_colorspace.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/input.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/input.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/audio.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/audio.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/platform/common.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/process.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/process.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/network.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/network.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/move_by_copy.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/system_tray.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/system_tray.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/task_pool.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/thread_pool.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/thread_safe.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/sync.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/round_robin.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/stat_trackers.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/stat_trackers.cpp"
${PLATFORM_TARGET_FILES})

set_source_files_properties(src/upnp.cpp PROPERTIES COMPILE_FLAGS -Wno-pedantic)
set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/src/upnp.cpp" PROPERTIES COMPILE_FLAGS -Wno-pedantic)

set_source_files_properties(third-party/nanors/rs.c
set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/third-party/nanors/rs.c"
PROPERTIES COMPILE_FLAGS "-include deps/obl/autoshim.h -ftree-vectorize")

if(NOT SUNSHINE_ASSETS_DIR_DEF)
Expand All @@ -96,22 +96,22 @@ list(APPEND SUNSHINE_DEFINITIONS SUNSHINE_ASSETS_DIR="${SUNSHINE_ASSETS_DIR_DEF}

list(APPEND SUNSHINE_DEFINITIONS SUNSHINE_TRAY=${SUNSHINE_TRAY})

include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories("${CMAKE_CURRENT_SOURCE_DIR}")

include_directories(
SYSTEM
${CMAKE_CURRENT_SOURCE_DIR}/third-party
${CMAKE_CURRENT_SOURCE_DIR}/third-party/moonlight-common-c/enet/include
${CMAKE_CURRENT_SOURCE_DIR}/third-party/nanors
${CMAKE_CURRENT_SOURCE_DIR}/third-party/nanors/deps/obl
"${CMAKE_CURRENT_SOURCE_DIR}/third-party"
"${CMAKE_CURRENT_SOURCE_DIR}/third-party/moonlight-common-c/enet/include"
"${CMAKE_CURRENT_SOURCE_DIR}/third-party/nanors"
"${CMAKE_CURRENT_SOURCE_DIR}/third-party/nanors/deps/obl"
${FFMPEG_INCLUDE_DIRS}
${PLATFORM_INCLUDE_DIRS}
)

string(TOUPPER "x${CMAKE_BUILD_TYPE}" BUILD_TYPE)
if("${BUILD_TYPE}" STREQUAL "XDEBUG")
if(WIN32)
set_source_files_properties(src/nvhttp.cpp PROPERTIES COMPILE_FLAGS -O2)
set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/src/nvhttp.cpp" PROPERTIES COMPILE_FLAGS -O2)
endif()
else()
add_definitions(-DNDEBUG)
Expand Down
62 changes: 31 additions & 31 deletions cmake/compile_definitions/linux.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ if(${SUNSHINE_ENABLE_CUDA})
endif()
endif()
if(CUDA_FOUND)
include_directories(SYSTEM third-party/nvfbc)
include_directories(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/third-party/nvfbc")
list(APPEND PLATFORM_TARGET_FILES
src/platform/linux/cuda.h
src/platform/linux/cuda.cu
src/platform/linux/cuda.cpp
third-party/nvfbc/NvFBC.h)
"${CMAKE_CURRENT_SOURCE_DIR}/src/platform/linux/cuda.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/platform/linux/cuda.cu"
"${CMAKE_CURRENT_SOURCE_DIR}/src/platform/linux/cuda.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/third-party/nvfbc/NvFBC.h")

add_compile_definitions(SUNSHINE_BUILD_CUDA)
endif()
Expand All @@ -112,7 +112,7 @@ if(LIBDRM_FOUND AND LIBCAP_FOUND)
include_directories(SYSTEM ${LIBDRM_INCLUDE_DIRS} ${LIBCAP_INCLUDE_DIRS})
list(APPEND PLATFORM_LIBRARIES ${LIBDRM_LIBRARIES} ${LIBCAP_LIBRARIES})
list(APPEND PLATFORM_TARGET_FILES
src/platform/linux/kmsgrab.cpp)
"${CMAKE_CURRENT_SOURCE_DIR}/src/platform/linux/kmsgrab.cpp")
list(APPEND SUNSHINE_DEFINITIONS EGL_NO_X11=1)
elseif(NOT LIBDRM_FOUND)
message(WARNING "Missing libdrm")
Expand All @@ -131,8 +131,8 @@ if(LIBVA_FOUND)
include_directories(SYSTEM ${LIBVA_INCLUDE_DIR})
list(APPEND PLATFORM_LIBRARIES ${LIBVA_LIBRARIES} ${LIBVA_DRM_LIBRARIES})
list(APPEND PLATFORM_TARGET_FILES
src/platform/linux/vaapi.h
src/platform/linux/vaapi.cpp)
"${CMAKE_CURRENT_SOURCE_DIR}/src/platform/linux/vaapi.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/platform/linux/vaapi.cpp")
endif()

# wayland
Expand All @@ -145,14 +145,14 @@ if(WAYLAND_FOUND)
add_compile_definitions(SUNSHINE_BUILD_WAYLAND)

if(NOT SUNSHINE_SYSTEM_WAYLAND_PROTOCOLS)
set(WAYLAND_PROTOCOLS_DIR "${CMAKE_SOURCE_DIR}/third-party/wayland-protocols")
set(WAYLAND_PROTOCOLS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third-party/wayland-protocols")
else()
pkg_get_variable(WAYLAND_PROTOCOLS_DIR wayland-protocols pkgdatadir)
pkg_check_modules(WAYLAND_PROTOCOLS wayland-protocols REQUIRED)
endif()

GEN_WAYLAND("${WAYLAND_PROTOCOLS_DIR}" "unstable/xdg-output" xdg-output-unstable-v1)
GEN_WAYLAND("${CMAKE_SOURCE_DIR}/third-party/wlr-protocols" "unstable" wlr-export-dmabuf-unstable-v1)
GEN_WAYLAND("${CMAKE_CURRENT_SOURCE_DIR}/third-party/wlr-protocols" "unstable" wlr-export-dmabuf-unstable-v1)

include_directories(
SYSTEM
Expand All @@ -162,9 +162,9 @@ if(WAYLAND_FOUND)

list(APPEND PLATFORM_LIBRARIES ${WAYLAND_LIBRARIES})
list(APPEND PLATFORM_TARGET_FILES
src/platform/linux/wlgrab.cpp
src/platform/linux/wayland.h
src/platform/linux/wayland.cpp)
"${CMAKE_CURRENT_SOURCE_DIR}/src/platform/linux/wlgrab.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/platform/linux/wayland.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/platform/linux/wayland.cpp")
endif()

# x11
Expand All @@ -178,8 +178,8 @@ if(X11_FOUND)
include_directories(SYSTEM ${X11_INCLUDE_DIR})
list(APPEND PLATFORM_LIBRARIES ${X11_LIBRARIES})
list(APPEND PLATFORM_TARGET_FILES
src/platform/linux/x11grab.h
src/platform/linux/x11grab.cpp)
"${CMAKE_CURRENT_SOURCE_DIR}/src/platform/linux/x11grab.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/platform/linux/x11grab.cpp")
endif()

if(NOT ${CUDA_FOUND}
Expand Down Expand Up @@ -211,7 +211,7 @@ if(${SUNSHINE_ENABLE_TRAY})
include_directories(SYSTEM ${APPINDICATOR_INCLUDE_DIRS} ${LIBNOTIFY_INCLUDE_DIRS})
link_directories(${APPINDICATOR_LIBRARY_DIRS} ${LIBNOTIFY_LIBRARY_DIRS})

list(APPEND PLATFORM_TARGET_FILES third-party/tray/tray_linux.c)
list(APPEND PLATFORM_TARGET_FILES "${CMAKE_CURRENT_SOURCE_DIR}/third-party/tray/tray_linux.c")
list(APPEND SUNSHINE_EXTERNAL_LIBRARIES ${APPINDICATOR_LIBRARIES} ${LIBNOTIFY_LIBRARIES})
endif()
else()
Expand All @@ -224,19 +224,19 @@ if (${SUNSHINE_TRAY} EQUAL 0 AND SUNSHINE_REQUIRE_TRAY)
endif()

list(APPEND PLATFORM_TARGET_FILES
src/platform/linux/publish.cpp
src/platform/linux/graphics.h
src/platform/linux/graphics.cpp
src/platform/linux/misc.h
src/platform/linux/misc.cpp
src/platform/linux/audio.cpp
src/platform/linux/input.cpp
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)
"${CMAKE_CURRENT_SOURCE_DIR}/src/platform/linux/publish.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/platform/linux/graphics.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/platform/linux/graphics.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/platform/linux/misc.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/platform/linux/misc.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/platform/linux/audio.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/platform/linux/input.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/third-party/glad/src/egl.c"
"${CMAKE_CURRENT_SOURCE_DIR}/third-party/glad/src/gl.c"
"${CMAKE_CURRENT_SOURCE_DIR}/third-party/glad/include/EGL/eglplatform.h"
"${CMAKE_CURRENT_SOURCE_DIR}/third-party/glad/include/KHR/khrplatform.h"
"${CMAKE_CURRENT_SOURCE_DIR}/third-party/glad/include/glad/gl.h"
"${CMAKE_CURRENT_SOURCE_DIR}/third-party/glad/include/glad/egl.h")

list(APPEND PLATFORM_LIBRARIES
Boost::dynamic_linking
Expand All @@ -249,5 +249,5 @@ list(APPEND PLATFORM_LIBRARIES
include_directories(
SYSTEM
/usr/include/libevdev-1.0
third-party/nv-codec-headers/include
third-party/glad/include)
"${CMAKE_CURRENT_SOURCE_DIR}/third-party/nv-codec-headers/include"
"${CMAKE_CURRENT_SOURCE_DIR}/third-party/glad/include")
34 changes: 17 additions & 17 deletions cmake/compile_definitions/macos.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,32 @@ list(APPEND SUNSHINE_EXTERNAL_LIBRARIES
set(PLATFORM_INCLUDE_DIRS
${Boost_INCLUDE_DIR})

set(APPLE_PLIST_FILE ${SUNSHINE_SOURCE_ASSETS_DIR}/macos/assets/Info.plist)
set(APPLE_PLIST_FILE "${SUNSHINE_SOURCE_ASSETS_DIR}/macos/assets/Info.plist")

# todo - tray is not working on macos
set(SUNSHINE_TRAY 0)

set(PLATFORM_TARGET_FILES
src/platform/macos/av_audio.h
src/platform/macos/av_audio.m
src/platform/macos/av_img_t.h
src/platform/macos/av_video.h
src/platform/macos/av_video.m
src/platform/macos/display.mm
src/platform/macos/input.cpp
src/platform/macos/microphone.mm
src/platform/macos/misc.mm
src/platform/macos/misc.h
src/platform/macos/nv12_zero_device.cpp
src/platform/macos/nv12_zero_device.h
src/platform/macos/publish.cpp
third-party/TPCircularBuffer/TPCircularBuffer.c
third-party/TPCircularBuffer/TPCircularBuffer.h
"${CMAKE_CURRENT_SOURCE_DIR}/src/platform/macos/av_audio.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/platform/macos/av_audio.m"
"${CMAKE_CURRENT_SOURCE_DIR}/src/platform/macos/av_img_t.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/platform/macos/av_video.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/platform/macos/av_video.m"
"${CMAKE_CURRENT_SOURCE_DIR}/src/platform/macos/display.mm"
"${CMAKE_CURRENT_SOURCE_DIR}/src/platform/macos/input.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/platform/macos/microphone.mm"
"${CMAKE_CURRENT_SOURCE_DIR}/src/platform/macos/misc.mm"
"${CMAKE_CURRENT_SOURCE_DIR}/src/platform/macos/misc.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/platform/macos/nv12_zero_device.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/platform/macos/nv12_zero_device.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/platform/macos/publish.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/third-party/TPCircularBuffer/TPCircularBuffer.c"
"${CMAKE_CURRENT_SOURCE_DIR}/third-party/TPCircularBuffer/TPCircularBuffer.h"
${APPLE_PLIST_FILE})

if(SUNSHINE_ENABLE_TRAY)
list(APPEND SUNSHINE_EXTERNAL_LIBRARIES
${COCOA})
list(APPEND PLATFORM_TARGET_FILES
third-party/tray/tray_darwin.m)
"${CMAKE_CURRENT_SOURCE_DIR}/third-party/tray/tray_darwin.m")
endif()
Loading

0 comments on commit 6f0bbf9

Please sign in to comment.