| 1 |
#.rst: |
| 2 |
# FindWayland |
| 3 |
# ----------- |
| 4 |
# |
| 5 |
# Try to find Wayland. |
| 6 |
# |
| 7 |
# This is a component-based find module, which makes use of the COMPONENTS |
| 8 |
# and OPTIONAL_COMPONENTS arguments to find_module. The following components |
| 9 |
# are available:: |
| 10 |
# |
| 11 |
# Client Server Cursor Egl |
| 12 |
# |
| 13 |
# If no components are specified, this module will act as though all components |
| 14 |
# were passed to OPTIONAL_COMPONENTS. |
| 15 |
# |
| 16 |
# This module will define the following variables, independently of the |
| 17 |
# components searched for or found: |
| 18 |
# |
| 19 |
# ``Wayland_FOUND`` |
| 20 |
# TRUE if (the requested version of) Wayland is available |
| 21 |
# ``Wayland_VERSION`` |
| 22 |
# Found Wayland version |
| 23 |
# ``Wayland_TARGETS`` |
| 24 |
# A list of all targets imported by this module (note that there may be more |
| 25 |
# than the components that were requested) |
| 26 |
# ``Wayland_LIBRARIES`` |
| 27 |
# This can be passed to target_link_libraries() instead of the imported |
| 28 |
# targets |
| 29 |
# ``Wayland_INCLUDE_DIRS`` |
| 30 |
# This should be passed to target_include_directories() if the targets are |
| 31 |
# not used for linking |
| 32 |
# ``Wayland_DEFINITIONS`` |
| 33 |
# This should be passed to target_compile_options() if the targets are not |
| 34 |
# used for linking |
| 35 |
# |
| 36 |
# For each searched-for components, ``Wayland_<component>_FOUND`` will be set to |
| 37 |
# TRUE if the corresponding Wayland library was found, and FALSE otherwise. If |
| 38 |
# ``Wayland_<component>_FOUND`` is TRUE, the imported target |
| 39 |
# ``Wayland::<component>`` will be defined. This module will also attempt to |
| 40 |
# determine ``Wayland_*_VERSION`` variables for each imported target, although |
| 41 |
# ``Wayland_VERSION`` should normally be sufficient. |
| 42 |
# |
| 43 |
# In general we recommend using the imported targets, as they are easier to use |
| 44 |
# and provide more control. Bear in mind, however, that if any target is in the |
| 45 |
# link interface of an exported library, it must be made available by the |
| 46 |
# package config file. |
| 47 |
# |
| 48 |
# Since pre-1.0.0. |
| 49 |
|
| 50 |
#============================================================================= |
| 51 |
# Copyright 2014 Alex Merry <[email protected]> |
| 52 |
# Copyright 2014 Martin Gräßlin <[email protected]> |
| 53 |
# |
| 54 |
# Redistribution and use in source and binary forms, with or without |
| 55 |
# modification, are permitted provided that the following conditions |
| 56 |
# are met: |
| 57 |
# |
| 58 |
# 1. Redistributions of source code must retain the copyright |
| 59 |
# notice, this list of conditions and the following disclaimer. |
| 60 |
# 2. Redistributions in binary form must reproduce the copyright |
| 61 |
# notice, this list of conditions and the following disclaimer in the |
| 62 |
# documentation and/or other materials provided with the distribution. |
| 63 |
# 3. The name of the author may not be used to endorse or promote products |
| 64 |
# derived from this software without specific prior written permission. |
| 65 |
# |
| 66 |
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 67 |
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 68 |
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 69 |
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 70 |
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 71 |
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 72 |
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 73 |
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 74 |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 75 |
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 76 |
#============================================================================= |
| 77 |
|
| 78 |
include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake) |
| 79 |
|
| 80 |
ecm_find_package_version_check(Wayland) |
| 81 |
|
| 82 |
set(Wayland_known_components |
| 83 |
Client |
| 84 |
Server |
| 85 |
Cursor |
| 86 |
Egl |
| 87 |
) |
| 88 |
foreach(_comp ${Wayland_known_components}) |
| 89 |
string(TOLOWER "${_comp}" _lc_comp) |
| 90 |
set(Wayland_${_comp}_component_deps) |
| 91 |
set(Wayland_${_comp}_pkg_config "wayland-${_lc_comp}") |
| 92 |
set(Wayland_${_comp}_lib "wayland-${_lc_comp}") |
| 93 |
set(Wayland_${_comp}_header "wayland-${_lc_comp}.h") |
| 94 |
endforeach() |
| 95 |
set(Wayland_Egl_component_deps Client) |
| 96 |
|
| 97 |
ecm_find_package_parse_components(Wayland |
| 98 |
RESULT_VAR Wayland_components |
| 99 |
KNOWN_COMPONENTS ${Wayland_known_components} |
| 100 |
) |
| 101 |
ecm_find_package_handle_library_components(Wayland |
| 102 |
COMPONENTS ${Wayland_components} |
| 103 |
) |
| 104 |
|
| 105 |
# If pkg-config didn't provide us with version information, |
| 106 |
# try to extract it from wayland-version.h |
| 107 |
# (Note that the version from wayland-egl.pc will probably be |
| 108 |
# the Mesa version, rather than the Wayland version, but that |
| 109 |
# version will be ignored as we always find wayland-client.pc |
| 110 |
# first). |
| 111 |
if(NOT Wayland_VERSION) |
| 112 |
find_file(Wayland_VERSION_HEADER |
| 113 |
NAMES wayland-version.h |
| 114 |
HINTS ${Wayland_INCLUDE_DIRS} |
| 115 |
) |
| 116 |
mark_as_advanced(Wayland_VERSION_HEADER) |
| 117 |
if(Wayland_VERSION_HEADER) |
| 118 |
file(READ ${Wayland_VERSION_HEADER} _wayland_version_header_contents) |
| 119 |
string(REGEX REPLACE |
| 120 |
"^.*[ \t]+WAYLAND_VERSION[ \t]+\"([0-9.]*)\".*$" |
| 121 |
"\\1" |
| 122 |
Wayland_VERSION |
| 123 |
"${_wayland_version_header_contents}" |
| 124 |
) |
| 125 |
unset(_wayland_version_header_contents) |
| 126 |
endif() |
| 127 |
endif() |
| 128 |
|
| 129 |
find_package_handle_standard_args(Wayland |
| 130 |
FOUND_VAR |
| 131 |
Wayland_FOUND |
| 132 |
REQUIRED_VARS |
| 133 |
Wayland_LIBRARIES |
| 134 |
VERSION_VAR |
| 135 |
Wayland_VERSION |
| 136 |
HANDLE_COMPONENTS |
| 137 |
) |
| 138 |
|
| 139 |
include(FeatureSummary) |
| 140 |
set_package_properties(Wayland PROPERTIES |
| 141 |
URL "http://wayland.freedesktop.org" |
| 142 |
DESCRIPTION "C library implementation of the Wayland protocol: a protocol for a compositor to talk to its clients" |
| 143 |
) |