From 9554aea93c0cdaca043ffdab3a7f60e659e31cdd Mon Sep 17 00:00:00 2001 From: zjeffer <4633209+zjeffer@users.noreply.github.com> Date: Wed, 22 May 2024 00:02:01 +0200 Subject: [PATCH] wip: installheaders with custom cmake target --- CMakeLists.txt | 27 +++++++++++++++++++++++++++ Makefile | 2 ++ 2 files changed, 29 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 858502cc5fce..8d26ee2acfd0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -219,6 +219,9 @@ message(STATUS "Setting link libraries") target_link_libraries(Hyprland rt PkgConfig::deps) +# list of headers +set(PROTOCOL_HEADERS "" CACHE INTERNAL "List of protocol headers") + function(protocol protoPath protoName external) if (external) set(path ${CMAKE_SOURCE_DIR}/${protoPath}) @@ -238,7 +241,14 @@ function(protocol protoPath protoName external) ) target_sources(Hyprland PRIVATE ${CMAKE_SOURCE_DIR}/protocols/${protoName}-protocol.h) target_sources(Hyprland PRIVATE ${CMAKE_SOURCE_DIR}/protocols/${protoName}-protocol.c) + + set ( + PROTOCOL_HEADERS + "${PROTOCOL_HEADERS};${CMAKE_SOURCE_DIR}/protocols/${protoName}-protocol.h;${CMAKE_SOURCE_DIR}/protocols/${protoName}-protocol.c" + PARENT_SCOPE + ) endfunction() + function(protocolNew protoPath protoName external) if (external) set(path ${CMAKE_SOURCE_DIR}/${protoPath}) @@ -253,6 +263,12 @@ function(protocolNew protoPath protoName external) ) target_sources(Hyprland PRIVATE protocols/${protoName}.cpp) target_sources(Hyprland PRIVATE protocols/${protoName}.hpp) + + set ( + PROTOCOL_HEADERS + "${PROTOCOL_HEADERS};${CMAKE_SOURCE_DIR}/protocols/${protoName}.cpp;${CMAKE_SOURCE_DIR}/protocols/${protoName}.hpp" + PARENT_SCOPE + ) endfunction() function(protocolWayland) add_custom_command( @@ -263,6 +279,12 @@ function(protocolWayland) ) target_sources(Hyprland PRIVATE protocols/wayland.cpp) target_sources(Hyprland PRIVATE protocols/wayland.hpp) + + set ( + PROTOCOL_HEADERS + "${PROTOCOL_HEADERS};${CMAKE_SOURCE_DIR}/protocols/wayland.cpp;${CMAKE_SOURCE_DIR}/protocols/wayland.hpp" + PARENT_SCOPE + ) endfunction() target_link_libraries(Hyprland @@ -314,6 +336,11 @@ protocolNew("unstable/primary-selection" "primary-selection-unstable-v1" false) protocolWayland() +add_custom_target( + generate-protocol-headers + DEPENDS ${PROTOCOL_HEADERS} +) + # tools add_subdirectory(hyprctl) add_subdirectory(hyprpm) diff --git a/Makefile b/Makefile index e7b9c1b6f927..a33f4cb71076 100644 --- a/Makefile +++ b/Makefile @@ -53,6 +53,8 @@ installheaders: mkdir -p ${PREFIX}/include/hyprland/wlr mkdir -p ${PREFIX}/share/pkgconfig + cmake --build ./build --config Release --target generate-protocol-headers + find src -name '*.h*' -print0 | cpio --quiet -0dump ${PREFIX}/include/hyprland cd subprojects/wlroots-hyprland/include/wlr && find . -name '*.h*' -print0 | cpio --quiet -0dump ${PREFIX}/include/hyprland/wlr && cd ../../../.. cd subprojects/wlroots-hyprland/build/include && find . -name '*.h*' -print0 | cpio --quiet -0dump ${PREFIX}/include/hyprland/wlr && cd ../../../..