2023-09-06 20:36:48 +02:00
|
|
|
cmake_minimum_required(VERSION 3.19)
|
|
|
|
|
|
|
|
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/VERSION VER)
|
|
|
|
string(STRIP ${VER} VER)
|
|
|
|
|
|
|
|
project(xdg-desktop-portal-hyprland
|
|
|
|
DESCRIPTION "An XDG-Destop-Portal backend for Hyprland (and wlroots)"
|
|
|
|
VERSION ${VER}
|
|
|
|
)
|
|
|
|
|
|
|
|
set(CMAKE_MESSAGE_LOG_LEVEL "STATUS")
|
|
|
|
|
|
|
|
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
|
|
|
|
message(STATUS "Configuring XDPH in Debug with CMake")
|
|
|
|
add_compile_definitions(HYPRLAND_DEBUG)
|
|
|
|
else()
|
|
|
|
add_compile_options(-O3)
|
|
|
|
message(STATUS "Configuring XDPH in Release with CMake")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
include_directories(
|
|
|
|
.
|
|
|
|
"protocols/"
|
|
|
|
)
|
|
|
|
|
2024-01-04 16:20:11 +01:00
|
|
|
# configure
|
2024-01-04 19:13:19 +01:00
|
|
|
include(GNUInstallDirs)
|
2024-01-04 21:34:27 +01:00
|
|
|
set(LIBEXECDIR ${CMAKE_INSTALL_FULL_LIBEXECDIR})
|
2024-01-04 16:20:11 +01:00
|
|
|
configure_file(org.freedesktop.impl.portal.desktop.hyprland.service.in org.freedesktop.impl.portal.desktop.hyprland.service @ONLY)
|
|
|
|
configure_file(contrib/systemd/xdg-desktop-portal-hyprland.service.in contrib/systemd/xdg-desktop-portal-hyprland.service @ONLY)
|
|
|
|
|
2023-09-06 20:36:48 +02:00
|
|
|
set(CMAKE_CXX_STANDARD 23)
|
2023-11-30 11:24:14 +01:00
|
|
|
add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value
|
|
|
|
-Wno-missing-field-initializers -Wno-narrowing -Wno-pointer-arith
|
2024-01-04 18:22:30 +01:00
|
|
|
-fpermissive -Wno-address-of-temporary)
|
2023-09-06 20:36:48 +02:00
|
|
|
|
2024-01-04 16:20:11 +01:00
|
|
|
# dependencies
|
2023-09-06 20:36:48 +02:00
|
|
|
message(STATUS "Checking deps...")
|
|
|
|
add_subdirectory(hyprland-share-picker)
|
|
|
|
|
2023-09-18 21:00:21 +02:00
|
|
|
find_package(Threads REQUIRED)
|
2023-09-06 20:36:48 +02:00
|
|
|
find_package(PkgConfig REQUIRED)
|
2024-01-03 12:59:40 +01:00
|
|
|
pkg_check_modules(deps REQUIRED IMPORTED_TARGET wayland-client wayland-protocols libpipewire-0.3 libspa-0.2 libdrm gbm hyprlang>=0.2.0)
|
2023-09-06 20:36:48 +02:00
|
|
|
|
2024-01-03 22:43:01 +01:00
|
|
|
# check whether we can find sdbus-c++ through pkg-config
|
|
|
|
pkg_check_modules(SDBUS IMPORTED_TARGET sdbus-c++)
|
|
|
|
if(NOT SDBUS_FOUND)
|
2024-01-04 16:20:11 +01:00
|
|
|
include_directories("subprojects/sdbus-cpp/include/")
|
2024-01-03 22:43:01 +01:00
|
|
|
add_subdirectory(subprojects/sdbus-cpp)
|
2024-01-04 18:48:43 +01:00
|
|
|
add_library(PkgConfig::SDBUS ALIAS sdbus-c++)
|
2024-01-03 22:43:01 +01:00
|
|
|
endif()
|
|
|
|
|
2024-01-04 16:20:11 +01:00
|
|
|
# same for hyprland-protocols
|
|
|
|
pkg_check_modules(HYPRLAND_PROTOS IMPORTED_TARGET hyprland-protocols)
|
|
|
|
if(HYPRLAND_PROTOS_FOUND)
|
|
|
|
set(HYPRLAND_PROTOCOLS "${HYPRLAND_PROTOS_PREFIX}/share/hyprland-protocols")
|
|
|
|
else()
|
|
|
|
set(HYPRLAND_PROTOCOLS "subprojects/hyprland-protocols")
|
|
|
|
endif()
|
|
|
|
|
2023-09-06 20:36:48 +02:00
|
|
|
file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp")
|
|
|
|
add_executable(xdg-desktop-portal-hyprland ${SRCFILES})
|
2024-01-04 18:48:43 +01:00
|
|
|
target_link_libraries(xdg-desktop-portal-hyprland PRIVATE rt PkgConfig::SDBUS Threads::Threads PkgConfig::deps)
|
2023-09-06 20:36:48 +02:00
|
|
|
|
|
|
|
# protocols
|
|
|
|
find_program(WaylandScanner NAMES wayland-scanner)
|
|
|
|
message(STATUS "Found WaylandScanner at ${WaylandScanner}")
|
|
|
|
execute_process(
|
|
|
|
COMMAND pkg-config --variable=pkgdatadir wayland-protocols
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
|
|
OUTPUT_VARIABLE WAYLAND_PROTOCOLS_DIR
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
message(STATUS "Found wayland-protocols at ${WAYLAND_PROTOCOLS_DIR}")
|
|
|
|
|
|
|
|
function(protocol protoPath protoName external)
|
|
|
|
if (external)
|
|
|
|
execute_process(
|
|
|
|
COMMAND ${WaylandScanner} client-header ${protoPath} protocols/${protoName}-protocol.h
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
|
|
|
execute_process(
|
|
|
|
COMMAND ${WaylandScanner} private-code ${protoPath} protocols/${protoName}-protocol.c
|
2023-11-30 11:24:14 +01:00
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
2023-09-06 20:36:48 +02:00
|
|
|
target_sources(xdg-desktop-portal-hyprland PRIVATE protocols/${protoName}-protocol.c)
|
|
|
|
else()
|
|
|
|
execute_process(
|
|
|
|
COMMAND ${WaylandScanner} client-header ${WAYLAND_PROTOCOLS_DIR}/${protoPath} protocols/${protoName}-protocol.h
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
|
|
|
execute_process(
|
|
|
|
COMMAND ${WaylandScanner} private-code ${WAYLAND_PROTOCOLS_DIR}/${protoPath} protocols/${protoName}-protocol.c
|
2023-11-30 11:24:14 +01:00
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
2023-09-06 20:36:48 +02:00
|
|
|
target_sources(xdg-desktop-portal-hyprland PRIVATE protocols/${protoName}-protocol.c)
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
protocol("protocols/wlr-foreign-toplevel-management-unstable-v1.xml" "wlr-foreign-toplevel-management-unstable-v1" true)
|
|
|
|
protocol("protocols/wlr-screencopy-unstable-v1.xml" "wlr-screencopy-unstable-v1" true)
|
2024-01-04 16:20:11 +01:00
|
|
|
protocol("${HYPRLAND_PROTOCOLS}/protocols/hyprland-global-shortcuts-v1.xml" "hyprland-global-shortcuts-v1" true)
|
|
|
|
protocol("${HYPRLAND_PROTOCOLS}/protocols/hyprland-toplevel-export-v1.xml" "hyprland-toplevel-export-v1" true)
|
2023-09-06 20:36:48 +02:00
|
|
|
protocol("unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml" "linux-dmabuf-unstable-v1" false)
|
2024-01-04 16:20:11 +01:00
|
|
|
|
|
|
|
# Installation
|
|
|
|
install(TARGETS hyprland-share-picker)
|
|
|
|
install(TARGETS xdg-desktop-portal-hyprland DESTINATION ${CMAKE_INSTALL_LIBEXECDIR})
|
|
|
|
|
|
|
|
install(FILES hyprland.portal DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/xdg-desktop-portal/portals")
|
|
|
|
install(FILES ${CMAKE_BINARY_DIR}/org.freedesktop.impl.portal.desktop.hyprland.service DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/dbus-1/services")
|
|
|
|
install(FILES ${CMAKE_BINARY_DIR}/contrib/systemd/xdg-desktop-portal-hyprland.service DESTINATION "${CMAKE_INSTALL_LIBDIR}/systemd/user")
|