Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake: get rid of Makefile and Ninja #154

Merged
merged 2 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,41 @@ endif()
include_directories(
.
"protocols/"
"subprojects/sdbus-cpp/include/"
)

# configure
set(LIBEXECDIR ${CMAKE_INSTALL_LIBEXECDIR})
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)

set(CMAKE_CXX_STANDARD 23)
add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value
-Wno-missing-field-initializers -Wno-narrowing -Wno-pointer-arith
-fpermissive -Wno-address-of-temporary)
-fpermissive)

# dependencies
message(STATUS "Checking deps...")
add_subdirectory(hyprland-share-picker)

find_package(Threads REQUIRED)

find_package(PkgConfig REQUIRED)
pkg_check_modules(deps REQUIRED IMPORTED_TARGET wayland-client wayland-protocols libpipewire-0.3 libspa-0.2 libdrm gbm hyprlang>=0.2.0)

# check whether we can find sdbus-c++ through pkg-config
pkg_check_modules(SDBUS IMPORTED_TARGET sdbus-c++)
if(NOT SDBUS_FOUND)
include_directories("subprojects/sdbus-cpp/include/")
add_subdirectory(subprojects/sdbus-cpp)
endif()

# 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()

file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp")
add_executable(xdg-desktop-portal-hyprland ${SRCFILES})
target_link_libraries(xdg-desktop-portal-hyprland PRIVATE rt sdbus-c++ Threads::Threads PkgConfig::deps)
Expand Down Expand Up @@ -79,7 +92,14 @@ 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)
protocol("subprojects/hyprland-protocols/protocols/hyprland-global-shortcuts-v1.xml" "hyprland-global-shortcuts-v1" true)
protocol("subprojects/hyprland-protocols/protocols/hyprland-toplevel-export-v1.xml" "hyprland-toplevel-export-v1" true)
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
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")
23 changes: 0 additions & 23 deletions Makefile

This file was deleted.

28 changes: 24 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
# xdg-desktop-portal-hyprland
An [XDG Desktop Portal](https://github.com/flatpak/xdg-desktop-portal) backend for Hyprland.

An [XDG Desktop Portal](https://github.com/flatpak/xdg-desktop-portal) backend
for Hyprland.

## Installing

First, make sure to install the required dependencies:

```
gbm
hyprland-protocols
hyprlang
libdrm
libpipewire-0.3
libspa-0.2
sdbus-cpp
wayland-client
wayland-protocols
```

Then run the build and install command:

```sh
git clone --recursive https://github.com/hyprwm/xdg-desktop-portal-hyprland
cd xdg-desktop-portal-hyprland/
make all
sudo make install
cmake -DCMAKE_INSTALL_LIBEXECDIR=/usr/lib -B build
cmake --install /usr
```

## Running, FAQs, etc.
See [the Hyprland wiki](https://wiki.hyprland.org/Useful-Utilities/Hyprland-desktop-portal/)

See
[the Hyprland wiki](https://wiki.hyprland.org/Useful-Utilities/Hyprland-desktop-portal)
2 changes: 1 addition & 1 deletion contrib/systemd/xdg-desktop-portal-hyprland.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ ConditionEnvironment=WAYLAND_DISPLAY
[Service]
Type=dbus
BusName=org.freedesktop.impl.portal.desktop.hyprland
ExecStart=@libexecdir@/xdg-desktop-portal-hyprland
ExecStart=@LIBEXECDIR@/xdg-desktop-portal-hyprland
Restart=on-failure
Slice=session.slice
31 changes: 13 additions & 18 deletions nix/default.nix
Original file line number Diff line number Diff line change
@@ -1,55 +1,50 @@
{
lib,
stdenv,
cmake,
makeWrapper,
meson,
ninja,
pkg-config,
wayland-scanner,
wrapQtAppsHook,
hyprland,
hyprland-protocols,
hyprlang,
libdrm,
mesa,
pipewire,
sdbus-cpp,
systemd,
wayland-protocols,
wayland-scanner,
qtbase,
qttools,
qtwayland,
wrapQtAppsHook,
hyprland,
sdbus-cpp,
slurp,
hyprland-protocols,
systemd,
wayland,
wayland-protocols,
debug ? false,
version ? "git",
}:
stdenv.mkDerivation {
pname = "xdg-desktop-portal-hyprland";
pname = "xdg-desktop-portal-hyprland" + lib.optionalString debug "-debug";
inherit version;

src = ../.;

mesonBuildType =
if debug
then "debug"
else "release";
cmakeFlags = lib.optional debug (lib.strings.cmakeFeature "CMAKE_BUILD_TYPE" "DEBUG");

nativeBuildInputs = [
meson
ninja
cmake
makeWrapper
pkg-config
wayland-scanner
makeWrapper
wrapQtAppsHook
];

buildInputs = [
hyprland-protocols
hyprlang
libdrm
mesa
pipewire
hyprlang
qtbase
qttools
qtwayland
Expand Down
2 changes: 1 addition & 1 deletion org.freedesktop.impl.portal.desktop.hyprland.service.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[D-BUS Service]
Name=org.freedesktop.impl.portal.desktop.hyprland
Exec=@libexecdir@/xdg-desktop-portal-hyprland
Exec=@LIBEXECDIR@/xdg-desktop-portal-hyprland
SystemdService=xdg-desktop-portal-hyprland.service
Loading