Warning, /frameworks/extra-cmake-modules/find-modules/FindWayland.cmake is written in an unsupported language. File is not indexed.
0001 # SPDX-FileCopyrightText: 2014 Alex Merry <alex.merry@kde.org> 0002 # SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org> 0003 # 0004 # SPDX-License-Identifier: BSD-3-Clause 0005 0006 #[=======================================================================[.rst: 0007 FindWayland 0008 ----------- 0009 0010 Try to find Wayland. 0011 0012 This is a component-based find module, which makes use of the COMPONENTS 0013 and OPTIONAL_COMPONENTS arguments to find_module. The following components 0014 are available:: 0015 0016 Client Server Cursor Egl 0017 0018 If no components are specified, this module will act as though all components 0019 were passed to OPTIONAL_COMPONENTS. 0020 0021 This module will define the following variables, independently of the 0022 components searched for or found: 0023 0024 ``Wayland_FOUND`` 0025 TRUE if (the requested version of) Wayland is available 0026 ``Wayland_VERSION`` 0027 Found Wayland version 0028 ``Wayland_TARGETS`` 0029 A list of all targets imported by this module (note that there may be more 0030 than the components that were requested) 0031 ``Wayland_LIBRARIES`` 0032 This can be passed to target_link_libraries() instead of the imported 0033 targets 0034 ``Wayland_INCLUDE_DIRS`` 0035 This should be passed to target_include_directories() if the targets are 0036 not used for linking 0037 ``Wayland_DEFINITIONS`` 0038 This should be passed to target_compile_options() if the targets are not 0039 used for linking 0040 ``Wayland_DATADIR`` 0041 The core wayland protocols data directory 0042 Since 5.73.0 0043 0044 For each searched-for components, ``Wayland_<component>_FOUND`` will be set to 0045 TRUE if the corresponding Wayland library was found, and FALSE otherwise. If 0046 ``Wayland_<component>_FOUND`` is TRUE, the imported target 0047 ``Wayland::<component>`` will be defined. This module will also attempt to 0048 determine ``Wayland_*_VERSION`` variables for each imported target, although 0049 ``Wayland_VERSION`` should normally be sufficient. 0050 0051 In general we recommend using the imported targets, as they are easier to use 0052 and provide more control. Bear in mind, however, that if any target is in the 0053 link interface of an exported library, it must be made available by the 0054 package config file. 0055 0056 Since pre-1.0.0. 0057 #]=======================================================================] 0058 0059 include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake) 0060 0061 ecm_find_package_version_check(Wayland) 0062 0063 set(Wayland_known_components 0064 Client 0065 Server 0066 Cursor 0067 Egl 0068 ) 0069 foreach(_comp ${Wayland_known_components}) 0070 string(TOLOWER "${_comp}" _lc_comp) 0071 set(Wayland_${_comp}_component_deps) 0072 set(Wayland_${_comp}_pkg_config "wayland-${_lc_comp}") 0073 set(Wayland_${_comp}_lib "wayland-${_lc_comp}") 0074 set(Wayland_${_comp}_header "wayland-${_lc_comp}.h") 0075 endforeach() 0076 set(Wayland_Egl_component_deps Client) 0077 0078 ecm_find_package_parse_components(Wayland 0079 RESULT_VAR Wayland_components 0080 KNOWN_COMPONENTS ${Wayland_known_components} 0081 ) 0082 ecm_find_package_handle_library_components(Wayland 0083 COMPONENTS ${Wayland_components} 0084 ) 0085 0086 # If pkg-config didn't provide us with version information, 0087 # try to extract it from wayland-version.h 0088 # (Note that the version from wayland-egl.pc will probably be 0089 # the Mesa version, rather than the Wayland version, but that 0090 # version will be ignored as we always find wayland-client.pc 0091 # first). 0092 if(NOT Wayland_VERSION) 0093 find_file(Wayland_VERSION_HEADER 0094 NAMES wayland-version.h 0095 HINTS ${Wayland_INCLUDE_DIRS} 0096 ) 0097 mark_as_advanced(Wayland_VERSION_HEADER) 0098 if(Wayland_VERSION_HEADER) 0099 file(READ ${Wayland_VERSION_HEADER} _wayland_version_header_contents) 0100 string(REGEX REPLACE 0101 "^.*[ \t]+WAYLAND_VERSION[ \t]+\"([0-9.]*)\".*$" 0102 "\\1" 0103 Wayland_VERSION 0104 "${_wayland_version_header_contents}" 0105 ) 0106 unset(_wayland_version_header_contents) 0107 endif() 0108 endif() 0109 0110 find_package_handle_standard_args(Wayland 0111 FOUND_VAR 0112 Wayland_FOUND 0113 REQUIRED_VARS 0114 Wayland_LIBRARIES 0115 VERSION_VAR 0116 Wayland_VERSION 0117 HANDLE_COMPONENTS 0118 ) 0119 0120 pkg_get_variable(Wayland_DATADIR wayland-scanner pkgdatadir) 0121 if (CMAKE_CROSSCOMPILING AND (NOT EXISTS "${Wayland_DATADIR}/wayland.xml")) 0122 # PKG_CONFIG_SYSROOT_DIR only applies to -I and -L flags, so pkg-config 0123 # does not prepend CMAKE_SYSROOT when cross-compiling unless you pass 0124 # --define-prefix explicitly. Therefore we have to manually do prepend 0125 # it here when cross-compiling. 0126 # See https://gitlab.kitware.com/cmake/cmake/-/issues/16647#note_844761 0127 set(Wayland_DATADIR ${CMAKE_SYSROOT}${Wayland_DATADIR}) 0128 endif() 0129 if (NOT EXISTS "${Wayland_DATADIR}/wayland.xml") 0130 message(WARNING "Could not find wayland.xml in ${Wayland_DATADIR}") 0131 endif() 0132 0133 include(FeatureSummary) 0134 set_package_properties(Wayland PROPERTIES 0135 URL "https://wayland.freedesktop.org/" 0136 DESCRIPTION "C library implementation of the Wayland protocol: a protocol for a compositor to talk to its clients" 0137 )