FindGio.cmake 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. #[=======================================================================[.rst
  2. FindGio
  3. -------
  4. FindModule for gio 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 ``gio::gio``.
  11. Result Variables
  12. ^^^^^^^^^^^^^^^^
  13. This module sets the following variables:
  14. ``Gio_FOUND``
  15. True, if all required components and the core library were found.
  16. ``Gio_VERSION``
  17. Detected version of found gio libraries.
  18. Cache variables
  19. ^^^^^^^^^^^^^^^
  20. The following cache variables may also be set:
  21. ``Gio_LIBRARY``
  22. Path to the library component of gio.
  23. ``Gio_INCLUDE_DIR``
  24. Directory containing ``gio.h``
  25. #]=======================================================================]
  26. include(FindPackageHandleStandardArgs)
  27. find_package(PkgConfig QUIET)
  28. if(PKG_CONFIG_FOUND)
  29. pkg_search_module(PC_Gio QUIET gio-2.0 gio)
  30. pkg_search_module(PC_GioUnix QUIET gio-unix-2.0)
  31. endif()
  32. find_path(
  33. Gio_INCLUDE_DIR
  34. NAMES gio/gio.h
  35. HINTS ${PC_Gio_INCLUDE_DIRS}
  36. PATHS /usr/include /usr/local/include
  37. PATH_SUFFIXES glib-2.0
  38. DOC "gio-2.0 include directory"
  39. )
  40. find_path(
  41. GioUnix_INCLUDE_DIR
  42. NAMES gio/gunixfdmessage.h
  43. HINTS ${PC_GioUnix_INCLUDE_DIRS}
  44. PATHS /usr/include /usr/local/include
  45. PATH_SUFFIXES gio-unix-2.0
  46. DOC "gio-unix-2.0 include directory"
  47. )
  48. find_library(
  49. Gio_LIBRARY
  50. NAMES libgio-2.0 gio-2.0 gio-unix-2.0
  51. HINTS ${PC_Gio_LIBRARY_DIRS}
  52. PATHS /usr/lib /usr/local/lib
  53. DOC "gio-2.0 location"
  54. )
  55. find_path(
  56. Glib_INCLUDE_DIR
  57. NAMES glibconfig.h
  58. HINTS ${PC_Gio_INCLUDE_DIRS}
  59. PATHS /usr/lib /usr/local/lib
  60. PATH_SUFFIXES glib-2.0/include
  61. )
  62. if(PC_Gio_VERSION VERSION_GREATER 0)
  63. set(Gio_VERSION ${PC_Gio_VERSION})
  64. else()
  65. if(NOT Gio_FIND_QUIETLY)
  66. message(AUTHOR_WARNING "Failed to find gio version.")
  67. endif()
  68. set(Gio_VERSION 0.0.0)
  69. endif()
  70. find_package_handle_standard_args(
  71. Gio
  72. REQUIRED_VARS Gio_LIBRARY Gio_INCLUDE_DIR GioUnix_INCLUDE_DIR Glib_INCLUDE_DIR
  73. VERSION_VAR Gio_VERSION
  74. REASON_FAILURE_MESSAGE "Ensure that glib is installed on the system."
  75. )
  76. mark_as_advanced(Gio_INCLUDE_DIR Gio_LIBRARY Glib_INCLUDE_DIR)
  77. if(Gio_FOUND)
  78. if(NOT TARGET gio::gio)
  79. if(IS_ABSOLUTE "${Gio_LIBRARY}")
  80. add_library(gio::gio UNKNOWN IMPORTED)
  81. set_property(TARGET gio::gio PROPERTY IMPORTED_LOCATION "${Gio_LIBRARY}")
  82. else()
  83. add_library(gio::gio INTERFACE IMPORTED)
  84. set_property(TARGET gio::gio PROPERTY IMPORTED_LIBNAME "${Gio_LIBRARY}")
  85. endif()
  86. set_target_properties(
  87. gio::gio
  88. PROPERTIES
  89. INTERFACE_COMPILE_OPTIONS "${PC_Gio_CFLAGS_OTHER}"
  90. INTERFACE_INCLUDE_DIRECTORIES "${Gio_INCLUDE_DIR};${GioUnix_INCLUDE_DIR};${Glib_INCLUDE_DIR}"
  91. VERSION ${Gio_VERSION}
  92. )
  93. endif()
  94. endif()
  95. include(FeatureSummary)
  96. set_package_properties(
  97. Gio
  98. PROPERTIES
  99. URL "https://docs.gtk.org/gio"
  100. DESCRIPTION
  101. "A library providing useful classes for general purpose I/O, networking, IPC, settings, and other high level application functionality."
  102. )