From 9f270005181ae0fe31cc26f02ec790a32d3ffe1c Mon Sep 17 00:00:00 2001 From: Bernhard Miklautz Date: Sun, 18 Jan 2015 22:23:50 +0100 Subject: [PATCH] build: improve wayland detection * add support to check wayland client version * set minimum required version to 0.95 --- cmake/FindWayland.cmake | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/cmake/FindWayland.cmake b/cmake/FindWayland.cmake index 131544465..36c384c6e 100644 --- a/cmake/FindWayland.cmake +++ b/cmake/FindWayland.cmake @@ -8,10 +8,12 @@ # # WAYLAND_INCLUDE_DIR - where to find wayland-client.h, etc. # WAYLAND_LIBRARY - the Wayland client library +# WAYLAND_VERSION - wayland client version if found and pkg-config was used # #============================================================================= # Copyright 2014 Manuel Bachmann +# Copyright 2015 Bernhard Miklautz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -26,21 +28,38 @@ # limitations under the License. #============================================================================= +set(REQUIRED_WAYLAND_CLIENT_VERSION 0.95) +include(FindPkgConfig) + +if(PKG_CONFIG_FOUND) + pkg_check_modules(WAYLAND wayland-client) +endif() + find_path(WAYLAND_INCLUDE_DIR NAMES wayland-client.h + PATHS ${WAYLAND_INCLUDE_DIRS} DOC "The Wayland include directory" ) find_library(WAYLAND_LIBRARY NAMES wayland-client + PATHS ${WAYLAND_LIBRARY_DIRS} DOC "The Wayland client library" ) include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND DEFAULT_MSG WAYLAND_LIBRARY WAYLAND_INCLUDE_DIR) -if(WAYLAND_FOUND) - set( WAYLAND_LIBRARIES ${WAYLAND_LIBRARY} ) - set( WAYLAND_INCLUDE_DIRS ${WAYLAND_INCLUDE_DIR} ) +if(WAYLAND_VERSION) + if (${WAYLAND_VERSION} VERSION_LESS ${REQUIRED_WAYLAND_CLIENT_VERSION}) + message(WARNING "Installed wayland version ${WAYLAND_VERSION} is too old - minimum required version ${REQUIRED_WAYLAND_CLIENT_VERSION}") + set(WAYLAND_FOUND FALSE) + endif() +else() + message(WARNING "Couldn't detect wayland version - no version check is done") endif() -mark_as_advanced(WAYLAND_INCLUDE_DIR WAYLAND_LIBRARY) +if(WAYLAND_FOUND) + set(WAYLAND_LIBRARIES ${WAYLAND_LIBRARY}) + set(WAYLAND_INCLUDE_DIRS ${WAYLAND_INCLUDE_DIR}) +endif() +mark_as_advanced(WAYLAND_INCLUDE_DIR WAYLAND_LIBRARY WAYLAND_VERSION)