| 1 |
#.rst: |
| 2 |
# FindX11_XCB |
| 3 |
# ----------- |
| 4 |
# |
| 5 |
# Try to find the X11 XCB compatibility library. |
| 6 |
# |
| 7 |
# This will define the following variables: |
| 8 |
# |
| 9 |
# ``X11_XCB_FOUND`` |
| 10 |
# True if (the requested version of) libX11-xcb is available |
| 11 |
# ``X11_XCB_VERSION`` |
| 12 |
# The version of libX11-xcb (this is not guaranteed to be set even when |
| 13 |
# X11_XCB_FOUND is true) |
| 14 |
# ``X11_XCB_LIBRARIES`` |
| 15 |
# This can be passed to target_link_libraries() instead of the ``EGL::EGL`` |
| 16 |
# target |
| 17 |
# ``X11_XCB_INCLUDE_DIR`` |
| 18 |
# This should be passed to target_include_directories() if the target is not |
| 19 |
# used for linking |
| 20 |
# ``X11_XCB_DEFINITIONS`` |
| 21 |
# This should be passed to target_compile_options() if the target is not |
| 22 |
# used for linking |
| 23 |
# |
| 24 |
# If ``X11_XCB_FOUND`` is TRUE, it will also define the following imported |
| 25 |
# target: |
| 26 |
# |
| 27 |
# ``X11::XCB`` |
| 28 |
# The X11 XCB compatibility library |
| 29 |
# |
| 30 |
# In general we recommend using the imported target, as it is easier to use. |
| 31 |
# Bear in mind, however, that if the target is in the link interface of an |
| 32 |
# exported library, it must be made available by the package config file. |
| 33 |
# |
| 34 |
# Since pre-1.0.0. |
| 35 |
|
| 36 |
#============================================================================= |
| 37 |
# Copyright 2014 Alex Merry <[email protected]> |
| 38 |
# Copyright 2011 Fredrik Höglund <[email protected]> |
| 39 |
# Copyright 2008 Helio Chissini de Castro <[email protected]> |
| 40 |
# Copyright 2007 Matthias Kretz <[email protected]> |
| 41 |
# |
| 42 |
# Redistribution and use in source and binary forms, with or without |
| 43 |
# modification, are permitted provided that the following conditions |
| 44 |
# are met: |
| 45 |
# |
| 46 |
# 1. Redistributions of source code must retain the copyright |
| 47 |
# notice, this list of conditions and the following disclaimer. |
| 48 |
# 2. Redistributions in binary form must reproduce the copyright |
| 49 |
# notice, this list of conditions and the following disclaimer in the |
| 50 |
# documentation and/or other materials provided with the distribution. |
| 51 |
# 3. The name of the author may not be used to endorse or promote products |
| 52 |
# derived from this software without specific prior written permission. |
| 53 |
# |
| 54 |
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 55 |
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 56 |
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 57 |
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 58 |
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 59 |
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 60 |
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 61 |
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 62 |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 63 |
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 64 |
#============================================================================= |
| 65 |
|
| 66 |
include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake) |
| 67 |
|
| 68 |
ecm_find_package_version_check(X11_XCB) |
| 69 |
|
| 70 |
# use pkg-config to get the directories and then use these values |
| 71 |
# in the FIND_PATH() and FIND_LIBRARY() calls |
| 72 |
find_package(PkgConfig QUIET) |
| 73 |
pkg_check_modules(PKG_X11_XCB QUIET x11-xcb) |
| 74 |
|
| 75 |
set(X11_XCB_DEFINITIONS ${PKG_X11_XCB_CFLAGS_OTHER}) |
| 76 |
set(X11_XCB_VERSION ${PKG_X11_XCB_VERSION}) |
| 77 |
|
| 78 |
find_path(X11_XCB_INCLUDE_DIR |
| 79 |
NAMES X11/Xlib-xcb.h |
| 80 |
HINTS ${PKG_X11_XCB_INCLUDE_DIRS} |
| 81 |
) |
| 82 |
find_library(X11_XCB_LIBRARY |
| 83 |
NAMES X11-xcb |
| 84 |
HINTS ${PKG_X11_XCB_LIBRARY_DIRS} |
| 85 |
) |
| 86 |
|
| 87 |
include(FindPackageHandleStandardArgs) |
| 88 |
find_package_handle_standard_args(X11_XCB |
| 89 |
FOUND_VAR |
| 90 |
X11_XCB_FOUND |
| 91 |
REQUIRED_VARS |
| 92 |
X11_XCB_LIBRARY |
| 93 |
X11_XCB_INCLUDE_DIR |
| 94 |
VERSION_VAR |
| 95 |
X11_XCB_VERSION |
| 96 |
) |
| 97 |
|
| 98 |
if(X11_XCB_FOUND AND NOT TARGET X11::XCB) |
| 99 |
add_library(X11::XCB UNKNOWN IMPORTED) |
| 100 |
set_target_properties(X11::XCB PROPERTIES |
| 101 |
IMPORTED_LOCATION "${X11_XCB_LIBRARY}" |
| 102 |
INTERFACE_COMPILE_OPTIONS "${X11_XCB_DEFINITIONS}" |
| 103 |
INTERFACE_INCLUDE_DIRECTORIES "${X11_XCB_INCLUDE_DIR}" |
| 104 |
) |
| 105 |
endif() |
| 106 |
|
| 107 |
mark_as_advanced(X11_XCB_INCLUDE_DIR X11_XCB_LIBRARY) |
| 108 |
|
| 109 |
# compatibility variables |
| 110 |
set(X11_XCB_LIBRARIES ${X11_XCB_LIBRARY}) |
| 111 |
set(X11_XCB_INCLUDE_DIRS ${X11_XCB_INCLUDE_DIR}) |
| 112 |
set(X11_XCB_VERSION_STRING ${X11_XCB_VERSION}) |
| 113 |
|
| 114 |
include(FeatureSummary) |
| 115 |
set_package_properties(X11_XCB PROPERTIES |
| 116 |
URL "http://xorg.freedesktop.org/" |
| 117 |
DESCRIPTION "A compatibility library for code that translates Xlib API calls into XCB calls" |
| 118 |
) |