diff --git a/CMakeLists.txt b/CMakeLists.txt index d709c00..9800fef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,7 @@ project(hyprwayland-scanner ) include(GNUInstallDirs) +include(CMakePackageConfigHelpers) set(PREFIX ${CMAKE_INSTALL_PREFIX}) @@ -42,6 +43,14 @@ file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp") add_executable(hyprwayland-scanner ${SRCFILES}) 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 install(TARGETS hyprwayland-scanner) 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) diff --git a/hyprwayland-scanner-config.cmake.in b/hyprwayland-scanner-config.cmake.in new file mode 100644 index 0000000..02096fe --- /dev/null +++ b/hyprwayland-scanner-config.cmake.in @@ -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)