mirror of https://github.com/PCSX2/pcsx2.git
CMake: Add options for building with X11/Wayland
This commit is contained in:
parent
fadd97c021
commit
114d78d378
|
@ -51,6 +51,11 @@ option(PORTAUDIO_API "Build portaudio support on SPU2" ON)
|
||||||
option(SDL2_API "Use SDL2 on SPU2 and PAD Linux (wxWidget mustn't be built with SDL1.2 support" ON)
|
option(SDL2_API "Use SDL2 on SPU2 and PAD Linux (wxWidget mustn't be built with SDL1.2 support" ON)
|
||||||
option(GTK2_API "Use GTK2 api (legacy)")
|
option(GTK2_API "Use GTK2 api (legacy)")
|
||||||
|
|
||||||
|
if(UNIX AND NOT APPLE)
|
||||||
|
option(X11_API "Enable X11 support" ON)
|
||||||
|
option(WAYLAND_API "Enable Wayland support" OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(PACKAGE_MODE)
|
if(PACKAGE_MODE)
|
||||||
# Compile all source codes with those defines
|
# Compile all source codes with those defines
|
||||||
list(APPEND PCSX2_DEFS
|
list(APPEND PCSX2_DEFS
|
||||||
|
@ -234,6 +239,14 @@ if(USE_VTUNE)
|
||||||
list(APPEND PCSX2_DEFS ENABLE_VTUNE)
|
list(APPEND PCSX2_DEFS ENABLE_VTUNE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(X11_API)
|
||||||
|
list(APPEND PCSX2_DEFS X11_API)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WAYLAND_API)
|
||||||
|
list(APPEND PCSX2_DEFS WAYLAND_API)
|
||||||
|
endif()
|
||||||
|
|
||||||
# -Wno-attributes: "always_inline function might not be inlinable" <= real spam (thousand of warnings!!!)
|
# -Wno-attributes: "always_inline function might not be inlinable" <= real spam (thousand of warnings!!!)
|
||||||
# -Wno-missing-field-initializers: standard allow to init only the begin of struct/array in static init. Just a silly warning.
|
# -Wno-missing-field-initializers: standard allow to init only the begin of struct/array in static init. Just a silly warning.
|
||||||
# Note: future GCC (aka GCC 5.1.1) has less false positive so warning could maybe put back
|
# Note: future GCC (aka GCC 5.1.1) has less false positive so warning could maybe put back
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
# Try to find Wayland on a Unix system
|
||||||
|
#
|
||||||
|
# This will define:
|
||||||
|
#
|
||||||
|
# WAYLAND_FOUND - True if Wayland is found
|
||||||
|
# WAYLAND_LIBRARIES - Link these to use Wayland
|
||||||
|
# WAYLAND_INCLUDE_DIR - Include directory for Wayland
|
||||||
|
# WAYLAND_DEFINITIONS - Compiler flags for using Wayland
|
||||||
|
#
|
||||||
|
# In addition the following more fine grained variables will be defined:
|
||||||
|
#
|
||||||
|
# WAYLAND_CLIENT_FOUND WAYLAND_CLIENT_INCLUDE_DIR WAYLAND_CLIENT_LIBRARIES
|
||||||
|
# WAYLAND_SERVER_FOUND WAYLAND_SERVER_INCLUDE_DIR WAYLAND_SERVER_LIBRARIES
|
||||||
|
# WAYLAND_EGL_FOUND WAYLAND_EGL_INCLUDE_DIR WAYLAND_EGL_LIBRARIES
|
||||||
|
#
|
||||||
|
# Copyright (c) 2013 Martin Gräßlin <mgraesslin@kde.org>
|
||||||
|
#
|
||||||
|
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||||
|
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||||
|
|
||||||
|
IF (NOT WIN32)
|
||||||
|
IF (WAYLAND_INCLUDE_DIR AND WAYLAND_LIBRARIES)
|
||||||
|
# In the cache already
|
||||||
|
SET(WAYLAND_FIND_QUIETLY TRUE)
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
|
# Use pkg-config to get the directories and then use these values
|
||||||
|
# in the FIND_PATH() and FIND_LIBRARY() calls
|
||||||
|
FIND_PACKAGE(PkgConfig)
|
||||||
|
PKG_CHECK_MODULES(PKG_WAYLAND QUIET wayland-client wayland-server wayland-egl wayland-cursor)
|
||||||
|
|
||||||
|
SET(WAYLAND_DEFINITIONS ${PKG_WAYLAND_CFLAGS})
|
||||||
|
|
||||||
|
FIND_PATH(WAYLAND_CLIENT_INCLUDE_DIR NAMES wayland-client.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS})
|
||||||
|
FIND_PATH(WAYLAND_SERVER_INCLUDE_DIR NAMES wayland-server.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS})
|
||||||
|
FIND_PATH(WAYLAND_EGL_INCLUDE_DIR NAMES wayland-egl.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS})
|
||||||
|
FIND_PATH(WAYLAND_CURSOR_INCLUDE_DIR NAMES wayland-cursor.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
FIND_LIBRARY(WAYLAND_CLIENT_LIBRARIES NAMES wayland-client HINTS ${PKG_WAYLAND_LIBRARY_DIRS})
|
||||||
|
FIND_LIBRARY(WAYLAND_SERVER_LIBRARIES NAMES wayland-server HINTS ${PKG_WAYLAND_LIBRARY_DIRS})
|
||||||
|
FIND_LIBRARY(WAYLAND_EGL_LIBRARIES NAMES wayland-egl HINTS ${PKG_WAYLAND_LIBRARY_DIRS})
|
||||||
|
FIND_LIBRARY(WAYLAND_CURSOR_LIBRARIES NAMES wayland-cursor HINTS ${PKG_WAYLAND_LIBRARY_DIRS})
|
||||||
|
|
||||||
|
set(WAYLAND_INCLUDE_DIR ${WAYLAND_CLIENT_INCLUDE_DIR} ${WAYLAND_SERVER_INCLUDE_DIR} ${WAYLAND_EGL_INCLUDE_DIR} ${WAYLAND_CURSOR_INCLUDE_DIR})
|
||||||
|
|
||||||
|
set(WAYLAND_LIBRARIES ${WAYLAND_CLIENT_LIBRARIES} ${WAYLAND_SERVER_LIBRARIES} ${WAYLAND_EGL_LIBRARIES} ${WAYLAND_CURSOR_LIBRARIES})
|
||||||
|
|
||||||
|
list(REMOVE_DUPLICATES WAYLAND_INCLUDE_DIR)
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_CLIENT DEFAULT_MSG WAYLAND_CLIENT_LIBRARIES WAYLAND_CLIENT_INCLUDE_DIR)
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_SERVER DEFAULT_MSG WAYLAND_SERVER_LIBRARIES WAYLAND_SERVER_INCLUDE_DIR)
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_EGL DEFAULT_MSG WAYLAND_EGL_LIBRARIES WAYLAND_EGL_INCLUDE_DIR)
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_CURSOR DEFAULT_MSG WAYLAND_CURSOR_LIBRARIES WAYLAND_CURSOR_INCLUDE_DIR)
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND DEFAULT_MSG WAYLAND_LIBRARIES WAYLAND_INCLUDE_DIR)
|
||||||
|
|
||||||
|
MARK_AS_ADVANCED(
|
||||||
|
WAYLAND_INCLUDE_DIR WAYLAND_LIBRARIES
|
||||||
|
WAYLAND_CLIENT_INCLUDE_DIR WAYLAND_CLIENT_LIBRARIES
|
||||||
|
WAYLAND_SERVER_INCLUDE_DIR WAYLAND_SERVER_LIBRARIES
|
||||||
|
WAYLAND_EGL_INCLUDE_DIR WAYLAND_EGL_LIBRARIES
|
||||||
|
WAYLAND_CURSOR_INCLUDE_DIR WAYLAND_CURSOR_LIBRARIES
|
||||||
|
)
|
||||||
|
|
||||||
|
ENDIF ()
|
|
@ -121,9 +121,14 @@ else()
|
||||||
|
|
||||||
if(UNIX AND NOT APPLE)
|
if(UNIX AND NOT APPLE)
|
||||||
check_lib(EGL EGL EGL/egl.h)
|
check_lib(EGL EGL EGL/egl.h)
|
||||||
check_lib(X11_XCB X11-xcb X11/Xlib-xcb.h)
|
if(X11_API)
|
||||||
check_lib(XCB xcb xcb/xcb.h)
|
check_lib(X11_XCB X11-xcb X11/Xlib-xcb.h)
|
||||||
check_lib(XRANDR xrandr)
|
check_lib(XCB xcb xcb/xcb.h)
|
||||||
|
check_lib(XRANDR xrandr)
|
||||||
|
endif()
|
||||||
|
if(WAYLAND_API)
|
||||||
|
find_package(Wayland REQUIRED)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(Linux)
|
if(Linux)
|
||||||
check_lib(AIO aio libaio.h)
|
check_lib(AIO aio libaio.h)
|
||||||
|
@ -173,6 +178,9 @@ else()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
if(WAYLAND_API)
|
||||||
|
find_package(Wayland REQUIRED)
|
||||||
|
endif()
|
||||||
|
|
||||||
#----------------------------------------
|
#----------------------------------------
|
||||||
# Use system include
|
# Use system include
|
||||||
|
|
|
@ -70,6 +70,10 @@ if(TARGET SDL::SDL)
|
||||||
target_link_libraries(PCSX2_FLAGS INTERFACE SDL::SDL)
|
target_link_libraries(PCSX2_FLAGS INTERFACE SDL::SDL)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(WAYLAND_CLIENT_FOUND)
|
||||||
|
target_compile_definitions(PCSX2 PRIVATE WAYLAND_BUILD)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
# Resources
|
# Resources
|
||||||
target_sources(PCSX2 PRIVATE
|
target_sources(PCSX2 PRIVATE
|
||||||
|
@ -1392,18 +1396,27 @@ if(Linux)
|
||||||
PkgConfig::AIO
|
PkgConfig::AIO
|
||||||
PkgConfig::EGL
|
PkgConfig::EGL
|
||||||
PkgConfig::LIBUDEV
|
PkgConfig::LIBUDEV
|
||||||
PkgConfig::X11_XCB
|
|
||||||
PkgConfig::XCB
|
|
||||||
X11::X11
|
|
||||||
ALSA::ALSA
|
ALSA::ALSA
|
||||||
)
|
)
|
||||||
elseif(UNIX AND NOT APPLE)
|
elseif(UNIX AND NOT APPLE)
|
||||||
target_link_libraries(PCSX2_FLAGS INTERFACE
|
target_link_libraries(PCSX2_FLAGS INTERFACE
|
||||||
X11::X11
|
|
||||||
PkgConfig::XCB
|
|
||||||
PkgConfig::EGL
|
PkgConfig::EGL
|
||||||
PkgConfig::X11_XCB
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(UNIX AND NOT APPLE)
|
||||||
|
if(X11_API)
|
||||||
|
target_link_libraries(PCSX2_FLAGS INTERFACE
|
||||||
|
PkgConfig::X11_XCB
|
||||||
|
PkgConfig::XCB
|
||||||
|
X11::X11
|
||||||
)
|
)
|
||||||
|
endif()
|
||||||
|
if(WAYLAND_API)
|
||||||
|
target_link_libraries(PCSX2_FLAGS INTERFACE
|
||||||
|
${WAYLAND_CLIENT_LIBRARIES}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Windows
|
# Windows
|
||||||
|
|
Loading…
Reference in New Issue