11find_package (PkgConfig REQUIRED)
2+ find_package (WaylandScanner REQUIRED)
23pkg_check_modules(wayland REQUIRED IMPORTED_TARGET wayland-client wayland-protocols)
34
4- find_package (Qt6 REQUIRED COMPONENTS WaylandClient)
5-
65# wayland protocols
76
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." )
129endif ()
1310
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 ." )
1613endif ()
1714
18- message (STATUS "Found qtwaylandscanner at ${qtwaylandscanner} " )
19-
20- find_program (waylandscanner NAMES wayland-scanner)
21- message (STATUS "Found wayland-scanner at ${waylandscanner} " )
22-
2315execute_process (
2416 COMMAND pkg-config --variable =pkgdatadir wayland-protocols
2517 OUTPUT_VARIABLE WAYLAND_PROTOCOLS
@@ -32,14 +24,38 @@ function (wl_proto target name path)
3224 set (PROTO_BUILD_PATH ${CMAKE_CURRENT_BINARY_DIR} /wl-proto/${name} )
3325 make_directory (${PROTO_BUILD_PATH} )
3426
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+ )
3955
4056 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}
4359 )
4460
4561 target_include_directories (wl-proto-${name} INTERFACE ${PROTO_BUILD_PATH} )
0 commit comments