2024-02-17 20:30:11 +01:00
|
|
|
cmake_minimum_required(VERSION 3.19)
|
|
|
|
|
2024-07-18 19:42:35 +02:00
|
|
|
file(READ "${CMAKE_SOURCE_DIR}/VERSION" VER_RAW)
|
|
|
|
string(STRIP ${VER_RAW} VERSION)
|
2024-02-17 20:30:11 +01:00
|
|
|
|
2024-07-18 19:43:28 +02:00
|
|
|
project(
|
|
|
|
hypridle
|
|
|
|
DESCRIPTION "An idle management daemon for Hyprland"
|
|
|
|
VERSION ${VERSION})
|
2024-02-17 20:30:11 +01:00
|
|
|
|
|
|
|
set(CMAKE_MESSAGE_LOG_LEVEL "STATUS")
|
|
|
|
|
|
|
|
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
|
2024-07-18 19:43:28 +02:00
|
|
|
message(STATUS "Configuring hypridle in Debug with CMake")
|
|
|
|
add_compile_definitions(HYPRLAND_DEBUG)
|
2024-02-17 20:30:11 +01:00
|
|
|
else()
|
2024-07-18 19:43:28 +02:00
|
|
|
add_compile_options(-O3)
|
|
|
|
message(STATUS "Configuring hypridle in Release with CMake")
|
2024-02-17 20:30:11 +01:00
|
|
|
endif()
|
|
|
|
|
2024-07-18 19:43:28 +02:00
|
|
|
include_directories(. "protocols/")
|
2024-02-17 20:30:11 +01:00
|
|
|
|
|
|
|
# configure
|
|
|
|
set(CMAKE_CXX_STANDARD 23)
|
|
|
|
add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value
|
2024-07-18 19:43:28 +02:00
|
|
|
-Wno-missing-field-initializers -Wno-narrowing)
|
2024-04-12 20:16:49 +02:00
|
|
|
configure_file(systemd/hypridle.service.in systemd/hypridle.service @ONLY)
|
2024-02-17 20:30:11 +01:00
|
|
|
|
|
|
|
# dependencies
|
|
|
|
message(STATUS "Checking deps...")
|
|
|
|
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
find_package(PkgConfig REQUIRED)
|
2024-07-18 19:43:28 +02:00
|
|
|
pkg_check_modules(
|
|
|
|
deps
|
|
|
|
REQUIRED
|
|
|
|
IMPORTED_TARGET
|
|
|
|
wayland-client
|
|
|
|
wayland-protocols
|
|
|
|
hyprlang>=0.4.0
|
|
|
|
hyprutils>=0.2.0
|
|
|
|
sdbus-c++)
|
2024-02-17 20:30:11 +01:00
|
|
|
|
|
|
|
file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp")
|
|
|
|
add_executable(hypridle ${SRCFILES})
|
|
|
|
target_link_libraries(hypridle PRIVATE rt Threads::Threads PkgConfig::deps)
|
|
|
|
|
|
|
|
# protocols
|
|
|
|
find_program(WaylandScanner NAMES wayland-scanner)
|
|
|
|
message(STATUS "Found WaylandScanner at ${WaylandScanner}")
|
|
|
|
execute_process(
|
2024-07-18 19:43:28 +02:00
|
|
|
COMMAND pkg-config --variable=pkgdatadir wayland-protocols
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
|
|
OUTPUT_VARIABLE WAYLAND_PROTOCOLS_DIR
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
2024-02-17 20:30:11 +01:00
|
|
|
message(STATUS "Found wayland-protocols at ${WAYLAND_PROTOCOLS_DIR}")
|
|
|
|
|
|
|
|
function(protocol protoPath protoName external)
|
2024-07-18 19:43:28 +02:00
|
|
|
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
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
|
|
|
target_sources(hypridle 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
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
|
|
|
target_sources(hypridle PRIVATE protocols/${protoName}-protocol.c)
|
|
|
|
endif()
|
2024-02-17 20:30:11 +01:00
|
|
|
endfunction()
|
|
|
|
|
2024-07-18 19:43:28 +02:00
|
|
|
make_directory(${CMAKE_SOURCE_DIR}/protocols) # we don't ship any custom ones so
|
|
|
|
# the dir won't be there
|
|
|
|
protocol("staging/ext-idle-notify/ext-idle-notify-v1.xml" "ext-idle-notify-v1"
|
|
|
|
false)
|
2024-02-17 20:30:11 +01:00
|
|
|
|
|
|
|
# Installation
|
|
|
|
install(TARGETS hypridle)
|
2024-07-18 19:43:28 +02:00
|
|
|
install(FILES ${CMAKE_BINARY_DIR}/systemd/hypridle.service
|
|
|
|
DESTINATION "lib/systemd/user")
|