aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorfuzzard <fuzzard@kodi.tv>2024-05-16 17:52:34 +1000
committerfuzzard <fuzzard@kodi.tv>2024-06-22 14:06:06 +1000
commitc0f36e41a5d9584eefabf9e775aed05235d22f44 (patch)
tree94cc6dc56e3bf929562818a7917cc16ea04f9f40 /cmake
parentf369d5887d5d0cd84cd42a2f673c901e0b657ec4 (diff)
[cmake][modules] FindLibInput update to target usage
Diffstat (limited to 'cmake')
-rw-r--r--cmake/modules/FindLibInput.cmake64
1 files changed, 33 insertions, 31 deletions
diff --git a/cmake/modules/FindLibInput.cmake b/cmake/modules/FindLibInput.cmake
index a1530f3a25..0e4681fbf9 100644
--- a/cmake/modules/FindLibInput.cmake
+++ b/cmake/modules/FindLibInput.cmake
@@ -3,36 +3,38 @@
# --------
# Finds the libinput library
#
-# This will define the following variables::
+# This will define the following target:
#
-# LIBINPUT_FOUND - system has libinput
-# LIBINPUT_INCLUDE_DIRS - the libinput include directory
-# LIBINPUT_LIBRARIES - the libinput libraries
-# LIBINPUT_DEFINITIONS - the libinput compile definitions
-#
-
-find_package(PkgConfig)
-
-if(PKG_CONFIG_FOUND)
- pkg_check_modules(PC_LIBINPUT libinput QUIET)
-endif()
-
-find_path(LIBINPUT_INCLUDE_DIR NAMES libinput.h
- HINTS ${PC_LIBINPUT_INCLUDEDIR})
-
-find_library(LIBINPUT_LIBRARY NAMES input
- HINTS ${PC_LIBINPUT_LIBDIR})
-
-set(LIBINPUT_VERSION ${PC_LIBINPUT_VERSION})
-
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(LibInput
- REQUIRED_VARS LIBINPUT_LIBRARY LIBINPUT_INCLUDE_DIR
- VERSION_VAR LIBINPUT_VERSION)
-
-if(LIBINPUT_FOUND)
- set(LIBINPUT_INCLUDE_DIRS ${LIBINPUT_INCLUDE_DIR})
- set(LIBINPUT_LIBRARIES ${LIBINPUT_LIBRARY})
+# ${APP_NAME_LC}::LibInput - The LibInput library
+
+if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME})
+ find_package(PkgConfig)
+
+ if(PKG_CONFIG_FOUND)
+ pkg_check_modules(PC_LIBINPUT libinput QUIET)
+ endif()
+
+ find_path(LIBINPUT_INCLUDE_DIR NAMES libinput.h
+ HINTS ${PC_LIBINPUT_INCLUDEDIR})
+
+ find_library(LIBINPUT_LIBRARY NAMES input
+ HINTS ${PC_LIBINPUT_LIBDIR})
+
+ set(LIBINPUT_VERSION ${PC_LIBINPUT_VERSION})
+
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(LibInput
+ REQUIRED_VARS LIBINPUT_LIBRARY LIBINPUT_INCLUDE_DIR
+ VERSION_VAR LIBINPUT_VERSION)
+
+ if(LIBINPUT_FOUND)
+ add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED)
+ set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES
+ IMPORTED_LOCATION "${LIBINPUT_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${LIBINPUT_INCLUDE_DIR}")
+ else()
+ if(LibInput_FIND_REQUIRED)
+ message(FATAL_ERROR "Libinput libraries were not found.")
+ endif()
+ endif()
endif()
-
-mark_as_advanced(LIBINPUT_INCLUDE_DIR LIBINPUT_LIBRARY)