FindXkbcommon.cmake 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #[=======================================================================[.rst
  2. FindXkbcommon
  3. -------------
  4. FindModule for xkbcommon and associated libraries
  5. .. versionchanged:: 3.0
  6. Updated FindModule to CMake standards
  7. Imported Targets
  8. ^^^^^^^^^^^^^^^^
  9. .. versionadded:: 2.0
  10. This module defines the :prop_tgt:`IMPORTED` target ``xkbcommon::xkbcommon``.
  11. Result Variables
  12. ^^^^^^^^^^^^^^^^
  13. This module sets the following variables:
  14. ``Xkbcommon_FOUND``
  15. True, if all required components and the core library were found.
  16. ``Xkbcommon_VERSION``
  17. Detected version of found xkbcommon libraries.
  18. Cache variables
  19. ^^^^^^^^^^^^^^^
  20. The following cache variables may also be set:
  21. ``Xkbcommon_LIBRARY``
  22. Path to the library component of xkbcommon.
  23. ``Xkbcommon_INCLUDE_DIR``
  24. Directory containing ``xkbcommon.h``.
  25. #]=======================================================================]
  26. include(FindPackageHandleStandardArgs)
  27. find_package(PkgConfig QUIET)
  28. if(PKG_CONFIG_FOUND)
  29. pkg_search_module(PC_Xkbcommon QUIET xkbcommon)
  30. endif()
  31. find_path(
  32. Xkbcommon_INCLUDE_DIR
  33. NAMES xkbcommon/xkbcommon.h
  34. HINTS ${PC_Xkbcommon_INCLUDE_DIRS}
  35. PATHS /usr/include /usr/local/include
  36. PATH_SUFFIXES xkbcommon
  37. DOC "xkbcommon include directory"
  38. )
  39. find_library(
  40. Xkbcommon_LIBRARY
  41. NAMES xkbcommon libxkbcommon
  42. HINTS ${PC_Xkbcommon_LIBRARY_DIRS}
  43. PATHS /usr/lib /usr/local/lib
  44. DOC "xkbcommon location"
  45. )
  46. if(PC_Xkbcommon_VERSION VERSION_GREATER 0)
  47. set(Xkbcommon_VERSION ${PC_Xkbcommon_VERSION})
  48. else()
  49. if(NOT Xkbcommon_FIND_QUIETLY)
  50. message(AUTHOR_WARNING "Failed to find xkbcommon version.")
  51. endif()
  52. set(Xkbcommon_VERSION 0.0.0)
  53. endif()
  54. find_package_handle_standard_args(
  55. Xkbcommon
  56. REQUIRED_VARS Xkbcommon_LIBRARY Xkbcommon_INCLUDE_DIR
  57. VERSION_VAR Xkbcommon_VERSION
  58. REASON_FAILURE_MESSAGE "Ensure that xkbcommon is installed on the system."
  59. )
  60. mark_as_advanced(Xkbcommon_INCLUDE_DIR Xkbcommon_LIBRARY)
  61. if(Xkbcommon_FOUND)
  62. if(NOT TARGET xkbcommon::xkbcommon)
  63. if(IS_ABSOLUTE "${Xkbcommon_LIBRARY}")
  64. add_library(xkbcommon::xkbcommon UNKNOWN IMPORTED)
  65. set_property(TARGET xkbcommon::xkbcommon PROPERTY IMPORTED_LOCATION "${Xkbcommon_LIBRARY}")
  66. else()
  67. add_library(xkbcommon::xkbcommon INTERFACE IMPORTED)
  68. set_property(TARGET xkbcommon::xkbcommon PROPERTY IMPORTED_LIBNAME "${Xkbcommon_LIBRARY}")
  69. endif()
  70. set_target_properties(
  71. xkbcommon::xkbcommon
  72. PROPERTIES
  73. INTERFACE_COMPILE_OPTIONS "${PC_Xkbcommon_CFLAGS_OTHER}"
  74. INTERFACE_INCLUDE_DIRECTORIES "${Xkbcommon_INCLUDE_DIR}"
  75. VERSION ${Xkbcommon_VERSION}
  76. )
  77. endif()
  78. endif()
  79. include(FeatureSummary)
  80. set_package_properties(
  81. Xkbcommon
  82. PROPERTIES
  83. URL "https://www.xkbcommon.org"
  84. DESCRIPTION
  85. "A library for handling of keyboard descriptions, including loading them from disk, parsing them and handling their state."
  86. )