1# Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2# file Copyright.txt or https://cmake.org/licensing for details. 3 4#[=======================================================================[.rst: 5FindLibinput 6------------ 7 8.. versionadded:: 3.14 9 10Find libinput headers and library. 11 12Imported Targets 13^^^^^^^^^^^^^^^^ 14 15``Libinput::Libinput`` 16 The libinput library, if found. 17 18Result Variables 19^^^^^^^^^^^^^^^^ 20 21This will define the following variables in your project: 22 23``Libinput_FOUND`` 24 true if (the requested version of) libinput is available. 25``Libinput_VERSION`` 26 the version of libinput. 27``Libinput_LIBRARIES`` 28 the libraries to link against to use libinput. 29``Libinput_INCLUDE_DIRS`` 30 where to find the libinput headers. 31``Libinput_COMPILE_OPTIONS`` 32 this should be passed to target_compile_options(), if the 33 target is not used for linking 34 35#]=======================================================================] 36 37 38# Use pkg-config to get the directories and then use these values 39# in the FIND_PATH() and FIND_LIBRARY() calls 40find_package(PkgConfig QUIET) 41pkg_check_modules(PKG_Libinput QUIET libinput) 42 43set(Libinput_COMPILE_OPTIONS ${PKG_Libinput_CFLAGS_OTHER}) 44set(Libinput_VERSION ${PKG_Libinput_VERSION}) 45 46find_path(Libinput_INCLUDE_DIR 47 NAMES 48 libinput.h 49 HINTS 50 ${PKG_Libinput_INCLUDE_DIRS} 51) 52find_library(Libinput_LIBRARY 53 NAMES 54 input 55 HINTS 56 ${PKG_Libinput_LIBRARY_DIRS} 57) 58 59include(FindPackageHandleStandardArgs) 60find_package_handle_standard_args(Libinput 61 FOUND_VAR 62 Libinput_FOUND 63 REQUIRED_VARS 64 Libinput_LIBRARY 65 Libinput_INCLUDE_DIR 66 VERSION_VAR 67 Libinput_VERSION 68) 69 70if(Libinput_FOUND AND NOT TARGET Libinput::Libinput) 71 add_library(Libinput::Libinput UNKNOWN IMPORTED) 72 set_target_properties(Libinput::Libinput PROPERTIES 73 IMPORTED_LOCATION "${Libinput_LIBRARY}" 74 INTERFACE_COMPILE_OPTIONS "${Libinput_COMPILE_OPTIONS}" 75 INTERFACE_INCLUDE_DIRECTORIES "${Libinput_INCLUDE_DIR}" 76 ) 77endif() 78 79mark_as_advanced(Libinput_LIBRARY Libinput_INCLUDE_DIR) 80 81if(Libinput_FOUND) 82 set(Libinput_LIBRARIES ${Libinput_LIBRARY}) 83 set(Libinput_INCLUDE_DIRS ${Libinput_INCLUDE_DIR}) 84endif() 85