Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(cmake): use CMAKE_SOURCE_DIR property #2091

Merged
merged 1 commit into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
endif()

# set the module path, used for includes
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

# set version info for this build
include(${CMAKE_MODULE_PATH}/prep/build_version.cmake)
Expand Down
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_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_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_SOURCE_DIR}/third-party/nanors/rs.c"
"${CMAKE_SOURCE_DIR}/third-party/nanors/rs.h"
"${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/src/Input.h"
"${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/src/Rtsp.h"
"${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/src/RtspParser.c"
"${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/src/Video.h"
"${CMAKE_SOURCE_DIR}/third-party/tray/tray.h"
"${CMAKE_SOURCE_DIR}/src/upnp.cpp"
"${CMAKE_SOURCE_DIR}/src/upnp.h"
"${CMAKE_SOURCE_DIR}/src/cbs.cpp"
"${CMAKE_SOURCE_DIR}/src/utility.h"
"${CMAKE_SOURCE_DIR}/src/uuid.h"
"${CMAKE_SOURCE_DIR}/src/config.h"
"${CMAKE_SOURCE_DIR}/src/config.cpp"
"${CMAKE_SOURCE_DIR}/src/main.cpp"
"${CMAKE_SOURCE_DIR}/src/main.h"
"${CMAKE_SOURCE_DIR}/src/crypto.cpp"
"${CMAKE_SOURCE_DIR}/src/crypto.h"
"${CMAKE_SOURCE_DIR}/src/nvhttp.cpp"
"${CMAKE_SOURCE_DIR}/src/nvhttp.h"
"${CMAKE_SOURCE_DIR}/src/httpcommon.cpp"
"${CMAKE_SOURCE_DIR}/src/httpcommon.h"
"${CMAKE_SOURCE_DIR}/src/confighttp.cpp"
"${CMAKE_SOURCE_DIR}/src/confighttp.h"
"${CMAKE_SOURCE_DIR}/src/rtsp.cpp"
"${CMAKE_SOURCE_DIR}/src/rtsp.h"
"${CMAKE_SOURCE_DIR}/src/stream.cpp"
"${CMAKE_SOURCE_DIR}/src/stream.h"
"${CMAKE_SOURCE_DIR}/src/video.cpp"
"${CMAKE_SOURCE_DIR}/src/video.h"
"${CMAKE_SOURCE_DIR}/src/video_colorspace.cpp"
"${CMAKE_SOURCE_DIR}/src/video_colorspace.h"
"${CMAKE_SOURCE_DIR}/src/input.cpp"
"${CMAKE_SOURCE_DIR}/src/input.h"
"${CMAKE_SOURCE_DIR}/src/audio.cpp"
"${CMAKE_SOURCE_DIR}/src/audio.h"
"${CMAKE_SOURCE_DIR}/src/platform/common.h"
"${CMAKE_SOURCE_DIR}/src/process.cpp"
"${CMAKE_SOURCE_DIR}/src/process.h"
"${CMAKE_SOURCE_DIR}/src/network.cpp"
"${CMAKE_SOURCE_DIR}/src/network.h"
"${CMAKE_SOURCE_DIR}/src/move_by_copy.h"
"${CMAKE_SOURCE_DIR}/src/system_tray.cpp"
"${CMAKE_SOURCE_DIR}/src/system_tray.h"
"${CMAKE_SOURCE_DIR}/src/task_pool.h"
"${CMAKE_SOURCE_DIR}/src/thread_pool.h"
"${CMAKE_SOURCE_DIR}/src/thread_safe.h"
"${CMAKE_SOURCE_DIR}/src/sync.h"
"${CMAKE_SOURCE_DIR}/src/round_robin.h"
"${CMAKE_SOURCE_DIR}/src/stat_trackers.h"
"${CMAKE_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_SOURCE_DIR}/src/upnp.cpp" PROPERTIES COMPILE_FLAGS -Wno-pedantic)

