aboutsummaryrefslogtreecommitdiff
path: root/CMake/FindLibInput.cmake
blob: 8772199813233f5d0eb239a3db9e34f17d934f17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#.rst:
# FindLibInput
# -------
#
# Find LibInput library
#
# Try to find LibInpu library. The following values are defined
#
# ::
#
#   LIBINPUT_FOUND         - True if libinput is available
#   LIBINPUT_INCLUDE_DIRS  - Include directories for libinput
#   LIBINPUT_LIBRARIES     - List of libraries for libinput
#   LIBINPUT_DEFINITIONS   - List of definitions for libinput
#
# and also the following more fine grained variables
#
# ::
#
#   LIBINPUT_VERSION
#   LIBINPUT_VERSION_MAJOR
#   LIBINPUT_VERSION_MINOR
#   LIBINPUT_VERSION_MICRO
#
#=============================================================================
# Copyright (c) 2015 Jari Vetoniemi
#
# Distributed under the OSI-approved BSD License (the "License");
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================

include(FeatureSummary)
set_package_properties(LibInput PROPERTIES
   URL "http://freedesktop.org/wiki/Software/libinput/"
   DESCRIPTION "Library to handle input devices")

find_package(PkgConfig)
pkg_check_modules(PC_INPUT QUIET libinput)
find_library(LIBINPUT_LIBRARIES NAMES input HINTS ${PC_INPUT_LIBRARY_DIRS})
find_path(LIBINPUT_INCLUDE_DIRS libinput.h HINTS ${PC_INPUT_INCLUDE_DIRS})

set(LIBINPUT_VERSION ${PC_INPUT_VERSION})
string(REPLACE "." ";" VERSION_LIST "${PC_INPUT_VERSION}")

LIST(LENGTH VERSION_LIST n)
if (n EQUAL 3)
   list(GET VERSION_LIST 0 LIBINPUT_VERSION_MAJOR)
   list(GET VERSION_LIST 1 LIBINPUT_VERSION_MINOR)
   list(GET VERSION_LIST 2 LIBINPUT_VERSION_MICRO)
endif ()

# This is compatible with libinput-version.h that exists in upstream
# but isn't in distribution (probably forgotten)
set(LIBINPUT_DEFINITIONS ${PC_INPUT_CFLAGS_OTHER}
   -DLIBINPUT_VERSION=\"${LIBINPUT_VERSION}\"
   -DLIBINPUT_VERSION_MAJOR=${LIBINPUT_VERSION_MAJOR}
   -DLIBINPUT_VERSION_MINOR=${LIBINPUT_VERSION_MINOR}
   -DLIBINPUT_VERSION_MICRO=${LIBINPUT_VERSION_MICRO})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LIBINPUT DEFAULT_MSG LIBINPUT_INCLUDE_DIRS LIBINPUT_LIBRARIES)
mark_as_advanced(LIBINPUT_INCLUDE_DIRS LIBINPUT_LIBRARIES LIBINPUT_DEFINITIONS
   LIBINPUT_VERSION LIBINPUT_VERSION_MAJOR LIBINPUT_VERSION_MICRO LIBINPUT_VERSION_MINOR)