Skip to content

Commit 18bc294

Browse files
committed
GPU Display CMake: Simplify generation of wayland protocols
1 parent f128d9b commit 18bc294

1 file changed

Lines changed: 25 additions & 27 deletions

File tree

‎GPU/GPUTracking/display/CMakeLists.txt‎

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -76,35 +76,33 @@ set(HDRS_INSTALL shaders/GPUDisplayShaders.h)
7676
if(GPUCA_EVENT_DISPLAY_VULKAN)
7777
set(SRCS ${SRCS} backend/GPUDisplayBackendVulkan.cxx)
7878
if(GPUCA_EVENT_DISPLAY_WAYLAND)
79-
add_custom_command(
80-
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/xdg-gen/xdg-shell-client-protocol.h
81-
COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/xdg-gen/
82-
COMMAND ${O2GPUWayland_SCANNER} client-header ${O2GPUWayland_PROTOCOLS_DIR}/stable/xdg-shell/xdg-shell.xml ${CMAKE_CURRENT_BINARY_DIR}/xdg-gen/xdg-shell-client-protocol.h
83-
MAIN_DEPENDENCY ${O2GPUWayland_PROTOCOLS_DIR}/stable/xdg-shell/xdg-shell.xml
84-
COMMENT "Preparing Wayland xdg-shell-client-protocol.h")
85-
add_custom_command(
86-
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/xdg-gen/xdg-shell-protocol.c
87-
COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/xdg-gen/
88-
COMMAND ${O2GPUWayland_SCANNER} private-code ${O2GPUWayland_PROTOCOLS_DIR}/stable/xdg-shell/xdg-shell.xml ${CMAKE_CURRENT_BINARY_DIR}/xdg-gen/xdg-shell-protocol.c
89-
MAIN_DEPENDENCY ${O2GPUWayland_PROTOCOLS_DIR}/stable/xdg-shell/xdg-shell.xml
90-
COMMENT "Preparing Wayland xdg-shell-protocol.c")
91-
add_custom_command(
92-
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/xdg-gen/xdg-decoration-client-protocol.h
93-
COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/xdg-gen/
94-
COMMAND ${O2GPUWayland_SCANNER} client-header ${O2GPUWayland_PROTOCOLS_DIR}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml ${CMAKE_CURRENT_BINARY_DIR}/xdg-gen/xdg-decoration-client-protocol.h
95-
MAIN_DEPENDENCY ${O2GPUWayland_PROTOCOLS_DIR}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml
96-
COMMENT "Preparing Wayland xdg-decoration-client-protocol.h")
97-
add_custom_command(
98-
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/xdg-gen/xdg-decoration-protocol.c
99-
COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/xdg-gen/
100-
COMMAND ${O2GPUWayland_SCANNER} private-code ${O2GPUWayland_PROTOCOLS_DIR}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml ${CMAKE_CURRENT_BINARY_DIR}/xdg-gen/xdg-decoration-protocol.c
101-
MAIN_DEPENDENCY ${O2GPUWayland_PROTOCOLS_DIR}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml
102-
COMMENT "Preparing Wayland xdg-decoration-protocol.c")
103-
104-
set_property(SOURCE frontend/GPUDisplayFrontendWayland.cxx ${CMAKE_CURRENT_BINARY_DIR}/xdg-gen/xdg-shell-protocol.c APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/xdg-gen/xdg-shell-client-protocol.h ${CMAKE_CURRENT_BINARY_DIR}/xdg-gen/xdg-decoration-client-protocol.h)
79+
set(WAYLAND_PROTOCOL_HEADERS)
80+
set(WAYLAND_PROTOCOL_SOURCES)
81+
foreach(xml stable/xdg-shell/xdg-shell.xml unstable/xdg-decoration/xdg-decoration-unstable-v1.xml)
82+
get_filename_component(name ${xml} NAME_WE)
83+
string(REPLACE "-unstable-v1" "" name ${name})
84+
set(header ${CMAKE_CURRENT_BINARY_DIR}/xdg-gen/${name}-client-protocol.h)
85+
set(source ${CMAKE_CURRENT_BINARY_DIR}/xdg-gen/${name}-protocol.c)
86+
add_custom_command(
87+
OUTPUT ${header}
88+
COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/xdg-gen/
89+
COMMAND ${O2GPUWayland_SCANNER} client-header ${O2GPUWayland_PROTOCOLS_DIR}/${xml} ${header}
90+
MAIN_DEPENDENCY ${O2GPUWayland_PROTOCOLS_DIR}/${xml}
91+
COMMENT "Preparing Wayland ${name}-client-protocol.h")
92+
add_custom_command(
93+
OUTPUT ${source}
94+
COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/xdg-gen/
95+
COMMAND ${O2GPUWayland_SCANNER} private-code ${O2GPUWayland_PROTOCOLS_DIR}/${xml} ${source}
96+
MAIN_DEPENDENCY ${O2GPUWayland_PROTOCOLS_DIR}/${xml}
97+
COMMENT "Preparing Wayland ${name}-protocol.c")
98+
list(APPEND WAYLAND_PROTOCOL_HEADERS ${header})
99+
list(APPEND WAYLAND_PROTOCOL_SOURCES ${source})
100+
endforeach()
101+
102+
set_property(SOURCE frontend/GPUDisplayFrontendWayland.cxx ${WAYLAND_PROTOCOL_SOURCES} APPEND PROPERTY OBJECT_DEPENDS ${WAYLAND_PROTOCOL_HEADERS})
105103
set_property(SOURCE frontend/GPUDisplayFrontendWayland.cxx APPEND PROPERTY INCLUDE_DIRECTORIES ${CMAKE_CURRENT_BINARY_DIR}/xdg-gen/)
106104

107-
set(SRCS_NO_H ${SRCS_NO_H} frontend/GPUDisplayFrontendWayland.cxx ${CMAKE_CURRENT_BINARY_DIR}/xdg-gen/xdg-shell-protocol.c ${CMAKE_CURRENT_BINARY_DIR}/xdg-gen/xdg-decoration-protocol.c)
105+
set(SRCS_NO_H ${SRCS_NO_H} frontend/GPUDisplayFrontendWayland.cxx ${WAYLAND_PROTOCOL_SOURCES})
108106
endif()
109107
endif()
110108

0 commit comments

Comments
 (0)