Fix build for SUNSHINE_ENABLE_WAYLAND=OFF

This commit is contained in:
Loki 2021-08-31 21:19:02 +02:00
parent 7c51fbfd18
commit 74f673e23c
2 changed files with 48 additions and 3 deletions

View File

@ -108,12 +108,18 @@ else()
if(${SUNSHINE_ENABLE_X11})
find_package(X11)
else()
set(X11_FOUND OFF)
endif()
if(${SUNSHINE_ENABLE_DRM})
find_package(LIBDRM)
else()
set(LIBDRM_FOUND OFF)
endif()
if(${SUNSHINE_ENABLE_WAYLAND})
find_package(Wayland)
else()
set(WAYLAND_FOUND OFF)
endif()
find_package(FFMPEG REQUIRED)
@ -165,11 +171,10 @@ else()
list(APPEND PLATFORM_LIBRARIES ${WAYLAND_LIBRARIES})
list(APPEND PLATFORM_TARGET_FILES
sunshine/platform/linux/wlgrab.cpp
sunshine/platform/linux/wayland.cpp
sunshine/platform/linux/wayland.h)
sunshine/platform/linux/wayland.cpp)
endif()
if(NOT ${X11_FOUND} AND NOT ${LIBDRM_FOUND} AND NOT ${WAYLAND_FOUND})
message(FATAL_ERROR "Couldn't find either x11 or libdrm")
message(FATAL_ERROR "Couldn't find either x11, wayland or libdrm")
endif()
list(APPEND PLATFORM_TARGET_FILES
@ -183,6 +188,7 @@ else()
sunshine/platform/linux/audio.cpp
sunshine/platform/linux/input.cpp
sunshine/platform/linux/x11grab.h
sunshine/platform/linux/wayland.h
third-party/glad/src/egl.c
third-party/glad/src/gl.c
third-party/glad/include/EGL/eglplatform.h

View File

@ -3,11 +3,19 @@
#include <bitset>
#ifdef SUNSHINE_BUILD_WAYLAND
#include <wlr-export-dmabuf-unstable-v1.h>
#include <xdg-output-unstable-v1.h>
#endif
#include "graphics.h"
/**
* The classes defined in this macro block should only be used by
* cpp files whose compilation depends on SUNSHINE_BUILD_WAYLAND
*/
#ifdef SUNSHINE_BUILD_WAYLAND
namespace wl {
using display_internal_t = util::safe_ptr<wl_display, wl_display_disconnect>;
@ -179,5 +187,36 @@ std::vector<std::unique_ptr<monitor_t>> monitors(const char *display_name = null
int init();
} // namespace wl
#else
struct wl_output;
struct zxdg_output_manager_v1;
namespace wl {
class monitor_t {
public:
monitor_t(monitor_t &&) = delete;
monitor_t(const monitor_t &) = delete;
monitor_t &operator=(const monitor_t &) = delete;
monitor_t &operator=(monitor_t &&) = delete;
monitor_t(wl_output *output);
void listen(zxdg_output_manager_v1 *output_manager);
wl_output *output;
std::string name;
std::string description;
platf::touch_port_t viewport;
};
inline std::vector<std::unique_ptr<monitor_t>> monitors(const char *display_name = nullptr) { return {}; }
inline int init() { return -1; }
} // namespace wl
#endif
#endif