CMake: fmt, require pw>=1.1.82

This commit is contained in:
Mihai Fufezan 2024-07-23 20:17:29 +03:00
parent 3b8c78145a
commit 5555f467f6
Signed by: fufexan
SSH key fingerprint: SHA256:SdnKmEpJrDu1+2UO1QpB/Eg4HKcdDi6n+xSRqFNJVpg

View file

@ -3,13 +3,15 @@ cmake_minimum_required(VERSION 3.19)
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/VERSION VER) file(READ ${CMAKE_CURRENT_SOURCE_DIR}/VERSION VER)
string(STRIP ${VER} VER) string(STRIP ${VER} VER)
project(xdg-desktop-portal-hyprland project(
xdg-desktop-portal-hyprland
DESCRIPTION "An XDG-Destop-Portal backend for Hyprland (and wlroots)" DESCRIPTION "An XDG-Destop-Portal backend for Hyprland (and wlroots)"
VERSION ${VER} VERSION ${VER})
)
set(CMAKE_MESSAGE_LOG_LEVEL "STATUS") set(CMAKE_MESSAGE_LOG_LEVEL "STATUS")
set(SYSTEMD_SERVICES ON CACHE BOOL "Install systemd service file") set(SYSTEMD_SERVICES
ON
CACHE BOOL "Install systemd service file")
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG) if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
message(STATUS "Configuring XDPH in Debug with CMake") message(STATUS "Configuring XDPH in Debug with CMake")
@ -19,23 +21,29 @@ else()
message(STATUS "Configuring XDPH in Release with CMake") message(STATUS "Configuring XDPH in Release with CMake")
endif() endif()
include_directories( include_directories(. "protocols/")
.
"protocols/"
)
# configure # configure
include(GNUInstallDirs) include(GNUInstallDirs)
set(LIBEXECDIR ${CMAKE_INSTALL_FULL_LIBEXECDIR}) set(LIBEXECDIR ${CMAKE_INSTALL_FULL_LIBEXECDIR})
configure_file(org.freedesktop.impl.portal.desktop.hyprland.service.in org.freedesktop.impl.portal.desktop.hyprland.service @ONLY) configure_file(org.freedesktop.impl.portal.desktop.hyprland.service.in
org.freedesktop.impl.portal.desktop.hyprland.service @ONLY)
if(SYSTEMD_SERVICES) if(SYSTEMD_SERVICES)
configure_file(contrib/systemd/xdg-desktop-portal-hyprland.service.in contrib/systemd/xdg-desktop-portal-hyprland.service @ONLY) configure_file(contrib/systemd/xdg-desktop-portal-hyprland.service.in
contrib/systemd/xdg-desktop-portal-hyprland.service @ONLY)
endif() endif()
set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD 23)
add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value add_compile_options(
-Wno-missing-field-initializers -Wno-narrowing -Wno-pointer-arith -Wall
$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-fpermissive> -Wno-address-of-temporary) -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)
# dependencies # dependencies
message(STATUS "Checking deps...") message(STATUS "Checking deps...")
@ -43,7 +51,18 @@ add_subdirectory(hyprland-share-picker)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
pkg_check_modules(deps REQUIRED IMPORTED_TARGET wayland-client wayland-protocols wayland-scanner libpipewire-0.3 libspa-0.2 libdrm gbm hyprlang>=0.2.0) pkg_check_modules(
deps
REQUIRED
IMPORTED_TARGET
wayland-client
wayland-protocols
wayland-scanner
libpipewire-0.3>=1.1.82
libspa-0.2
libdrm
gbm
hyprlang>=0.2.0)
# check whether we can find sdbus-c++ through pkg-config # check whether we can find sdbus-c++ through pkg-config
pkg_check_modules(SDBUS IMPORTED_TARGET sdbus-c++) pkg_check_modules(SDBUS IMPORTED_TARGET sdbus-c++)
@ -63,7 +82,9 @@ endif()
file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp") file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp")
add_executable(xdg-desktop-portal-hyprland ${SRCFILES}) add_executable(xdg-desktop-portal-hyprland ${SRCFILES})
target_link_libraries(xdg-desktop-portal-hyprland PRIVATE rt PkgConfig::SDBUS Threads::Threads PkgConfig::deps) target_link_libraries(
xdg-desktop-portal-hyprland PRIVATE rt PkgConfig::SDBUS Threads::Threads
PkgConfig::deps)
# protocols # protocols
pkg_get_variable(WaylandScanner wayland-scanner wayland_scanner) pkg_get_variable(WaylandScanner wayland-scanner wayland_scanner)
@ -79,28 +100,44 @@ function(protocol protoPath protoName external)
endif() endif()
add_custom_command( add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/protocols/${protoName}-protocol.h OUTPUT ${CMAKE_SOURCE_DIR}/protocols/${protoName}-protocol.h
COMMAND ${WaylandScanner} client-header ${path} ${CMAKE_SOURCE_DIR}/protocols/${protoName}-protocol.h COMMAND ${WaylandScanner} client-header ${path}
${CMAKE_SOURCE_DIR}/protocols/${protoName}-protocol.h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
add_custom_command( add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/protocols/${protoName}-protocol.c OUTPUT ${CMAKE_SOURCE_DIR}/protocols/${protoName}-protocol.c
COMMAND ${WaylandScanner} private-code ${path} ${CMAKE_SOURCE_DIR}/protocols/${protoName}-protocol.c COMMAND ${WaylandScanner} private-code ${path}
${CMAKE_SOURCE_DIR}/protocols/${protoName}-protocol.c
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
target_sources(xdg-desktop-portal-hyprland PRIVATE protocols/${protoName}-protocol.h) target_sources(xdg-desktop-portal-hyprland
target_sources(xdg-desktop-portal-hyprland PRIVATE protocols/${protoName}-protocol.c) PRIVATE protocols/${protoName}-protocol.h)
target_sources(xdg-desktop-portal-hyprland
PRIVATE protocols/${protoName}-protocol.c)
endfunction() endfunction()
protocol("protocols/wlr-foreign-toplevel-management-unstable-v1.xml" "wlr-foreign-toplevel-management-unstable-v1" true) protocol("protocols/wlr-foreign-toplevel-management-unstable-v1.xml"
protocol("protocols/wlr-screencopy-unstable-v1.xml" "wlr-screencopy-unstable-v1" true) "wlr-foreign-toplevel-management-unstable-v1" true)
protocol("${HYPRLAND_PROTOCOLS}/protocols/hyprland-global-shortcuts-v1.xml" "hyprland-global-shortcuts-v1" true) protocol("protocols/wlr-screencopy-unstable-v1.xml"
protocol("${HYPRLAND_PROTOCOLS}/protocols/hyprland-toplevel-export-v1.xml" "hyprland-toplevel-export-v1" true) "wlr-screencopy-unstable-v1" true)
protocol("unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml" "linux-dmabuf-unstable-v1" false) 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)
protocol("unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml"
"linux-dmabuf-unstable-v1" false)
# Installation # Installation
install(TARGETS hyprland-share-picker) install(TARGETS hyprland-share-picker)
install(TARGETS xdg-desktop-portal-hyprland DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}) install(TARGETS xdg-desktop-portal-hyprland
DESTINATION ${CMAKE_INSTALL_LIBEXECDIR})
install(FILES hyprland.portal DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/xdg-desktop-portal/portals") install(FILES hyprland.portal
install(FILES ${CMAKE_BINARY_DIR}/org.freedesktop.impl.portal.desktop.hyprland.service DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/dbus-1/services") 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) if(SYSTEMD_SERVICES)
install(FILES ${CMAKE_BINARY_DIR}/contrib/systemd/xdg-desktop-portal-hyprland.service DESTINATION "lib/systemd/user") install(
FILES
${CMAKE_BINARY_DIR}/contrib/systemd/xdg-desktop-portal-hyprland.service
DESTINATION "lib/systemd/user")
endif() endif()