set_source_files_properties(third-party/nanors/rs.c
set_source_files_properties("${CMAKE_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_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_SOURCE_DIR}/third-party"
"${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/enet/include"
"${CMAKE_SOURCE_DIR}/third-party/nanors"
"${CMAKE_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_SOURCE_DIR}/src/nvhttp.cpp" PROPERTIES COMPILE_FLAGS -O2)
endif()
else()
add_definitions(-DNDEBUG)
Expand Down
58 changes: 29 additions & 29 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_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_SOURCE_DIR}/src/platform/linux/cuda.h"
"${CMAKE_SOURCE_DIR}/src/platform/linux/cuda.cu"
"${CMAKE_SOURCE_DIR}/src/platform/linux/cuda.cpp"
"${CMAKE_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_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_SOURCE_DIR}/src/platform/linux/vaapi.h"
"${CMAKE_SOURCE_DIR}/src/platform/linux/vaapi.cpp")
endif()

# wayland
Expand Down Expand Up @@ -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_SOURCE_DIR}/src/platform/linux/wlgrab.cpp"
"${CMAKE_SOURCE_DIR}/src/platform/linux/wayland.h"
"${CMAKE_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_SOURCE_DIR}/src/platform/linux/x11grab.h"
"${CMAKE_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_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_SOURCE_DIR}/src/platform/linux/publish.cpp"
"${CMAKE_SOURCE_DIR}/src/platform/linux/graphics.h"
"${CMAKE_SOURCE_DIR}/src/platform/linux/graphics.cpp"
"${CMAKE_SOURCE_DIR}/src/platform/linux/misc.h"
"${CMAKE_SOURCE_DIR}/src/platform/linux/misc.cpp"
"${CMAKE_SOURCE_DIR}/src/platform/linux/audio.cpp"
"${CMAKE_SOURCE_DIR}/src/platform/linux/input.cpp"
"${CMAKE_SOURCE_DIR}/third-party/glad/src/egl.c"
"${CMAKE_SOURCE_DIR}/third-party/glad/src/gl.c"
"${CMAKE_SOURCE_DIR}/third-party/glad/include/EGL/eglplatform.h"
"${CMAKE_SOURCE_DIR}/third-party/glad/include/KHR/khrplatform.h"
"${CMAKE_SOURCE_DIR}/third-party/glad/include/glad/gl.h"
"${CMAKE_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_SOURCE_DIR}/third-party/nv-codec-headers/include"
"${CMAKE_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_SOURCE_DIR}/src/platform/macos/av_audio.h"
"${CMAKE_SOURCE_DIR}/src/platform/macos/av_audio.m"
"${CMAKE_SOURCE_DIR}/src/platform/macos/av_img_t.h"
"${CMAKE_SOURCE_DIR}/src/platform/macos/av_video.h"
"${CMAKE_SOURCE_DIR}/src/platform/macos/av_video.m"
"${CMAKE_SOURCE_DIR}/src/platform/macos/display.mm"
"${CMAKE_SOURCE_DIR}/src/platform/macos/input.cpp"
"${CMAKE_SOURCE_DIR}/src/platform/macos/microphone.mm"
"${CMAKE_SOURCE_DIR}/src/platform/macos/misc.mm"
"${CMAKE_SOURCE_DIR}/src/platform/macos/misc.h"
"${CMAKE_SOURCE_DIR}/src/platform/macos/nv12_zero_device.cpp"
"${CMAKE_SOURCE_DIR}/src/platform/macos/nv12_zero_device.h"
"${CMAKE_SOURCE_DIR}/src/platform/macos/publish.cpp"
"${CMAKE_SOURCE_DIR}/third-party/TPCircularBuffer/TPCircularBuffer.c"
"${CMAKE_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_SOURCE_DIR}/third-party/tray/tray_darwin.m")
endif()
48 changes: 24 additions & 24 deletions cmake/compile_definitions/windows.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,42 +18,42 @@ add_definitions(-DMINIUPNP_STATICLIB)
add_subdirectory(tools) # todo - this is temporary, only tools for Windows are needed, for now

