FindGio.cmake 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # * Try to find Gio Once done this will define
  2. #
  3. # GIO_FOUND - system has Gio GIO_INCLUDE_DIRS - the Gio include directory
  4. # GIO_LIBRARIES - the libraries needed to use Gio GIO_DEFINITIONS - Compiler
  5. # switches required for using Gio
  6. # Use pkg-config to get the directories and then use these values in the
  7. # find_path() and find_library() calls
  8. find_package(PkgConfig QUIET)
  9. if(PKG_CONFIG_FOUND)
  10. pkg_check_modules(_GIO gio-2.0 gio-unix-2.0)
  11. endif()
  12. find_path(
  13. GIO_INCLUDE_DIR
  14. NAMES gio.h
  15. HINTS ${_GIO_INCLUDE_DIRS}
  16. PATHS /usr/include /usr/local/include /opt/local/include /sw/include
  17. PATH_SUFFIXES glib-2.0/gio/)
  18. find_library(
  19. GIO_LIB
  20. NAMES gio-2.0 libgio-2.0 gio-unix-2.0
  21. HINTS ${_GIO_LIBRARY_DIRS}
  22. PATHS /usr/lib /usr/local/lib /opt/local/lib /sw/lib)
  23. include(FindPackageHandleStandardArgs)
  24. find_package_handle_standard_args(Gio REQUIRED_VARS GIO_LIB GIO_INCLUDE_DIR)
  25. mark_as_advanced(GIO_INCLUDE_DIR GIO_LIB)
  26. if(GIO_FOUND)
  27. set(GIO_INCLUDE_DIRS ${GIO_INCLUDE_DIR})
  28. set(GIO_LIBRARIES ${GIO_LIB})
  29. if(NOT TARGET GIO::GIO)
  30. if(IS_ABSOLUTE "${GIO_LIBRARIES}")
  31. add_library(GIO::GIO UNKNOWN IMPORTED)
  32. set_target_properties(GIO::GIO PROPERTIES IMPORTED_LOCATION
  33. "${GIO_LIBRARIES}")
  34. else()
  35. add_library(GIO::GIO INTERFACE IMPORTED)
  36. set_target_properties(GIO::GIO PROPERTIES IMPORTED_LIBNAME
  37. "${GIO_LIBRARIES}")
  38. endif()
  39. # Special case for gio, as both the
  40. set_target_properties(GIO::GIO PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
  41. "${_GIO_INCLUDE_DIRS}")
  42. target_compile_options(GIO::GIO INTERFACE ${_GIO_CFLAGS})
  43. endif()
  44. endif()