1
1
find_package (PkgConfig REQUIRED )
2
+ find_package (WaylandScanner REQUIRED )
2
3
pkg_check_modules (wayland REQUIRED IMPORTED_TARGET wayland-client wayland-protocols )
3
4
4
- find_package (Qt6 REQUIRED COMPONENTS WaylandClient )
5
-
6
5
# wayland protocols
7
6
8
- if (DEFINED ENV{QTWAYLANDSCANNER} )
9
- set (qtwaylandscanner $ENV{QTWAYLANDSCANNER} )
10
- else ()
11
- find_program (qtwaylandscanner NAMES qtwaylandscanner )
7
+ if (NOT TARGET Wayland::Scanner )
8
+ message (FATAL_ERROR "Wayland::Scanner target not found. You might be missing the WaylandScanner CMake package." )
12
9
endif ()
13
10
14
- if ( qtwaylandscanner STREQUAL " qtwaylandscanner-NOTFOUND" )
15
- message (FATAL_ERROR "qtwaylandscanner not found. Set the QTWAYLANDSCANNER environment variable to specify its path explicity ." )
11
+ if ( NOT TARGET Qt6:: qtwaylandscanner )
12
+ message (FATAL_ERROR "qtwaylandscanner executable not found. Most likely there is an issue with your Qt installation ." )
16
13
endif ()
17
14
18
- message (STATUS "Found qtwaylandscanner at ${qtwaylandscanner} " )
19
-
20
- find_program (waylandscanner NAMES wayland-scanner )
21
- message (STATUS "Found wayland-scanner at ${waylandscanner} " )
22
-
23
15
execute_process (
24
16
COMMAND pkg-config --variable=pkgdatadir wayland-protocols
25
17
OUTPUT_VARIABLE WAYLAND_PROTOCOLS
@@ -32,14 +24,38 @@ function (wl_proto target name path)
32
24
set (PROTO_BUILD_PATH ${CMAKE_CURRENT_BINARY_DIR} /wl-proto/${name} )
33
25
make_directory (${PROTO_BUILD_PATH} )
34
26
35
- execute_process (COMMAND ${waylandscanner} client-header ${path} ${PROTO_BUILD_PATH} /wayland-${name}-client-protocol.h )
36
- execute_process (COMMAND ${waylandscanner} private -code ${path} ${PROTO_BUILD_PATH} /wayland-${name}.c )
37
- execute_process (COMMAND ${qtwaylandscanner} client-header ${path} OUTPUT_FILE ${PROTO_BUILD_PATH} /qwayland-${name}.h )
38
- execute_process (COMMAND ${qtwaylandscanner} client-code ${path} OUTPUT_FILE ${PROTO_BUILD_PATH} /qwayland-${name}.cpp )
27
+ set (WS_CLIENT_HEADER "${PROTO_BUILD_PATH} /wayland-${name} -client-protocol.h" )
28
+ set (WS_CLIENT_CODE "${PROTO_BUILD_PATH} /wayland-${name} .c" )
29
+ set (QWS_CLIENT_HEADER "${PROTO_BUILD_PATH} /qwayland-${name} .h" )
30
+ set (QWS_CLIENT_CODE "${PROTO_BUILD_PATH} /qwayland-${name} .cpp" )
31
+
32
+ add_custom_command (
33
+ OUTPUT "${WS_CLIENT_HEADER} "
34
+ COMMAND Wayland::Scanner client-header "${path} " "${WS_CLIENT_HEADER} "
35
+ DEPENDS Wayland::Scanner "${path} "
36
+ )
37
+
38
+ add_custom_command (
39
+ OUTPUT "${WS_CLIENT_CODE} "
40
+ COMMAND Wayland::Scanner private -code "${path} " "${WS_CLIENT_CODE} "
41
+ DEPENDS Wayland::Scanner "${path} "
42
+ )
43
+
44
+ add_custom_command (
45
+ OUTPUT "${QWS_CLIENT_HEADER} "
46
+ COMMAND Qt6::qtwaylandscanner client-header "${path} " > "${QWS_CLIENT_HEADER} "
47
+ DEPENDS Qt6::qtwaylandscanner "${path} "
48
+ )
49
+
50
+ add_custom_command (
51
+ OUTPUT "${QWS_CLIENT_CODE} "
52
+ COMMAND Qt6::qtwaylandscanner client-code "${path} " > "${QWS_CLIENT_CODE} "
53
+ DEPENDS Qt6::qtwaylandscanner "${path} "
54
+ )
39
55
40
56
add_library (wl-proto-${name}
41
- ${PROTO_BUILD_PATH} /wayland-${name}.c
42
- ${PROTO_BUILD_PATH} /qwayland-${name}.cpp
57
+ ${WS_CLIENT_HEADER} ${WS_CLIENT_CODE}
58
+ ${QWS_CLIENT_HEADER} ${QWS_CLIENT_CODE}
43
59
)
44
60
45
61
target_include_directories (wl-proto-${name} INTERFACE ${PROTO_BUILD_PATH} )
0 commit comments