Skip to content

Commit 89d04f3

Browse files
committed
build: find waylandscanner and qtwaylandscanner from imported target
Removes the QTWAYLANDSCANNER env hack.
1 parent 23f59ec commit 89d04f3

File tree

3 files changed

+35
-22
lines changed

3 files changed

+35
-22
lines changed

default.nix

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@
6565
++ lib.optional withPam pam
6666
++ lib.optional withPipewire pipewire;
6767

68-
QTWAYLANDSCANNER = lib.optionalString withWayland "${qt6.qtwayland}/libexec/qtwaylandscanner";
69-
7068
cmakeBuildType = if debug then "Debug" else "RelWithDebInfo";
7169

7270
cmakeFlags = [

shell.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ in pkgs.mkShell.override { stdenv = quickshell.stdenv; } {
2121
];
2222

2323
TIDYFOX = "${tidyfox}/lib/libtidyfox.so";
24-
QTWAYLANDSCANNER = quickshell.QTWAYLANDSCANNER;
2524

2625
shellHook = ''
2726
export CMAKE_BUILD_PARALLEL_LEVEL=$(nproc)

src/wayland/CMakeLists.txt

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,17 @@
11
find_package(PkgConfig REQUIRED)
2+
find_package(WaylandScanner REQUIRED)
23
pkg_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.")
129
endif()
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.")
1613
endif()
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-
2315
execute_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

Comments
 (0)