| 1 |
#.rst: |
| 2 |
# FindLibinput |
| 3 |
# ------- |
| 4 |
# |
| 5 |
# Try to find libinput on a Unix system. |
| 6 |
# |
| 7 |
# This will define the following variables: |
| 8 |
# |
| 9 |
# ``Libinput_FOUND`` |
| 10 |
# True if (the requested version of) libinput is available |
| 11 |
# ``Libinput_VERSION`` |
| 12 |
# The version of libinput |
| 13 |
# ``Libinput_LIBRARIES`` |
| 14 |
# This can be passed to target_link_libraries() instead of the ``Libinput::Libinput`` |
| 15 |
# target |
| 16 |
# ``Libinput_INCLUDE_DIRS`` |
| 17 |
# This should be passed to target_include_directories() if the target is not |
| 18 |
# used for linking |
| 19 |
# ``Libinput_DEFINITIONS`` |
| 20 |
# This should be passed to target_compile_options() if the target is not |
| 21 |
# used for linking |
| 22 |
# |
| 23 |
# If ``Libinput_FOUND`` is TRUE, it will also define the following imported target: |
| 24 |
# |
| 25 |
# ``Libinput::Libinput`` |
| 26 |
# The libinput library |
| 27 |
# |
| 28 |
# In general we recommend using the imported target, as it is easier to use. |
| 29 |
# Bear in mind, however, that if the target is in the link interface of an |
| 30 |
# exported library, it must be made available by the package config file. |
| 31 |
|
| 32 |
#============================================================================= |
| 33 |
# Copyright 2014 Alex Merry <[email protected]> |
| 34 |
# Copyright 2014 Martin Gräßlin <[email protected]> |
| 35 |
# |
| 36 |
# Redistribution and use in source and binary forms, with or without |
| 37 |
# modification, are permitted provided that the following conditions |
| 38 |
# are met: |
| 39 |
# |
| 40 |
# 1. Redistributions of source code must retain the copyright |
| 41 |
# notice, this list of conditions and the following disclaimer. |
| 42 |
# 2. Redistributions in binary form must reproduce the copyright |
| 43 |
# notice, this list of conditions and the following disclaimer in the |
| 44 |
# documentation and/or other materials provided with the distribution. |
| 45 |
# 3. The name of the author may not be used to endorse or promote products |
| 46 |
# derived from this software without specific prior written permission. |
| 47 |
# |
| 48 |
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 49 |
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 50 |
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 51 |
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 52 |
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 53 |
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 54 |
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 55 |
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 56 |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 57 |
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 58 |
#============================================================================= |
| 59 |
|
| 60 |
if(CMAKE_VERSION VERSION_LESS 2.8.12) |
| 61 |
message(FATAL_ERROR "CMake 2.8.12 is required by FindLibinput.cmake") |
| 62 |
endif() |
| 63 |
if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.12) |
| 64 |
message(AUTHOR_WARNING "Your project should require at least CMake 2.8.12 to use FindLibinput.cmake") |
| 65 |
endif() |
| 66 |
|
| 67 |
if(NOT WIN32) |
| 68 |
# Use pkg-config to get the directories and then use these values |
| 69 |
# in the FIND_PATH() and FIND_LIBRARY() calls |
| 70 |
find_package(PkgConfig QUIET) |
| 71 |
pkg_check_modules(PKG_Libinput QUIET libinput) |
| 72 |
|
| 73 |
set(Libinput_DEFINITIONS ${PKG_Libinput_CFLAGS_OTHER}) |
| 74 |
set(Libinput_VERSION ${PKG_Libinput_VERSION}) |
| 75 |
|
| 76 |
find_path(Libinput_INCLUDE_DIR |
| 77 |
NAMES |
| 78 |
libinput.h |
| 79 |
HINTS |
| 80 |
${PKG_Libinput_INCLUDE_DIRS} |
| 81 |
) |
| 82 |
find_library(Libinput_LIBRARY |
| 83 |
NAMES |
| 84 |
input |
| 85 |
HINTS |
| 86 |
${PKG_Libinput_LIBRARY_DIRS} |
| 87 |
) |
| 88 |
|
| 89 |
include(FindPackageHandleStandardArgs) |
| 90 |
find_package_handle_standard_args(Libinput |
| 91 |
FOUND_VAR |
| 92 |
Libinput_FOUND |
| 93 |
REQUIRED_VARS |
| 94 |
Libinput_LIBRARY |
| 95 |
Libinput_INCLUDE_DIR |
| 96 |
VERSION_VAR |
| 97 |
Libinput_VERSION |
| 98 |
) |
| 99 |
|
| 100 |
if(Libinput_FOUND AND NOT TARGET Libinput::Libinput) |
| 101 |
add_library(Libinput::Libinput UNKNOWN IMPORTED) |
| 102 |
set_target_properties(Libinput::Libinput PROPERTIES |
| 103 |
IMPORTED_LOCATION "${Libinput_LIBRARY}" |
| 104 |
INTERFACE_COMPILE_OPTIONS "${Libinput_DEFINITIONS}" |
| 105 |
INTERFACE_INCLUDE_DIRECTORIES "${Libinput_INCLUDE_DIR}" |
| 106 |
) |
| 107 |
endif() |
| 108 |
|
| 109 |
mark_as_advanced(Libinput_LIBRARY Libinput_INCLUDE_DIR) |
| 110 |
|
| 111 |
# compatibility variables |
| 112 |
set(Libinput_LIBRARIES ${Libinput_LIBRARY}) |
| 113 |
set(Libinput_INCLUDE_DIRS ${Libinput_INCLUDE_DIR}) |
| 114 |
set(Libinput_VERSION_STRING ${Libinput_VERSION}) |
| 115 |
|
| 116 |
else() |
| 117 |
message(STATUS "FindLibinput.cmake cannot find libinput on Windows systems.") |
| 118 |
set(Libinput_FOUND FALSE) |
| 119 |
endif() |
| 120 |
|
| 121 |
include(FeatureSummary) |
| 122 |
set_package_properties(Libinput PROPERTIES |
| 123 |
URL "http://www.freedesktop.org/wiki/Software/libinput/" |
| 124 |
DESCRIPTION "Library to handle input devices in Wayland compositors and to provide a generic X.Org input driver." |
| 125 |
) |