Skip to content
Draft
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ endif()
OPTION(NO_WEBVIEW "Disable wxWebview usage (for start page and documentation)" OFF)
OPTION(NO_LUA "Disable Lua/Scripting features to reduce compile time" OFF)
OPTION(NO_FLUIDSYNTH "Disable FluidSynth MIDI playback" OFF)
OPTION(NO_WAYLAND "Disable experimental support for wayland" ON)
OPTION(BUILD_PK3 "Build the SLADE pk3 file from dist/res" ON)
OPTION(BUILD_WX "Download and build wxWidgets instead of using system-installed libs" OFF)

Expand Down
125 changes: 125 additions & 0 deletions cmake/find_modules/FindWayland.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# cmake-format: off
# 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_DIRS - Include directory for Wayland
# WAYLAND_COMPILE_FLAGS - Compiler flags for using Wayland
#
# In addition the following more fine grained variables will be defined:
#
# Wayland_Client_FOUND WAYLAND_CLIENT_INCLUDE_DIRS WAYLAND_CLIENT_LIBRARIES
# Wayland_Server_FOUND WAYLAND_SERVER_INCLUDE_DIRS WAYLAND_SERVER_LIBRARIES
# Wayland_EGL_FOUND WAYLAND_EGL_INCLUDE_DIRS WAYLAND_EGL_LIBRARIES
# Wayland_Cursor_FOUND WAYLAND_CURSOR_INCLUDE_DIRS WAYLAND_CURSOR_LIBRARIES
#
# Copyright (c) 2013 Martin Gräßlin <[email protected]> 2020 Georges Basile
# Stavracas Neto <[email protected]>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.

# Use pkg-config to get the directories and then use these values in the
# find_path() and find_library() calls
# cmake-format: on

find_package(PkgConfig)
pkg_check_modules(PKG_WAYLAND QUIET wayland-client wayland-server wayland-egl wayland-cursor)

set(WAYLAND_COMPILE_FLAGS ${PKG_WAYLAND_CFLAGS})

find_path(
WAYLAND_CLIENT_INCLUDE_DIRS
NAMES wayland-client.h
HINTS ${PKG_WAYLAND_INCLUDE_DIRS})
find_library(
WAYLAND_CLIENT_LIBRARIES
NAMES wayland-client
HINTS ${PKG_WAYLAND_LIBRARY_DIRS})
if(WAYLAND_CLIENT_INCLUDE_DIRS AND WAYLAND_CLIENT_LIBRARIES)
set(Wayland_Client_FOUND TRUE)
else()
set(Wayland_Client_FOUND FALSE)
endif()
mark_as_advanced(WAYLAND_CLIENT_INCLUDE_DIRS WAYLAND_CLIENT_LIBRARIES)

find_path(
WAYLAND_CURSOR_INCLUDE_DIRS
NAMES wayland-cursor.h
HINTS ${PKG_WAYLAND_INCLUDE_DIRS})
find_library(
WAYLAND_CURSOR_LIBRARIES
NAMES wayland-cursor
HINTS ${PKG_WAYLAND_LIBRARY_DIRS})
if(WAYLAND_CURSOR_INCLUDE_DIRS AND WAYLAND_CURSOR_LIBRARIES)
set(Wayland_Cursor_FOUND TRUE)
else()
set(Wayland_Cursor_FOUND FALSE)
endif()
mark_as_advanced(WAYLAND_CURSOR_INCLUDE_DIRS WAYLAND_CURSOR_LIBRARIES)

find_path(
WAYLAND_EGL_INCLUDE_DIRS
NAMES wayland-egl.h
HINTS ${PKG_WAYLAND_INCLUDE_DIRS})
find_library(
WAYLAND_EGL_LIBRARIES
NAMES wayland-egl
HINTS ${PKG_WAYLAND_LIBRARY_DIRS})
if(WAYLAND_EGL_INCLUDE_DIRS AND WAYLAND_EGL_LIBRARIES)
set(Wayland_EGL_FOUND TRUE)
else()
set(Wayland_EGL_FOUND FALSE)
endif()
mark_as_advanced(WAYLAND_EGL_INCLUDE_DIRS WAYLAND_EGL_LIBRARIES)

