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