mirror of
https://github.com/hyprwm/hyprwayland-scanner.git
synced 2024-11-22 19:15:57 +01:00
cmake: add hyprwayland-scanner-config (#1)
This allows us to add wayland protocol dependencies to other cmake-based projects with minimum extra code. Example: find_package(hyprwayland-scanner REQUIRED) add_executable(target main.c) hyprwayland_protocol( target "linux-dmabuf-v1" "${WAYLAND_PROTOCOLS}/linux-dmabuf/" "${CMAKE_SOURCE_DIR}/protocols" )
This commit is contained in:
parent
126dad854f
commit
abbade08f1
2 changed files with 24 additions and 0 deletions
|
@ -8,6 +8,7 @@ project(hyprwayland-scanner
|
||||||
)
|
)
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
include(CMakePackageConfigHelpers)
|
||||||
|
|
||||||
set(PREFIX ${CMAKE_INSTALL_PREFIX})
|
set(PREFIX ${CMAKE_INSTALL_PREFIX})
|
||||||
|
|
||||||
|
@ -42,6 +43,14 @@ file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp")
|
||||||
add_executable(hyprwayland-scanner ${SRCFILES})
|
add_executable(hyprwayland-scanner ${SRCFILES})
|
||||||
target_link_libraries(hyprwayland-scanner PRIVATE rt Threads::Threads PkgConfig::deps)
|
target_link_libraries(hyprwayland-scanner PRIVATE rt Threads::Threads PkgConfig::deps)
|
||||||
|
|
||||||
|
configure_package_config_file(
|
||||||
|
hyprwayland-scanner-config.cmake.in
|
||||||
|
hyprwayland-scanner-config.cmake
|
||||||
|
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/hyprwayland-scanner"
|
||||||
|
PATH_VARS CMAKE_INSTALL_BINDIR
|
||||||
|
)
|
||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
install(TARGETS hyprwayland-scanner)
|
install(TARGETS hyprwayland-scanner)
|
||||||
install(FILES ${CMAKE_BINARY_DIR}/hyprwayland-scanner.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
install(FILES ${CMAKE_BINARY_DIR}/hyprwayland-scanner.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||||
|
install(FILES ${CMAKE_BINARY_DIR}/hyprwayland-scanner-config.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/hyprwayland-scanner)
|
||||||
|
|
15
hyprwayland-scanner-config.cmake.in
Normal file
15
hyprwayland-scanner-config.cmake.in
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
@PACKAGE_INIT@
|
||||||
|
|
||||||
|
set_and_check(BINDIR "@PACKAGE_CMAKE_INSTALL_BINDIR@")
|
||||||
|
|
||||||
|
function(hyprwayland_protocol targets protoName protoPath outputPath)
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT "${outputPath}/${protoName}.cpp"
|
||||||
|
COMMAND "${BINDIR}/hyprwayland-scanner" "${protoPath}/${protoName}.xml" "${outputPath}"
|
||||||
|
)
|
||||||
|
foreach(target ${targets})
|
||||||
|
target_sources(${target} PRIVATE "${outputPath}/${protoName}.cpp")
|
||||||
|
endforeach()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
check_required_components(hyprwayland-scanner)
|
Loading…
Reference in a new issue