find_path(
WAYLAND_SERVER_INCLUDE_DIRS
NAMES wayland-server.h
HINTS ${PKG_WAYLAND_INCLUDE_DIRS})
find_library(
WAYLAND_SERVER_LIBRARIES
NAMES wayland-server
HINTS ${PKG_WAYLAND_LIBRARY_DIRS})
if(WAYLAND_SERVER_INCLUDE_DIRS AND WAYLAND_SERVER_LIBRARIES)
set(Wayland_Server_FOUND TRUE)
else()
set(Wayland_Server_FOUND FALSE)
endif()
mark_as_advanced(WAYLAND_SERVER_INCLUDE_DIRS WAYLAND_SERVER_LIBRARIES)

set(WAYLAND_INCLUDE_DIRS ${WAYLAND_CLIENT_INCLUDE_DIRS} ${WAYLAND_SERVER_INCLUDE_DIRS} ${WAYLAND_EGL_INCLUDE_DIRS}
${WAYLAND_CURSOR_INCLUDE_DIRS})
set(WAYLAND_LIBRARIES ${WAYLAND_CLIENT_LIBRARIES} ${WAYLAND_SERVER_LIBRARIES} ${WAYLAND_EGL_LIBRARIES}
${WAYLAND_CURSOR_LIBRARIES})
mark_as_advanced(WAYLAND_INCLUDE_DIRS WAYLAND_LIBRARIES)

list(REMOVE_DUPLICATES WAYLAND_INCLUDE_DIRS)

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(
Wayland
REQUIRED_VARS WAYLAND_LIBRARIES WAYLAND_INCLUDE_DIRS
HANDLE_COMPONENTS)

foreach(component "Client" "Server" "EGL" "Cursor")
if(NOT TARGET Wayland::${component})
string(TOUPPER ${component} component_u)
if(Wayland_${component}_FOUND)
if(IS_ABSOLUTE "${WAYLAND_${component_u}_LIBRARIES}")
add_library(Wayland::${component} UNKNOWN IMPORTED)
set_target_properties(Wayland::${component} PROPERTIES IMPORTED_LOCATION "${WAYLAND_${component_u}_LIBRARIES}")
else()
add_library(Wayland::${component} INTERFACE IMPORTED)
set_target_properties(Wayland::${component} PROPERTIES IMPORTED_LIBNAME "${WAYLAND_${component_u}_LIBRARIES}")
endif()

set_target_properties(Wayland::${component} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
"${WAYLAND_${component_u}_INCLUDE_DIRS}")

set_target_properties(Wayland::${component} PROPERTIES INTERFACE_COMPILE_OPTIONS "${WAYLAND_COMPILE_FLAGS}")
endif()
endif()
endforeach()
20 changes: 20 additions & 0 deletions cmake/unix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ if (UNIX OR MINGW)
# Is the wx we are using built on gtk2 or 3?
execute_process(COMMAND ${WX_TOOL} --selected_config OUTPUT_VARIABLE WX_GTK_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
string(SUBSTRING "${WX_GTK_VERSION}" "3" "1" GTK_VERSION)
if (NOT NO_WAYLAND)
find_package(PkgConfig)
pkg_check_modules(GTK REQUIRED gtk+-3.0)
# Setup CMake to use GTK+, tell the compiler where to look for headers
# and to the linker where to look for libraries
include_directories(${GTK_INCLUDE_DIRS})
link_directories(${GTK_LIBRARY_DIRS})
# Add other flags to the compiler
add_definitions(${GTK_CFLAGS_OTHER})
endif()
message("-- gtk version is: ${GTK_VERSION}")
endif()
set(wxWidgets_CONFIG_EXECUTABLE "${WX_TOOL}")
Expand Down Expand Up @@ -85,6 +95,10 @@ endif()
find_package(Freetype REQUIRED)
find_package(FTGL REQUIRED)

if(NOT NO_WAYLAND)
find_package(Wayland REQUIRED)
endif()

# Fluidsynth
if (NO_FLUIDSYNTH)
ADD_DEFINITIONS(-DNO_FLUIDSYNTH)
Expand Down Expand Up @@ -158,6 +172,12 @@ add_executable(slade WIN32 MACOSX_BUNDLE
${SLADE_HEADERS}
)

if(NOT NO_WAYLAND)
target_link_libraries(slade ${GTK_LIBRARIES} Wayland::Client)
add_library( wpointer STATIC ../src/MapEditor/UI/wayland-pointer-constraints-unstable-v1.c)
target_link_libraries(slade wpointer)
endif()

target_link_libraries(slade
${ZLIB_LIBRARY}
${BZIP2_LIBRARIES}
Expand Down
Loading