# nvidia
include_directories(SYSTEM third-party/nvapi-open-source-sdk)
include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/third-party/nvapi-open-source-sdk")
file(GLOB NVPREFS_FILES CONFIGURE_DEPENDS
"third-party/nvapi-open-source-sdk/*.h"
"src/platform/windows/nvprefs/*.cpp"
"src/platform/windows/nvprefs/*.h")
"${CMAKE_SOURCE_DIR}/third-party/nvapi-open-source-sdk/*.h"
"${CMAKE_SOURCE_DIR}/src/platform/windows/nvprefs/*.cpp"
"${CMAKE_SOURCE_DIR}/src/platform/windows/nvprefs/*.h")

# vigem
include_directories(SYSTEM third-party/ViGEmClient/include)
set_source_files_properties(third-party/ViGEmClient/src/ViGEmClient.cpp
include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/third-party/ViGEmClient/include")
set_source_files_properties("${CMAKE_SOURCE_DIR}/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
set_source_files_properties("${CMAKE_SOURCE_DIR}/third-party/ViGEmClient/src/ViGEmClient.cpp"
PROPERTIES COMPILE_FLAGS "-Wno-unknown-pragmas -Wno-misleading-indentation -Wno-class-memaccess")

# sunshine icon
if(NOT DEFINED SUNSHINE_ICON_PATH)
set(SUNSHINE_ICON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/sunshine.ico")
set(SUNSHINE_ICON_PATH "${CMAKE_SOURCE_DIR}/sunshine.ico")
endif()

configure_file(src/platform/windows/windows.rs.in windows.rc @ONLY)
configure_file("${CMAKE_SOURCE_DIR}/src/platform/windows/windows.rs.in" windows.rc @ONLY)

set(PLATFORM_TARGET_FILES
"${CMAKE_CURRENT_BINARY_DIR}/windows.rc"
src/platform/windows/publish.cpp
src/platform/windows/misc.h
src/platform/windows/misc.cpp
src/platform/windows/input.cpp
src/platform/windows/display.h
src/platform/windows/display_base.cpp
src/platform/windows/display_vram.cpp
src/platform/windows/display_ram.cpp
src/platform/windows/audio.cpp
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
"${CMAKE_SOURCE_DIR}/src/platform/windows/publish.cpp"
"${CMAKE_SOURCE_DIR}/src/platform/windows/misc.h"
"${CMAKE_SOURCE_DIR}/src/platform/windows/misc.cpp"
"${CMAKE_SOURCE_DIR}/src/platform/windows/input.cpp"
"${CMAKE_SOURCE_DIR}/src/platform/windows/display.h"
"${CMAKE_SOURCE_DIR}/src/platform/windows/display_base.cpp"
"${CMAKE_SOURCE_DIR}/src/platform/windows/display_vram.cpp"
"${CMAKE_SOURCE_DIR}/src/platform/windows/display_ram.cpp"
"${CMAKE_SOURCE_DIR}/src/platform/windows/audio.cpp"
"${CMAKE_SOURCE_DIR}/third-party/ViGEmClient/src/ViGEmClient.cpp"
"${CMAKE_SOURCE_DIR}/third-party/ViGEmClient/include/ViGEm/Client.h"
"${CMAKE_SOURCE_DIR}/third-party/ViGEmClient/include/ViGEm/Common.h"
"${CMAKE_SOURCE_DIR}/third-party/ViGEmClient/include/ViGEm/Util.h"
"${CMAKE_SOURCE_DIR}/third-party/ViGEmClient/include/ViGEm/km/BusShared.h"
${NVPREFS_FILES})

set(OPENSSL_LIBRARIES
Expand All @@ -78,5 +78,5 @@ list(PREPEND PLATFORM_LIBRARIES

if(SUNSHINE_ENABLE_TRAY)
list(APPEND PLATFORM_TARGET_FILES
third-party/tray/tray_windows.c)
"${CMAKE_SOURCE_DIR}/third-party/tray/tray_windows.c")
endif()
Loading
Loading