FindWayland.cmake 3.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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_DIR - 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_DIR WAYLAND_CLIENT_LIBRARIES
  13. # WAYLAND_SERVER_FOUND WAYLAND_SERVER_INCLUDE_DIR WAYLAND_SERVER_LIBRARIES
  14. # WAYLAND_EGL_FOUND WAYLAND_EGL_INCLUDE_DIR WAYLAND_EGL_LIBRARIES
  15. # WAYLAND_CURSOR_FOUND WAYLAND_CURSOR_INCLUDE_DIR WAYLAND_CURSOR_LIBRARIES
  16. #
  17. # Copyright (c) 2013 Martin Gräßlin <mgraesslin@kde.org>
  18. #
  19. # Redistribution and use is allowed according to the terms of the BSD license.
  20. # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
  21. IF (NOT WIN32)
  22. IF (WAYLAND_INCLUDE_DIR AND WAYLAND_LIBRARIES)
  23. # In the cache already
  24. SET(WAYLAND_FIND_QUIETLY TRUE)
  25. ENDIF ()
  26. # Use pkg-config to get the directories and then use these values
  27. # in the FIND_PATH() and FIND_LIBRARY() calls
  28. FIND_PACKAGE(PkgConfig)
  29. PKG_CHECK_MODULES(PKG_WAYLAND QUIET wayland-client wayland-server wayland-egl wayland-cursor)
  30. SET(WAYLAND_DEFINITIONS ${PKG_WAYLAND_CFLAGS})
  31. FIND_PATH(WAYLAND_CLIENT_INCLUDE_DIR NAMES wayland-client.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS})
  32. FIND_PATH(WAYLAND_SERVER_INCLUDE_DIR NAMES wayland-server.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS})
  33. FIND_PATH(WAYLAND_EGL_INCLUDE_DIR NAMES wayland-egl.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS})
  34. FIND_PATH(WAYLAND_CURSOR_INCLUDE_DIR NAMES wayland-cursor.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS})
  35. FIND_LIBRARY(WAYLAND_CLIENT_LIBRARIES NAMES wayland-client HINTS ${PKG_WAYLAND_LIBRARY_DIRS})
  36. FIND_LIBRARY(WAYLAND_SERVER_LIBRARIES NAMES wayland-server HINTS ${PKG_WAYLAND_LIBRARY_DIRS})
  37. FIND_LIBRARY(WAYLAND_EGL_LIBRARIES NAMES wayland-egl HINTS ${PKG_WAYLAND_LIBRARY_DIRS})
  38. FIND_LIBRARY(WAYLAND_CURSOR_LIBRARIES NAMES wayland-cursor HINTS ${PKG_WAYLAND_LIBRARY_DIRS})
  39. set(WAYLAND_INCLUDE_DIR ${WAYLAND_CLIENT_INCLUDE_DIR} ${WAYLAND_SERVER_INCLUDE_DIR} ${WAYLAND_EGL_INCLUDE_DIR} ${WAYLAND_CURSOR_INCLUDE_DIR})
  40. set(WAYLAND_LIBRARIES ${WAYLAND_CLIENT_LIBRARIES} ${WAYLAND_SERVER_LIBRARIES} ${WAYLAND_EGL_LIBRARIES} ${WAYLAND_CURSOR_LIBRARIES})
  41. list(REMOVE_DUPLICATES WAYLAND_INCLUDE_DIR)
  42. include(FindPackageHandleStandardArgs)
  43. FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_CLIENT DEFAULT_MSG WAYLAND_CLIENT_LIBRARIES WAYLAND_CLIENT_INCLUDE_DIR)
  44. FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_SERVER DEFAULT_MSG WAYLAND_SERVER_LIBRARIES WAYLAND_SERVER_INCLUDE_DIR)
  45. FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_EGL DEFAULT_MSG WAYLAND_EGL_LIBRARIES WAYLAND_EGL_INCLUDE_DIR)
  46. FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_CURSOR DEFAULT_MSG WAYLAND_CURSOR_LIBRARIES WAYLAND_CURSOR_INCLUDE_DIR)
  47. FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND DEFAULT_MSG WAYLAND_LIBRARIES WAYLAND_INCLUDE_DIR)
  48. MARK_AS_ADVANCED(
  49. WAYLAND_INCLUDE_DIR WAYLAND_LIBRARIES
  50. WAYLAND_CLIENT_INCLUDE_DIR WAYLAND_CLIENT_LIBRARIES
  51. WAYLAND_SERVER_INCLUDE_DIR WAYLAND_SERVER_LIBRARIES
  52. WAYLAND_EGL_INCLUDE_DIR WAYLAND_EGL_LIBRARIES
  53. WAYLAND_CURSOR_INCLUDE_DIR WAYLAND_CURSOR_LIBRARIES
  54. )
  55. ENDIF ()