From 7352e7277a65d8f18cfe2b1669873ae9af933605 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Mon, 14 Oct 2024 18:28:55 -0400 Subject: [PATCH] build(linux): fail build if capture dependencies not found (#3305) --- cmake/compile_definitions/linux.cmake | 23 ++++++++--------------- cmake/prep/options.cmake | 2 +- packaging/sunshine.rb | 2 ++ 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/cmake/compile_definitions/linux.cmake b/cmake/compile_definitions/linux.cmake index 94465abeb38..6f10aaf92eb 100644 --- a/cmake/compile_definitions/linux.cmake +++ b/cmake/compile_definitions/linux.cmake @@ -67,6 +67,8 @@ if(${SUNSHINE_ENABLE_CUDA}) # message(STATUS "CUDA NVCC Flags: ${CUDA_NVCC_FLAGS}") message(STATUS "CUDA Architectures: ${CMAKE_CUDA_ARCHITECTURES}") + elseif(${CUDA_FAIL_ON_MISSING}) + message(FATAL_ERROR "CUDA not found") endif() endif() if(CUDA_FOUND) @@ -82,8 +84,8 @@ endif() # drm if(${SUNSHINE_ENABLE_DRM}) - find_package(LIBDRM) - find_package(LIBCAP) + find_package(LIBDRM REQUIRED) + find_package(LIBCAP REQUIRED) else() set(LIBDRM_FOUND OFF) set(LIBCAP_FOUND OFF) @@ -95,10 +97,6 @@ if(LIBDRM_FOUND AND LIBCAP_FOUND) list(APPEND PLATFORM_TARGET_FILES "${CMAKE_SOURCE_DIR}/src/platform/linux/kmsgrab.cpp") list(APPEND SUNSHINE_DEFINITIONS EGL_NO_X11=1) -elseif(NOT LIBDRM_FOUND) - message(WARNING "Missing libdrm") -elseif(NOT LIBDRM_FOUND) - message(WARNING "Missing libcap") endif() # evdev @@ -106,7 +104,7 @@ include(dependencies/libevdev_Sunshine) # vaapi if(${SUNSHINE_ENABLE_VAAPI}) - find_package(Libva) + find_package(Libva REQUIRED) else() set(LIBVA_FOUND OFF) endif() @@ -121,7 +119,7 @@ endif() # wayland if(${SUNSHINE_ENABLE_WAYLAND}) - find_package(Wayland) + find_package(Wayland REQUIRED) else() set(WAYLAND_FOUND OFF) endif() @@ -153,7 +151,7 @@ endif() # x11 if(${SUNSHINE_ENABLE_X11}) - find_package(X11) + find_package(X11 REQUIRED) else() set(X11_FOUND OFF) endif() @@ -187,10 +185,9 @@ if(${SUNSHINE_ENABLE_TRAY}) endif() pkg_check_modules(LIBNOTIFY libnotify) if(NOT APPINDICATOR_FOUND OR NOT LIBNOTIFY_FOUND) - set(SUNSHINE_TRAY 0) - message(WARNING "Missing appindicator or libnotify, disabling tray icon") message(STATUS "APPINDICATOR_FOUND: ${APPINDICATOR_FOUND}") message(STATUS "LIBNOTIFY_FOUND: ${LIBNOTIFY_FOUND}") + message(FATAL_ERROR "Couldn't find either appindicator or libnotify") else() include_directories(SYSTEM ${APPINDICATOR_INCLUDE_DIRS} ${LIBNOTIFY_INCLUDE_DIRS}) link_directories(${APPINDICATOR_LIBRARY_DIRS} ${LIBNOTIFY_LIBRARY_DIRS}) @@ -203,10 +200,6 @@ else() message(STATUS "Tray icon disabled") endif() -if(${SUNSHINE_ENABLE_TRAY} AND ${SUNSHINE_TRAY} EQUAL 0 AND SUNSHINE_REQUIRE_TRAY) - message(FATAL_ERROR "Tray icon is required") -endif() - if(${SUNSHINE_USE_LEGACY_INPUT}) # TODO: Remove this legacy option after the next stable release list(APPEND PLATFORM_TARGET_FILES "${CMAKE_SOURCE_DIR}/src/platform/linux/input/legacy_input.cpp") else() diff --git a/cmake/prep/options.cmake b/cmake/prep/options.cmake index 2914c4db882..ba1dc193238 100644 --- a/cmake/prep/options.cmake +++ b/cmake/prep/options.cmake @@ -22,7 +22,6 @@ option(BUILD_WERROR "Enable -Werror flag." OFF) option(SUNSHINE_CONFIGURE_ONLY "Configure special files only, then exit." OFF) option(SUNSHINE_ENABLE_TRAY "Enable system tray icon. This option will be ignored on macOS." ON) -option(SUNSHINE_REQUIRE_TRAY "Require system tray icon. Fail the build if tray requirements are not met." ON) option(SUNSHINE_SYSTEM_WAYLAND_PROTOCOLS "Use system installation of wayland-protocols rather than the submodule." OFF) @@ -32,6 +31,7 @@ else() option(BOOST_USE_STATIC "Use static boost libraries." ON) endif() +option(CUDA_FAIL_ON_MISSING "Fail the build if CUDA is not found." ON) option(CUDA_INHERIT_COMPILE_OPTIONS "When building CUDA code, inherit compile options from the the main project. You may want to disable this if your IDE throws errors about unknown flags after running cmake." ON) diff --git a/packaging/sunshine.rb b/packaging/sunshine.rb index 68193ec1056..98b48eaaff0 100644 --- a/packaging/sunshine.rb +++ b/packaging/sunshine.rb @@ -105,6 +105,8 @@ def install ohai "Linking against ICU libraries at: #{icu4c_lib_path}" end + args << "-DCUDA_FAIL_ON_MISSING=OFF" if OS.linux? + system "cmake", "-S", ".", "-B", "build", *std_cmake_args, *args cd "build" do