diff options
author | Wolfgang Schupp <w.schupp@a1.net> | 2018-01-05 12:58:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-05 12:58:58 +0100 |
commit | 88710f25037eb786058228f3b4541d99336d60a2 (patch) | |
tree | 4458349ed96058a4b39269adb950f87434adbd17 /cmake | |
parent | c262275e6707c7da48e69f4cdee58e0cc133c303 (diff) | |
parent | 0a1219eeb99466fe295824d5a42329ddf55976d0 (diff) |
Merge pull request #13096 from pkerling/wayland-fixes
Wayland fixes
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/modules/FindWaylandProtocols.cmake | 24 | ||||
-rw-r--r-- | cmake/modules/FindWaylandpp.cmake | 69 | ||||
-rw-r--r-- | cmake/modules/FindXkbcommon.cmake | 24 | ||||
-rw-r--r-- | cmake/platform/freebsd/wayland.cmake | 18 | ||||
-rw-r--r-- | cmake/platform/linux/wayland.cmake | 2 | ||||
-rw-r--r-- | cmake/scripts/common/Macros.cmake | 90 |
6 files changed, 116 insertions, 111 deletions
diff --git a/cmake/modules/FindWaylandProtocols.cmake b/cmake/modules/FindWaylandProtocols.cmake new file mode 100644 index 0000000000..0b96ff04ec --- /dev/null +++ b/cmake/modules/FindWaylandProtocols.cmake @@ -0,0 +1,24 @@ +# FindWaylandProtocols +# -------------------- +# Find wayland-protocols +# +# This will will define the following variables:: +# +# WAYLAND_PROTOCOLS_DIR - directory containing the additional Wayland protocols +# from the wayland-protocols package + +pkg_check_modules(PC_WAYLAND_PROTOCOLS wayland-protocols) +if(PC_WAYLAND_PROTOCOLS_FOUND) + pkg_get_variable(WAYLAND_PROTOCOLS_DIR wayland-protocols pkgdatadir) +endif() + +# Promote to cache variables so all code can access it +set(WAYLAND_PROTOCOLS_DIR ${WAYLAND_PROTOCOLS_DIR} CACHE INTERNAL "") + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(WaylandProtocols + REQUIRED_VARS + PC_WAYLAND_PROTOCOLS_FOUND + WAYLAND_PROTOCOLS_DIR + VERSION_VAR + PC_WAYLAND_PROTOCOLS_VERSION) diff --git a/cmake/modules/FindWaylandpp.cmake b/cmake/modules/FindWaylandpp.cmake index 8a1cd74f46..9393a124dd 100644 --- a/cmake/modules/FindWaylandpp.cmake +++ b/cmake/modules/FindWaylandpp.cmake @@ -1,64 +1,33 @@ # FindWaylandpp -# ----------- +# ------------- # Finds the waylandpp library # # This will will define the following variables:: # -# WAYLANDPP_FOUND - the system has Wayland -# WAYLANDPP_INCLUDE_DIRS - the Wayland include directory -# WAYLANDPP_LIBRARIES - the Wayland libraries -# WAYLANDPP_DEFINITIONS - the Wayland definitions - - -if(PKG_CONFIG_FOUND) - pkg_check_modules(PC_WAYLANDPP wayland-client++>=0.1 wayland-egl++ wayland-cursor++ wayland-scanner++ QUIET) - pkg_check_modules(PC_WAYLAND_PROTOCOLS wayland-protocols>=1.7 QUIET) - # TODO: Remove check when CMake minimum version is bumped globally - if(CMAKE_VERSION VERSION_EQUAL 3.4.0 OR CMAKE_VERSION VERSION_GREATER 3.4.0) - if(PC_WAYLANDPP_FOUND) - pkg_get_variable(PC_WAYLANDPP_SCANNER wayland-scanner++ wayland_scannerpp) - endif() - if(PC_WAYLAND_PROTOCOLS_FOUND) - pkg_get_variable(PC_WAYLAND_PROTOCOLS_DIR wayland-protocols pkgdatadir) - endif() - endif() +# WAYLANDPP_FOUND - the system has waylandpp +# WAYLANDPP_INCLUDE_DIRS - the waylandpp include directory +# WAYLANDPP_LIBRARIES - the waylandpp libraries +# WAYLANDPP_DEFINITIONS - the waylandpp definitions +# WAYLANDPP_SCANNER - path to wayland-scanner++ + +pkg_check_modules(WAYLANDPP wayland-client++ wayland-egl++ wayland-cursor++) +pkg_check_modules(PC_WAYLANDPP_SCANNER wayland-scanner++) +if(PC_WAYLANDPP_SCANNER_FOUND) + pkg_get_variable(PC_WAYLANDPP_SCANNER wayland-scanner++ wayland_scannerpp) endif() -find_path(WAYLANDPP_INCLUDE_DIR NAMES wayland-client.hpp - PATHS ${PC_WAYLANDPP_INCLUDE_DIRS}) - -find_library(WAYLANDPP_CLIENT_LIBRARY NAMES wayland-client++ - PATHS ${PC_WAYLANDPP_LIBRARIES} ${PC_WAYLANDPP_LIBRARY_DIRS}) - -find_library(WAYLANDPP_CURSOR_LIBRARY NAMES wayland-cursor++ - PATHS ${PC_WAYLANDPP_LIBRARIES} ${PC_WAYLANDPP_LIBRARY_DIRS}) - -find_library(WAYLANDPP_EGL_LIBRARY NAMES wayland-egl++ - PATHS ${PC_WAYLANDPP_LIBRARIES} ${PC_WAYLANDPP_LIBRARY_DIRS}) - -find_program(WAYLANDPP_SCANNER NAMES wayland-scanner++ - PATHS ${PC_WAYLANDPP_SCANNER}) - -find_path(WAYLAND_PROTOCOLS_DIR NAMES unstable/xdg-shell/xdg-shell-unstable-v6.xml - PATHS ${PC_WAYLAND_PROTOCOLS_DIR} - DOC "Directory containing additional Wayland protocols") +# wayland-scanner++ is from native/host system in case of cross-compilation, so +# it's ok if we don't find it with pkgconfig +find_program(WAYLANDPP_SCANNER wayland-scanner++ PATHS ${PC_WAYLANDPP_SCANNER}) include (FindPackageHandleStandardArgs) find_package_handle_standard_args (Waylandpp REQUIRED_VARS - WAYLANDPP_INCLUDE_DIR - WAYLANDPP_CLIENT_LIBRARY - WAYLANDPP_CURSOR_LIBRARY - WAYLANDPP_EGL_LIBRARY + WAYLANDPP_FOUND WAYLANDPP_SCANNER - WAYLAND_PROTOCOLS_DIR VERSION_VAR - PC_WAYLANDPP_wayland-client++_VERSION) - -if (WAYLANDPP_FOUND) - set(WAYLANDPP_LIBRARIES ${WAYLANDPP_CLIENT_LIBRARY} ${WAYLANDPP_CURSOR_LIBRARY} ${WAYLANDPP_EGL_LIBRARY}) - set(WAYLANDPP_INCLUDE_DIRS ${PC_WAYLANDPP_INCLUDE_DIRS}) - set(WAYLANDPP_DEFINITIONS -DHAVE_WAYLAND=1) -endif() + WAYLANDPP_wayland-client++_VERSION) -mark_as_advanced (WAYLANDPP_CLIENT_LIBRARY WAYLANDPP_CURSOR_LIBRARY WAYLANDPP_EGL_LIBRARY WAYLANDPP_INCLUDE_DIR) +set(WAYLANDPP_DEFINITIONS -DHAVE_WAYLAND=1) +# Also pass on library directories +set(WAYLANDPP_LIBRARIES ${WAYLANDPP_LDFLAGS}) diff --git a/cmake/modules/FindXkbcommon.cmake b/cmake/modules/FindXkbcommon.cmake index 619b39d52e..2a84fe59f6 100644 --- a/cmake/modules/FindXkbcommon.cmake +++ b/cmake/modules/FindXkbcommon.cmake @@ -9,27 +9,13 @@ # XKBCOMMON_LIBRARIES - the libxkbcommon libraries # XKBCOMMON_DEFINITIONS - the libxkbcommon definitions - -if(PKG_CONFIG_FOUND) - pkg_check_modules (PC_XKBCOMMON xkbcommon QUIET) -endif() - -find_path(XKBCOMMON_INCLUDE_DIR NAMES xkbcommon/xkbcommon.h - PATHS ${PC_XKBCOMMON_INCLUDE_DIRS}) - -find_library(XKBCOMMON_LIBRARY NAMES xkbcommon - PATHS ${PC_XKBCOMMON_LIBRARIES} ${PC_XKBCOMMON_LIBRARY_DIRS}) +pkg_check_modules (XKBCOMMON xkbcommon) include (FindPackageHandleStandardArgs) find_package_handle_standard_args (Xkbcommon REQUIRED_VARS - XKBCOMMON_INCLUDE_DIR - XKBCOMMON_LIBRARY) - -if (XKBCOMMON_FOUND) - set(XKBCOMMON_LIBRARIES ${XKBCOMMON_LIBRARY}) - set(XKBCOMMON_INCLUDE_DIRS ${PC_XKBCOMMON_INCLUDE_DIRS}) - set(XKBCOMMON_DEFINITIONS -DHAVE_XKBCOMMON=1) -endif() + XKBCOMMON_FOUND) -mark_as_advanced (XKBCOMMON_LIBRARY XKBCOMMON_INCLUDE_DIR)
\ No newline at end of file +set(XKBCOMMON_DEFINITIONS -DHAVE_XKBCOMMON=1) +set(XKBCOMMON_LIBRARIES ${XKBCOMMON_LDFLAGS}) +set(XKBCOMMON_INCLUDE_DIRS ${XKBCOMMON_INCLUDEDIR}) diff --git a/cmake/platform/freebsd/wayland.cmake b/cmake/platform/freebsd/wayland.cmake index 55fbd8a940..f6361aa189 100644 --- a/cmake/platform/freebsd/wayland.cmake +++ b/cmake/platform/freebsd/wayland.cmake @@ -1,17 +1 @@ -set(PLATFORM_REQUIRED_DEPS EGL Waylandpp LibDRM Xkbcommon) -set(PLATFORM_OPTIONAL_DEPS VAAPI) - -set(WAYLAND_RENDER_SYSTEM "" CACHE STRING "Render system to use with Wayland: \"gl\" or \"gles\"") - -if(WAYLAND_RENDER_SYSTEM STREQUAL "gl") - list(APPEND PLATFORM_REQUIRED_DEPS OpenGl) -elseif(WAYLAND_RENDER_SYSTEM STREQUAL "gles") - list(APPEND PLATFORM_REQUIRED_DEPS OpenGLES) -else() - message(SEND_ERROR "You need to decide whether you want to use GL- or GLES-based rendering in combination with the Wayland windowing system. Please set WAYLAND_RENDER_SYSTEM to either \"gl\" or \"gles\". For normal desktop systems, you will usually want to use \"gl\".") -endif() - -set(PLATFORM_GLOBAL_TARGET_DEPS generate-wayland-extra-protocols) -set(WAYLAND_EXTRA_PROTOCOL_GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}") -# for wayland-extra-protocols.hpp -include_directories("${WAYLAND_EXTRA_PROTOCOL_GENERATED_DIR}") +include(../linux/wayland.cmake) diff --git a/cmake/platform/linux/wayland.cmake b/cmake/platform/linux/wayland.cmake index 1a7e219989..e4728238d5 100644 --- a/cmake/platform/linux/wayland.cmake +++ b/cmake/platform/linux/wayland.cmake @@ -1,4 +1,4 @@ -set(PLATFORM_REQUIRED_DEPS EGL Waylandpp LibDRM Xkbcommon) +set(PLATFORM_REQUIRED_DEPS EGL WaylandProtocols>=1.7 Waylandpp>=0.1.5 LibDRM Xkbcommon>=0.4.1) set(PLATFORM_OPTIONAL_DEPS VAAPI) set(WAYLAND_RENDER_SYSTEM "" CACHE STRING "Render system to use with Wayland: \"gl\" or \"gles\"") diff --git a/cmake/scripts/common/Macros.cmake b/cmake/scripts/common/Macros.cmake index d508f87f33..c0d421cdb9 100644 --- a/cmake/scripts/common/Macros.cmake +++ b/cmake/scripts/common/Macros.cmake @@ -338,15 +338,54 @@ macro(export_dep) mark_as_advanced(${depup}_LIBRARIES) endmacro() -# add a required dependency of main application +# split dependency specification to name and version # Arguments: -# dep_list name of find rule for dependency, used uppercased for variable prefix -# also accepts a list of multiple dependencies +# depspec dependency specification that can optionally include a required +# package version +# syntax: [package name], [package name]>=[version] (minimum version), +# or [package name]=[version] (exact version) +# name_outvar variable that should receive the package name +# version_outvar variable that should receive the package version part (>=[version]) # On return: -# dependency added to ${SYSTEM_INCLUDES}, ${DEPLIBS} and ${DEP_DEFINES} +# ${name_outvar} and ${version_outvar} in caller scope are set to respective values. +# ${version_outvar} may be unset if there is no specific version requested. +function(split_dependency_specification depspec name_outvar version_outvar) + if(${depspec} MATCHES "^([^>]*)(>?=[0-9.]+)$") + set(${name_outvar} ${CMAKE_MATCH_1} PARENT_SCOPE) + set(${version_outvar} ${CMAKE_MATCH_2} PARENT_SCOPE) + else() + set(${name_outvar} ${depspec} PARENT_SCOPE) + unset(${version_outvar} PARENT_SCOPE) + endif() +endfunction() + +# helper macro to split version info from req and call find_package +macro(find_package_with_ver package) + set(_find_arguments "${ARGN}") + if("${ARGV1}" MATCHES "^(>)?=([0-9.]+)$") + # We have a version spec, parse it + list(REMOVE_AT _find_arguments 0) + # ">" not present? -> exact match + if(NOT CMAKE_MATCH_1) + list(INSERT _find_arguments 0 "EXACT") + endif() + find_package(${package} ${CMAKE_MATCH_2} ${_find_arguments}) + else() + find_package(${package} ${_find_arguments}) + endif() + unset(_find_arguments) +endmacro() + +# add required dependencies of main application +# Arguments: +# dep_list One or many dependency specifications (see split_dependency_specification) +# for syntax). The dependency name is used uppercased as variable prefix. +# On return: +# dependencies added to ${SYSTEM_INCLUDES}, ${DEPLIBS} and ${DEP_DEFINES} function(core_require_dep) - foreach(dep ${ARGN}) - find_package(${dep} REQUIRED) + foreach(depspec ${ARGN}) + split_dependency_specification(${depspec} dep version) + find_package_with_ver(${dep} ${version} REQUIRED) string(TOUPPER ${dep} depup) list(APPEND SYSTEM_INCLUDES ${${depup}_INCLUDE_DIRS}) list(APPEND DEPLIBS ${${depup}_LIBRARIES}) @@ -355,15 +394,16 @@ function(core_require_dep) endforeach() endfunction() -# add a required dyloaded dependency of main application +# add required dyloaded dependencies of main application # Arguments: -# dep_list name of find rule for dependency, used uppercased for variable prefix -# also accepts a list of multiple dependencies +# dep_list One or many dependency specifications (see split_dependency_specification) +# for syntax). The dependency name is used uppercased as variable prefix. # On return: # dependency added to ${SYSTEM_INCLUDES}, ${dep}_SONAME is set up function(core_require_dyload_dep) - foreach(dep ${ARGN}) - find_package(${dep} REQUIRED) + foreach(depspec ${ARGN}) + split_dependency_specification(${depspec} dep version) + find_package_with_ver(${dep} ${version} REQUIRED) string(TOUPPER ${dep} depup) list(APPEND SYSTEM_INCLUDES ${${depup}_INCLUDE_DIRS}) list(APPEND DEP_DEFINES ${${depup}_DEFINITIONS}) @@ -385,20 +425,21 @@ macro(setup_enable_switch) set(${enable_switch} "AUTO" CACHE STRING "Enable ${depup} support?") endmacro() -# add an optional dependency of main application +# add optional dependencies of main application # Arguments: -# dep_list name of find rule for dependency, used uppercased for variable prefix -# also accepts a list of multiple dependencies +# dep_list One or many dependency specifications (see split_dependency_specification) +# for syntax). The dependency name is used uppercased as variable prefix. # On return: # dependency optionally added to ${SYSTEM_INCLUDES}, ${DEPLIBS} and ${DEP_DEFINES} function(core_optional_dep) - foreach(dep ${ARGN}) + foreach(depspec ${ARGN}) set(_required False) + split_dependency_specification(${depspec} dep version) setup_enable_switch() if(${enable_switch} STREQUAL AUTO) - find_package(${dep}) + find_package_with_ver(${dep} ${version}) elseif(${${enable_switch}}) - find_package(${dep} REQUIRED) + find_package_with_ver(${dep} ${version} REQUIRED) set(_required True) endif() @@ -417,20 +458,21 @@ function(core_optional_dep) set(final_message ${final_message} PARENT_SCOPE) endfunction() -# add an optional dyloaded dependency of main application +# add optional dyloaded dependencies of main application # Arguments: -# dep_list name of find rule for dependency, used uppercased for variable prefix -# also accepts a list of multiple dependencies +# dep_list One or many dependency specifications (see split_dependency_specification) +# for syntax). The dependency name is used uppercased as variable prefix. # On return: # dependency optionally added to ${SYSTEM_INCLUDES}, ${DEP_DEFINES}, ${dep}_SONAME is set up function(core_optional_dyload_dep) - foreach(dep ${ARGN}) + foreach(depspec ${ARGN}) set(_required False) - setup_enable_switch() + split_dependency_specification(${depspec} dep version) + setup_enable_switch() if(${enable_switch} STREQUAL AUTO) - find_package(${dep}) + find_package_with_ver(${dep} ${version}) elseif(${${enable_switch}}) - find_package(${dep} REQUIRED) + find_package_with_ver(${dep} ${version} REQUIRED) set(_required True) endif() |