blob: 21014fc43f7cf4b781251b790ced542a017447b8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
# Try to find Wayland on a Unix system
#
# This will define:
#
# Wayland_FOUND - True if Wayland is available
# Wayland_LIBRARIES - Link these to use Wayland
# Wayland_INCLUDE_DIRS - Include directory for Wayland
# Wayland_DEFINITIONS - Compiler flags for using Wayland
# Wayland_VERSION_STRING - Found Wayland version
#
# In addition the following more fine grained variables will be defined:
#
# Wayland_Client_FOUND Wayland_Client_INCLUDE_DIR Wayland_Client_LIBRARY Wayland_Client_VERSION_STRING
# Wayland_Server_FOUND Wayland_Server_INCLUDE_DIR Wayland_Server_LIBRARY Wayland_Server_VERSION_STRING
# Wayland_Cursor_FOUND Wayland_Cursor_INCLUDE_DIR Wayland_Cursor_LIBRARY Wayland_Cursor_VERSION_STRING
# Wayland_Egl_FOUND Wayland_Egl_INCLUDE_DIR Wayland_Egl_LIBRARY Wayland_Egl_VERSION_STRING
#
# Additionally, the following imported targets will be defined:
#
# Wayland::Client
# Wayland::Server
# Wayland::Cursor
# Wayland::Egl
#
# Copyright (c) 2014 Martin Gräßlin <mgraesslin@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
if(CMAKE_VERSION VERSION_LESS 2.8.12)
message(FATAL_ERROR "CMake 2.8.12 is required by FindWayland.cmake")
endif()
if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.12)
message(AUTHOR_WARNING "Your project should require at least CMake 2.8.12 to use FindWayland.cmake")
endif()
set(knownComponents Client
Server
Cursor
Egl
)
unset(unknownComponents)
set(pkgConfigModules)
if (Wayland_FIND_COMPONENTS)
set(comps ${Wayland_FIND_COMPONENTS})
else()
set(comps ${knownComponents})
endif()
# iterate through the list of requested components, and check that we know them all.
# If not, fail.
foreach(comp ${comps})
list(FIND knownComponents ${comp} index )
if("${index}" STREQUAL "-1")
list(APPEND unknownComponents "${comp}")
else()
if("${comp}" STREQUAL "Client")
list(APPEND pkgConfigModules "wayland-client")
elseif("${comp}" STREQUAL "Server")
list(APPEND pkgConfigModules "wayland-server")
elseif("${comp}" STREQUAL "Cursor")
list(APPEND pkgConfigModules "wayland-cursor")
elseif("${comp}" STREQUAL "Egl")
list(APPEND pkgConfigModules "wayland-egl")
endif()
endif()
endforeach()
if(DEFINED unknownComponents)
set(msgType STATUS)
if(Wayland_FIND_REQUIRED)
set(msgType FATAL_ERROR)
endif()
if(NOT Wayland_FIND_QUIETLY)
message(${msgType} "Wayland: requested unknown components ${unknownComponents}")
endif()
return()
endif()
macro(_wayland_handle_component _comp)
set(_header )
set(_lib )
set(_pkgconfig_module_var)
if("${_comp}" STREQUAL "Client")
set(_header "wayland-client.h")
set(_lib "wayland-client")
set(_pkgconfig_module_var "wayland-client")
elseif("${_comp}" STREQUAL "Server")
set(_header "wayland-server.h")
set(_lib "wayland-server")
set(_pkgconfig_module_var "wayland-server")
elseif("${_comp}" STREQUAL "Cursor")
set(_header "wayland-cursor.h")
set(_lib "wayland-cursor")
set(_pkgconfig_module_var "wayland-cursor")
elseif("${_comp}" STREQUAL "Egl")
set(_header "wayland-egl.h")
set(_lib "wayland-egl")
set(_pkgconfig_module_var "wayland-egl")
endif()
find_path(Wayland_${_comp}_INCLUDE_DIR
NAMES ${_header}
HINTS ${PKG_Wayland_INCLUDE_DIRS}
)
find_library(Wayland_${_comp}_LIBRARY
NAMES ${_lib}
HINTS ${PKG_Wayland_LIBRARY_DIRS}
)
if(Wayland_${_comp}_INCLUDE_DIR AND Wayland_${_comp}_LIBRARY)
list(APPEND Wayland_INCLUDE_DIRS ${Wayland_${_comp}_INCLUDE_DIR})
list(APPEND Wayland_LIBRARIES ${Wayland_${_comp}_LIBRARY})
endif()
if(PKG_Wayland_VERSION AND NOT PKG_Wayland_${_pkgconfig_module_var}_VERSION)
# this is what gets set if we only search for one module
set(Wayland_${_comp}_VERSION_STRING "${PKG_Wayland_VERSION}")
else()
set(Wayland_${_comp}_VERSION_STRING "${PKG_Wayland_${_pkgconfig_module_var}_VERSION}")
endif()
if(NOT Wayland_VERSION_STRING)
set(Wayland_VERSION_STRING ${Wayland_${_comp}_VERSION_STRING})
endif()
find_package_handle_standard_args(Wayland_${_comp}
FOUND_VAR
Wayland_${_comp}_FOUND
REQUIRED_VARS
Wayland_${_comp}_LIBRARY
Wayland_${_comp}_INCLUDE_DIR
VERSION_VAR
Wayland_${_comp}_VERSION_STRING
)
mark_as_advanced(
Wayland_${_comp}_LIBRARY
Wayland_${_comp}_INCLUDE_DIR
)
if(Wayland_${_comp}_FOUND AND NOT TARGET Wayland::${_comp})
add_library(Wayland::${_comp} UNKNOWN IMPORTED)
set_target_properties(Wayland::${_comp} PROPERTIES
IMPORTED_LOCATION "${Wayland_${_comp}_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${Wayland_DEFINITIONS}"
INTERFACE_INCLUDE_DIRECTORIES "${Wayland_${_comp}_INCLUDE_DIR}"
)
endif()
endmacro()
if(NOT WIN32)
include(FindPackageHandleStandardArgs)
# Use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
find_package(PkgConfig)
pkg_check_modules(PKG_Wayland QUIET ${pkgConfigModules})
set(Wayland_DEFINITIONS ${PKG_Wayland_CFLAGS_OTHER})
foreach(comp ${comps})
_wayland_handle_component(${comp})
endforeach()
if(Wayland_INCLUDE_DIRS)
list(REMOVE_DUPLICATES Wayland_INCLUDE_DIRS)
endif()
find_package_handle_standard_args(Wayland
FOUND_VAR
Wayland_FOUND
REQUIRED_VARS
Wayland_LIBRARIES
Wayland_INCLUDE_DIRS
VERSION_VAR
Wayland_VERSION_STRING
HANDLE_COMPONENTS
)
else()
message(STATUS "Wayland is not available on Windows.")
set(Wayland_FOUND FALSE)
endif()
include(FeatureSummary)
set_package_properties(Wayland PROPERTIES
URL "http://wayland.freedesktop.org"
DESCRIPTION "C library implementation of the Wayland protocol: a protocol for a compositor to talk to its clients"
)
|