| 1 |
# Try to find xkbcommon on a Unix system |
| 2 |
# |
| 3 |
# This will define: |
| 4 |
# |
| 5 |
# XKB_FOUND - True if XKB is available |
| 6 |
# XKB_LIBRARIES - Link these to use XKB |
| 7 |
# XKB_INCLUDE_DIRS - Include directory for XKB |
| 8 |
# XKB_DEFINITIONS - Compiler flags for using XKB |
| 9 |
# |
| 10 |
# Additionally, the following imported targets will be defined: |
| 11 |
# |
| 12 |
# XKB::XKB |
| 13 |
# |
| 14 |
# Copyright (c) 2014 Martin Gräßlin <[email protected]> |
| 15 |
# |
| 16 |
# Redistribution and use in source and binary forms, with or without |
| 17 |
# modification, are permitted provided that the following conditions |
| 18 |
# are met: |
| 19 |
# 1. Redistributions of source code must retain the above copyright |
| 20 |
# notice, this list of conditions and the following disclaimer. |
| 21 |
# 2. Redistributions in binary form must reproduce the above copyright |
| 22 |
# notice, this list of conditions and the following disclaimer in the |
| 23 |
# documentation and/or other materials provided with the distribution. |
| 24 |
# 3. Neither the name of the University nor the names of its contributors |
| 25 |
# may be used to endorse or promote products derived from this software |
| 26 |
# without specific prior written permission. |
| 27 |
# |
| 28 |
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
| 29 |
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 30 |
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 31 |
# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 32 |
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 33 |
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 34 |
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 35 |
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 36 |
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 37 |
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 38 |
# SUCH DAMAGE. |
| 39 |
|
| 40 |
if(CMAKE_VERSION VERSION_LESS 2.8.12) |
| 41 |
message(FATAL_ERROR "CMake 2.8.12 is required by FindXKB.cmake") |
| 42 |
endif() |
| 43 |
if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.12) |
| 44 |
message(AUTHOR_WARNING "Your project should require at least CMake 2.8.12 to use FindXKB.cmake") |
| 45 |
endif() |
| 46 |
|
| 47 |
if(NOT WIN32) |
| 48 |
# Use pkg-config to get the directories and then use these values |
| 49 |
# in the FIND_PATH() and FIND_LIBRARY() calls |
| 50 |
find_package(PkgConfig QUIET) |
| 51 |
pkg_check_modules(PKG_XKB QUIET xkbcommon) |
| 52 |
|
| 53 |
set(XKB_DEFINITIONS ${PKG_XKB_CFLAGS_OTHER}) |
| 54 |
|
| 55 |
find_path(XKB_INCLUDE_DIR |
| 56 |
NAMES |
| 57 |
xkbcommon/xkbcommon.h |
| 58 |
HINTS |
| 59 |
${PKG_XKB_INCLUDE_DIRS} |
| 60 |
) |
| 61 |
find_library(XKB_LIBRARY |
| 62 |
NAMES |
| 63 |
xkbcommon |
| 64 |
HINTS |
| 65 |
${PKG_XKB_LIBRARY_DIRS} |
| 66 |
) |
| 67 |
|
| 68 |
set(XKB_LIBRARIES ${XKB_LIBRARY}) |
| 69 |
set(XKB_INCLUDE_DIRS ${XKB_INCLUDE_DIR}) |
| 70 |
set(XKB_VERSION ${PKG_XKB_VERSION}) |
| 71 |
|
| 72 |
include(FindPackageHandleStandardArgs) |
| 73 |
find_package_handle_standard_args(XKB |
| 74 |
FOUND_VAR |
| 75 |
XKB_FOUND |
| 76 |
REQUIRED_VARS |
| 77 |
XKB_LIBRARY |
| 78 |
XKB_INCLUDE_DIR |
| 79 |
VERSION_VAR |
| 80 |
XKB_VERSION |
| 81 |
) |
| 82 |
|
| 83 |
if(XKB_FOUND AND NOT TARGET XKB::XKB) |
| 84 |
add_library(XKB::XKB UNKNOWN IMPORTED) |
| 85 |
set_target_properties(XKB::XKB PROPERTIES |
| 86 |
IMPORTED_LOCATION "${XKB_LIBRARY}" |
| 87 |
INTERFACE_COMPILE_OPTIONS "${XKB_DEFINITIONS}" |
| 88 |
INTERFACE_INCLUDE_DIRECTORIES "${XKB_INCLUDE_DIR}" |
| 89 |
) |
| 90 |
endif() |
| 91 |
|
| 92 |
else() |
| 93 |
message(STATUS "FindXKB.cmake cannot find XKB on Windows systems.") |
| 94 |
set(XKB_FOUND FALSE) |
| 95 |
endif() |
| 96 |
|
| 97 |
include(FeatureSummary) |
| 98 |
set_package_properties(XKB PROPERTIES |
| 99 |
URL "http://xkbcommon.org" |
| 100 |
DESCRIPTION "XKB API common to servers and clients." |
| 101 |
) |