Skip to content

Commit

Permalink
wip: installheaders with custom cmake target
Browse files Browse the repository at this point in the history
  • Loading branch information
zjeffer committed May 21, 2024
1 parent 8c0ae9a commit 9554aea
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
27 changes: 27 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -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})
Expand All @@ -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(
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ../../../..
Expand Down

0 comments on commit 9554aea

Please sign in to comment.