xdg-desktop-portal-hyprland/CMakeLists.txt

154 lines
5 KiB
Text
Raw Normal View History

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)
2024-07-23 19:17:29 +02:00
project(
xdg-desktop-portal-hyprland
DESCRIPTION "An XDG-Destop-Portal backend for Hyprland (and wlroots)"
VERSION ${VER})
2023-09-06 20:36:48 +02:00
set(CMAKE_MESSAGE_LOG_LEVEL "STATUS")
2024-07-23 19:17:29 +02:00
set(SYSTEMD_SERVICES
ON
CACHE BOOL "Install systemd service file")
2023-09-06 20:36:48 +02:00
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
2024-07-23 19:17:29 +02:00
message(STATUS "Configuring XDPH in Debug with CMake")
add_compile_definitions(HYPRLAND_DEBUG)
2023-09-06 20:36:48 +02:00
else()
2024-07-23 19:17:29 +02:00
add_compile_options(-O3)
message(STATUS "Configuring XDPH in Release with CMake")
2023-09-06 20:36:48 +02:00
endif()
2024-09-21 17:45:23 +02:00
add_compile_definitions(XDPH_VERSION="${VER}")
2024-07-23 19:17:29 +02:00
include_directories(. "protocols/")
2023-09-06 20:36:48 +02: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-07-23 19:17:29 +02:00
configure_file(org.freedesktop.impl.portal.desktop.hyprland.service.in
org.freedesktop.impl.portal.desktop.hyprland.service @ONLY)
if(SYSTEMD_SERVICES)
2024-07-23 19:17:29 +02:00
configure_file(contrib/systemd/xdg-desktop-portal-hyprland.service.in
contrib/systemd/xdg-desktop-portal-hyprland.service @ONLY)
endif()
2023-09-06 20:36:48 +02:00
set(CMAKE_CXX_STANDARD 23)
2024-07-23 19:17:29 +02:00
add_compile_options(
-Wall
-Wextra
-Wno-unused-parameter
-Wno-unused-value
-Wno-missing-field-initializers
-Wno-narrowing
-Wno-pointer-arith
$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-fpermissive>
-Wno-address-of-temporary)
2023-09-06 20:36:48 +02:00
# dependencies
2023-09-06 20:36:48 +02:00
message(STATUS "Checking deps...")
add_subdirectory(hyprland-share-picker)
find_package(Threads REQUIRED)
2023-09-06 20:36:48 +02:00
find_package(PkgConfig REQUIRED)
2024-07-23 19:17:29 +02:00
pkg_check_modules(
deps
REQUIRED
IMPORTED_TARGET
wayland-client
wayland-protocols
libpipewire-0.3>=1.1.82
libspa-0.2
libdrm
2024-09-25 18:06:16 +02:00
libeis-1.0
2024-07-23 19:17:29 +02:00
gbm
hyprlang>=0.2.0
hyprutils>=0.2.6
hyprwayland-scanner>=0.4.2)
2023-09-06 20:36:48 +02:00
# check whether we can find sdbus-c++ through pkg-config
pkg_check_modules(SDBUS IMPORTED_TARGET sdbus-c++>=2.0.0)
if(NOT SDBUS_FOUND)
2024-07-23 19:17:29 +02:00
include_directories("subprojects/sdbus-cpp/include/")
add_subdirectory(subprojects/sdbus-cpp EXCLUDE_FROM_ALL)
add_library(PkgConfig::SDBUS ALIAS sdbus-c++)
endif()
# same for hyprland-protocols
pkg_check_modules(HYPRLAND_PROTOS IMPORTED_TARGET hyprland-protocols)
if(HYPRLAND_PROTOS_FOUND)
2024-07-23 19:17:29 +02:00
set(HYPRLAND_PROTOCOLS "${HYPRLAND_PROTOS_PREFIX}/share/hyprland-protocols")
else()
set(HYPRLAND_PROTOCOLS "${CMAKE_SOURCE_DIR}/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-07-23 19:17:29 +02: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
pkg_get_variable(WAYLAND_PROTOCOLS_DIR wayland-protocols pkgdatadir)
2023-09-06 20:36:48 +02:00
message(STATUS "Found wayland-protocols at ${WAYLAND_PROTOCOLS_DIR}")
pkg_get_variable(WAYLAND_SCANNER_DIR wayland-scanner pkgdatadir)
message(STATUS "Found wayland-scanner at ${WAYLAND_SCANNER_DIR}")
2023-09-06 20:36:48 +02:00
function(protocolnew protoPath protoName external)
2024-07-23 19:17:29 +02:00
if(external)
set(path ${protoPath})
else()
set(path ${WAYLAND_PROTOCOLS_DIR}/${protoPath})
endif()
add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/protocols/${protoName}.cpp
${CMAKE_SOURCE_DIR}/protocols/${protoName}.hpp
COMMAND hyprwayland-scanner --client ${path}/${protoName}.xml
${CMAKE_SOURCE_DIR}/protocols/
2024-07-23 19:17:29 +02:00
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
target_sources(xdg-desktop-portal-hyprland PRIVATE protocols/${protoName}.cpp
protocols/${protoName}.hpp)
endfunction()
function(protocolWayland)
2024-07-23 19:17:29 +02:00
add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/protocols/wayland.cpp
${CMAKE_SOURCE_DIR}/protocols/wayland.hpp
COMMAND hyprwayland-scanner --wayland-enums --client
${WAYLAND_SCANNER_DIR}/wayland.xml ${CMAKE_SOURCE_DIR}/protocols/
2024-07-23 19:17:29 +02:00
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
target_sources(xdg-desktop-portal-hyprland PRIVATE protocols/wayland.cpp
protocols/wayland.hpp)
2023-09-06 20:36:48 +02:00
endfunction()
protocolwayland()
protocolnew("${CMAKE_SOURCE_DIR}/protocols"
"wlr-foreign-toplevel-management-unstable-v1" true)
protocolnew("${CMAKE_SOURCE_DIR}/protocols" "wlr-screencopy-unstable-v1" true)
protocolnew("${HYPRLAND_PROTOCOLS}/protocols" "hyprland-global-shortcuts-v1"
true)
protocolnew("${HYPRLAND_PROTOCOLS}/protocols" "hyprland-toplevel-export-v1"
true)
2024-09-25 18:06:16 +02:00
protocolnew("${HYPRLAND_PROTOCOLS}/protocols" "hyprland-input-capture-v1"
true)
protocolnew("stable/linux-dmabuf" "linux-dmabuf-v1" false)
# Installation
install(TARGETS hyprland-share-picker)
2024-07-23 19:17:29 +02:00
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")
if(SYSTEMD_SERVICES)
2024-07-23 19:17:29 +02:00
install(
FILES
${CMAKE_BINARY_DIR}/contrib/systemd/xdg-desktop-portal-hyprland.service
DESTINATION "lib/systemd/user")
endif()