FindWayland.cmake 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # Try to find Wayland on a Unix system
  2. #
  3. # This will define:
  4. #
  5. # WAYLAND_FOUND - True if Wayland is found
  6. # WAYLAND_LIBRARIES - Link these to use Wayland
  7. # WAYLAND_INCLUDE_DIRS - Include directory for Wayland
  8. # WAYLAND_DEFINITIONS - Compiler flags for using Wayland
  9. #
  10. # In addition the following more fine grained variables will be defined:
  11. #
  12. # Wayland_Client_FOUND WAYLAND_CLIENT_INCLUDE_DIRS WAYLAND_CLIENT_LIBRARIES
  13. # Wayland_Server_FOUND WAYLAND_SERVER_INCLUDE_DIRS WAYLAND_SERVER_LIBRARIES
  14. # Wayland_EGL_FOUND WAYLAND_EGL_INCLUDE_DIRS WAYLAND_EGL_LIBRARIES
  15. # Wayland_Cursor_FOUND WAYLAND_CURSOR_INCLUDE_DIRS WAYLAND_CURSOR_LIBRARIES
  16. #
  17. # Copyright (c) 2013 Martin Gräßlin <[email protected]>
  18. # 2020 Georges Basile Stavracas Neto <[email protected]>
  19. #
  20. # Redistribution and use is allowed according to the terms of the BSD license.
  21. # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
  22. IF (NOT WIN32)
  23. # Use pkg-config to get the directories and then use these values
  24. # in the find_path() and find_library() calls
  25. find_package(PkgConfig)
  26. PKG_CHECK_MODULES(PKG_WAYLAND QUIET wayland-client wayland-server wayland-egl wayland-cursor)
  27. set(WAYLAND_DEFINITIONS ${PKG_WAYLAND_CFLAGS})
  28. find_path(WAYLAND_CLIENT_INCLUDE_DIRS NAMES wayland-client.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS})
  29. find_library(WAYLAND_CLIENT_LIBRARIES NAMES wayland-client HINTS ${PKG_WAYLAND_LIBRARY_DIRS})
  30. if(WAYLAND_CLIENT_INCLUDE_DIRS AND WAYLAND_CLIENT_LIBRARIES)
  31. set(Wayland_Client_FOUND TRUE)
  32. else()
  33. set(Wayland_Client_FOUND FALSE)
  34. endif()
  35. mark_as_advanced(WAYLAND_CLIENT_INCLUDE_DIRS WAYLAND_CLIENT_LIBRARIES)
  36. find_path(WAYLAND_CURSOR_INCLUDE_DIRS NAMES wayland-cursor.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS})
  37. find_library(WAYLAND_CURSOR_LIBRARIES NAMES wayland-cursor HINTS ${PKG_WAYLAND_LIBRARY_DIRS})
  38. if(WAYLAND_CURSOR_INCLUDE_DIRS AND WAYLAND_CURSOR_LIBRARIES)
  39. set(Wayland_Cursor_FOUND TRUE)
  40. else()
  41. set(Wayland_Cursor_FOUND FALSE)
  42. endif()
  43. mark_as_advanced(WAYLAND_CURSOR_INCLUDE_DIRS WAYLAND_CURSOR_LIBRARIES)
  44. find_path(WAYLAND_EGL_INCLUDE_DIRS NAMES wayland-egl.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS})
  45. find_library(WAYLAND_EGL_LIBRARIES NAMES wayland-egl HINTS ${PKG_WAYLAND_LIBRARY_DIRS})
  46. if(WAYLAND_EGL_INCLUDE_DIRS AND WAYLAND_EGL_LIBRARIES)
  47. set(Wayland_EGL_FOUND TRUE)
  48. else()
  49. set(Wayland_EGL_FOUND FALSE)
  50. endif()
  51. mark_as_advanced(WAYLAND_EGL_INCLUDE_DIRS WAYLAND_EGL_LIBRARIES)
  52. find_path(WAYLAND_SERVER_INCLUDE_DIRS NAMES wayland-server.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS})
  53. find_library(WAYLAND_SERVER_LIBRARIES NAMES wayland-server HINTS ${PKG_WAYLAND_LIBRARY_DIRS})
  54. if(WAYLAND_SERVER_INCLUDE_DIRS AND WAYLAND_SERVER_LIBRARIES)
  55. set(Wayland_Server_FOUND TRUE)
  56. else()
  57. set(Wayland_Server_FOUND FALSE)
  58. endif()
  59. mark_as_advanced(WAYLAND_SERVER_INCLUDE_DIRS WAYLAND_SERVER_LIBRARIES)
  60. set(WAYLAND_INCLUDE_DIRS ${WAYLAND_CLIENT_INCLUDE_DIRS} ${WAYLAND_SERVER_INCLUDE_DIRS} ${WAYLAND_EGL_INCLUDE_DIRS} ${WAYLAND_CURSOR_INCLUDE_DIRS})
  61. set(WAYLAND_LIBRARIES ${WAYLAND_CLIENT_LIBRARIES} ${WAYLAND_SERVER_LIBRARIES} ${WAYLAND_EGL_LIBRARIES} ${WAYLAND_CURSOR_LIBRARIES})
  62. mark_as_advanced(WAYLAND_INCLUDE_DIRS WAYLAND_LIBRARIES)
  63. list(REMOVE_DUPLICATES WAYLAND_INCLUDE_DIRS)
  64. include(FindPackageHandleStandardArgs)
  65. find_package_handle_standard_args(Wayland REQUIRED_VARS WAYLAND_LIBRARIES WAYLAND_INCLUDE_DIRS HANDLE_COMPONENTS)
  66. ENDIF ()