Merge pull request #23092 from webosbrew/feature/webOS
[xbmc.git] / cmake / modules / FindWaylandpp.cmake
blob06ed683e8a1959acd68a567f91ed392b51df6f26
1 # FindWaylandpp
2 # -------------
3 # Finds the waylandpp library
5 # This will define the following variables::
7 # WAYLANDPP_FOUND        - the system has waylandpp
8 # WAYLANDPP_INCLUDE_DIRS - the waylandpp include directory
9 # WAYLANDPP_LIBRARIES    - the waylandpp libraries
10 # WAYLANDPP_DEFINITIONS  - the waylandpp definitions
11 # WAYLANDPP_SCANNER      - path to wayland-scanner++
13 pkg_check_modules(PC_WAYLANDPP wayland-client++ wayland-egl++ wayland-cursor++ QUIET)
15 if(PC_WAYLANDPP_FOUND)
16   pkg_get_variable(PC_WAYLANDPP_PKGDATADIR wayland-client++ pkgdatadir)
17 else()
18   message(SEND_ERROR "wayland-client++ not found via pkg-config")
19 endif()
21 pkg_check_modules(PC_WAYLANDPP_SCANNER wayland-scanner++ QUIET)
23 if(PC_WAYLANDPP_SCANNER_FOUND)
24   pkg_get_variable(PC_WAYLANDPP_SCANNER wayland-scanner++ wayland_scannerpp)
25 else()
26   message(SEND_ERROR "wayland-scanner++ not found via pkg-config")
27 endif()
29 find_path(WAYLANDPP_INCLUDE_DIR wayland-client.hpp PATHS ${PC_WAYLANDPP_INCLUDEDIR})
31 find_library(WAYLANDPP_CLIENT_LIBRARY NAMES wayland-client++
32                                       PATHS ${PC_WAYLANDPP_LIBRARY_DIRS})
34 find_library(WAYLANDPP_CURSOR_LIBRARY NAMES wayland-cursor++
35                                       PATHS ${PC_WAYLANDPP_LIBRARY_DIRS})
37 find_library(WAYLANDPP_EGL_LIBRARY NAMES wayland-egl++
38                                    PATHS ${PC_WAYLANDPP_LIBRARY_DIRS})
40 if(KODI_DEPENDSBUILD)
41   pkg_check_modules(PC_WAYLANDC wayland-client wayland-egl wayland-cursor QUIET)
43   if(PREFER_TOOLCHAIN_PATH)
44     set(WAYLAND_SEARCH_PATH ${PREFER_TOOLCHAIN_PATH}
45                             NO_DEFAULT_PATH
46                             PATH_SUFFIXES usr/lib)
47   else()
48     set(WAYLAND_SEARCH_PATH ${PC_WAYLANDC_LIBRARY_DIRS})
49   endif()
51   find_library(WAYLANDC_CLIENT_LIBRARY NAMES wayland-client
52                                        PATHS ${WAYLAND_SEARCH_PATH}
53                                        REQUIRED)
54   find_library(WAYLANDC_CURSOR_LIBRARY NAMES wayland-cursor
55                                        PATHS ${WAYLAND_SEARCH_PATH}
56                                        REQUIRED)
57   find_library(WAYLANDC_EGL_LIBRARY NAMES wayland-egl
58                                     PATHS ${WAYLAND_SEARCH_PATH}
59                                     REQUIRED)
61   set(WAYLANDPP_STATIC_DEPS ${WAYLANDC_CLIENT_LIBRARY}
62                             ${WAYLANDC_CURSOR_LIBRARY}
63                             ${WAYLANDC_EGL_LIBRARY})
64 endif()
66 # Promote to cache variables so all code can access it
67 set(WAYLANDPP_PROTOCOLS_DIR "${PC_WAYLANDPP_PKGDATADIR}/protocols" CACHE INTERNAL "")
69 # wayland-scanner++ is from native/host system in case of cross-compilation, so
70 # it's ok if we don't find it with pkgconfig
71 find_program(WAYLANDPP_SCANNER wayland-scanner++ PATHS ${PC_WAYLANDPP_SCANNER})
73 include (FindPackageHandleStandardArgs)
74 find_package_handle_standard_args(Waylandpp
75                                   REQUIRED_VARS WAYLANDPP_INCLUDE_DIR
76                                                 WAYLANDPP_CLIENT_LIBRARY
77                                                 WAYLANDPP_CURSOR_LIBRARY
78                                                 WAYLANDPP_EGL_LIBRARY
79                                                 WAYLANDPP_SCANNER
80                                   VERSION_VAR WAYLANDPP_wayland-client++_VERSION)
82 if(WAYLANDPP_FOUND)
83   set(WAYLANDPP_INCLUDE_DIRS ${WAYLANDPP_INCLUDE_DIR})
84   set(WAYLANDPP_LIBRARIES ${WAYLANDPP_CLIENT_LIBRARY}
85                           ${WAYLANDPP_CURSOR_LIBRARY}
86                           ${WAYLANDPP_EGL_LIBRARY}
87                           ${WAYLANDPP_STATIC_DEPS})
88   set(WAYLANDPP_DEFINITIONS -DHAVE_WAYLAND=1)
89 endif()
91 mark_as_advanced(WAYLANDPP_INCLUDE_DIR
92                  WAYLANDPP_CLIENT_LIBRARY
93                  WAYLANDC_CLIENT_LIBRARY
94                  WAYLANDPP_CURSOR_LIBRARY
95                  WAYLANDC_CURSOR_LIBRARY
96                  WAYLANDPP_EGL_LIBRARY
97                  WAYLANDC_EGL_LIBRARY
98                  WAYLANDPP_SCANNER)