59 lines
1.9 KiB
CMake
59 lines
1.9 KiB
CMake
find_program(QTWAYLANDSCANNER_EXECUTABLE qtwaylandscanner REQUIRED)
|
|
find_program(WAYLAND_SCANNER_EXECUTABLE wayland-scanner REQUIRED)
|
|
|
|
pkg_get_variable(WAYLAND_PROTOCOLS wayland-protocols pkgdatadir)
|
|
if(NOT WAYLAND_PROTOCOLS)
|
|
message(FATAL_ERROR "wayland-protocols not found")
|
|
endif()
|
|
|
|
function(wl_proto arg_TARGET arg_PROTOCOL arg_XML_DIR)
|
|
set(out_dir "${CMAKE_BINARY_DIR}/wayland-protocols/${arg_TARGET}")
|
|
file(MAKE_DIRECTORY "${out_dir}")
|
|
|
|
set(xml "${arg_XML_DIR}/${arg_PROTOCOL}.xml")
|
|
|
|
add_custom_command(
|
|
OUTPUT "${out_dir}/wayland-${arg_PROTOCOL}-client-protocol.h"
|
|
"${out_dir}/wayland-${arg_PROTOCOL}.c"
|
|
COMMAND ${WAYLAND_SCANNER_EXECUTABLE} client-header "${xml}"
|
|
"${out_dir}/wayland-${arg_PROTOCOL}-client-protocol.h"
|
|
COMMAND ${WAYLAND_SCANNER_EXECUTABLE} private-code "${xml}"
|
|
"${out_dir}/wayland-${arg_PROTOCOL}.c"
|
|
DEPENDS "${xml}"
|
|
COMMENT "Generating ${arg_PROTOCOL} protocol files"
|
|
)
|
|
|
|
add_custom_command(
|
|
OUTPUT "${out_dir}/qwayland-${arg_PROTOCOL}.h"
|
|
"${out_dir}/qwayland-${arg_PROTOCOL}.cpp"
|
|
COMMAND ${QTWAYLANDSCANNER_EXECUTABLE} client-header "${xml}"
|
|
> "${out_dir}/qwayland-${arg_PROTOCOL}.h"
|
|
COMMAND ${QTWAYLANDSCANNER_EXECUTABLE} client-code "${xml}"
|
|
> "${out_dir}/qwayland-${arg_PROTOCOL}.cpp"
|
|
DEPENDS "${xml}" "${out_dir}/wayland-${arg_PROTOCOL}-client-protocol.h"
|
|
COMMENT "Generating ${arg_PROTOCOL} client wrapper"
|
|
)
|
|
|
|
add_library(
|
|
${arg_TARGET}
|
|
STATIC
|
|
"${out_dir}/wayland-${arg_PROTOCOL}.c"
|
|
"${out_dir}/qwayland-${arg_PROTOCOL}.cpp"
|
|
)
|
|
set_source_files_properties(
|
|
"${out_dir}/qwayland-${arg_PROTOCOL}.cpp"
|
|
PROPERTIES COMPILE_OPTIONS
|
|
"-Wno-old-style-cast;-Wno-sign-conversion;-Wno-conversion;-Wno-shadow"
|
|
)
|
|
set_target_properties(${arg_TARGET} PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
|
target_include_directories(${arg_TARGET} PUBLIC "${out_dir}")
|
|
target_link_libraries(
|
|
${arg_TARGET}
|
|
PUBLIC
|
|
Qt::Core
|
|
Qt::WaylandClient
|
|
Qt::WaylandClientPrivate
|
|
PkgConfig::WAYLAND_CLIENT
|
|
)
|
|
endfunction()
|