2025-01-11 17:38:18 +01:00
|
|
|
cmake_minimum_required(VERSION 3.27)
|
2024-02-19 00:08:03 +01:00
|
|
|
|
2024-07-18 19:45:42 +02:00
|
|
|
file(READ "${CMAKE_SOURCE_DIR}/VERSION" VER_RAW)
|
|
|
|
string(STRIP ${VER_RAW} VERSION)
|
2024-02-19 00:08:03 +01:00
|
|
|
|
2024-07-18 19:46:31 +02:00
|
|
|
project(
|
|
|
|
hyprlock
|
|
|
|
DESCRIPTION "A gpu-accelerated screen lock for Hyprland"
|
|
|
|
VERSION ${VERSION})
|
2024-02-19 00:08:03 +01:00
|
|
|
|
|
|
|
set(CMAKE_MESSAGE_LOG_LEVEL "STATUS")
|
2024-05-21 00:00:28 +02:00
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
|
2024-02-19 00:08:03 +01:00
|
|
|
|
|
|
|
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
|
2024-07-18 19:46:31 +02:00
|
|
|
message(STATUS "Configuring hyprlock in Debug with CMake")
|
|
|
|
add_compile_definitions(HYPRLAND_DEBUG)
|
2024-02-19 00:08:03 +01:00
|
|
|
else()
|
2024-07-18 19:46:31 +02:00
|
|
|
add_compile_options(-O3)
|
|
|
|
message(STATUS "Configuring hyprlock in Release with CMake")
|
2024-02-19 00:08:03 +01:00
|
|
|
endif()
|
|
|
|
|
2024-07-18 19:46:31 +02:00
|
|
|
include_directories(. "protocols/")
|
2024-02-19 00:08:03 +01:00
|
|
|
|
2024-03-02 00:49:44 +01:00
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
2024-02-19 00:08:03 +01:00
|
|
|
# configure
|
|
|
|
set(CMAKE_CXX_STANDARD 23)
|
|
|
|
add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value
|
2024-07-18 19:46:31 +02:00
|
|
|
-Wno-missing-field-initializers -Wno-narrowing)
|
2024-05-21 00:00:28 +02:00
|
|
|
|
2024-12-20 19:41:06 +01:00
|
|
|
# get git commit
|
|
|
|
execute_process(
|
|
|
|
OUTPUT_VARIABLE GIT_SHORT_HASH
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
COMMAND git rev-parse --short HEAD
|
|
|
|
)
|
|
|
|
|
|
|
|
# get git commit of v$VERSION
|
|
|
|
execute_process(
|
|
|
|
OUTPUT_VARIABLE GIT_TAG_SHORT_HASH
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
COMMAND git rev-parse --short v${VERSION}
|
|
|
|
)
|
|
|
|
|
|
|
|
add_compile_definitions(HYPRLOCK_VERSION="${VERSION}")
|
|
|
|
add_compile_definitions(HYPRLOCK_COMMIT="${GIT_SHORT_HASH}")
|
|
|
|
add_compile_definitions(HYPRLOCK_VERSION_COMMIT="${GIT_TAG_SHORT_HASH}")
|
|
|
|
|
2024-05-21 00:00:28 +02:00
|
|
|
# position independent build: __FILE__
|
|
|
|
add_compile_options(-fmacro-prefix-map=${CMAKE_SOURCE_DIR}/=)
|
2024-02-19 00:08:03 +01:00
|
|
|
|
|
|
|
# dependencies
|
|
|
|
message(STATUS "Checking deps...")
|
|
|
|
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
find_package(PkgConfig REQUIRED)
|
2025-01-11 17:38:18 +01:00
|
|
|
find_package(OpenGL REQUIRED COMPONENTS EGL GLES3)
|
2024-12-29 19:36:08 +01:00
|
|
|
find_package(hyprwayland-scanner 0.4.4 REQUIRED)
|
2024-07-18 19:46:31 +02:00
|
|
|
pkg_check_modules(
|
|
|
|
deps
|
|
|
|
REQUIRED
|
|
|
|
IMPORTED_TARGET
|
|
|
|
wayland-client
|
|
|
|
wayland-protocols
|
|
|
|
wayland-egl
|
|
|
|
hyprlang>=0.4.0
|
|
|
|
egl
|
|
|
|
xkbcommon
|
|
|
|
libjpeg
|
|
|
|
libwebp
|
|
|
|
libmagic
|
|
|
|
cairo
|
|
|
|
pangocairo
|
|
|
|
libdrm
|
|
|
|
gbm
|
2025-01-06 13:34:21 +01:00
|
|
|
hyprutils>=0.3.3
|
2024-11-28 17:43:11 +01:00
|
|
|
sdbus-c++>=2.0.0
|
|
|
|
hyprgraphics)
|
2024-02-19 00:08:03 +01:00
|
|
|
|
|
|
|
file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp")
|
|
|
|
add_executable(hyprlock ${SRCFILES})
|
2024-07-18 19:46:31 +02:00
|
|
|
target_link_libraries(hyprlock PRIVATE pam rt Threads::Threads PkgConfig::deps
|
2025-01-11 17:38:18 +01:00
|
|
|
OpenGL::EGL OpenGL::GLES3)
|
2024-02-19 00:08:03 +01:00
|
|
|
|
|
|
|
# protocols
|
2024-12-29 19:36:08 +01:00
|
|
|
pkg_get_variable(WAYLAND_PROTOCOLS_DIR wayland-protocols pkgdatadir)
|
2024-02-19 00:08:03 +01:00
|
|
|
message(STATUS "Found wayland-protocols at ${WAYLAND_PROTOCOLS_DIR}")
|
2024-12-29 19:36:08 +01:00
|
|
|
pkg_get_variable(WAYLAND_SCANNER_PKGDATA_DIR wayland-scanner pkgdatadir)
|
|
|
|
message(
|
|
|
|
STATUS "Found wayland-scanner pkgdatadir at ${WAYLAND_SCANNER_PKGDATA_DIR}")
|
2024-02-19 00:08:03 +01:00
|
|
|
|
2024-12-29 19:36:08 +01:00
|
|
|
function(protocolnew protoPath protoName external)
|
2024-07-18 19:46:31 +02:00
|
|
|
if(external)
|
2024-12-29 19:36:08 +01:00
|
|
|
set(path ${CMAKE_SOURCE_DIR}/${protoPath})
|
2024-07-18 19:46:31 +02:00
|
|
|
else()
|
2024-12-29 19:36:08 +01:00
|
|
|
set(path ${WAYLAND_PROTOCOLS_DIR}/${protoPath})
|
2024-07-18 19:46:31 +02:00
|
|
|
endif()
|
2024-12-29 19:36:08 +01:00
|
|
|
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/
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
|
|
|
target_sources(hyprlock PRIVATE protocols/${protoName}.cpp
|
|
|
|
protocols/${protoName}.hpp)
|
|
|
|
endfunction()
|
|
|
|
function(protocolWayland)
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${CMAKE_SOURCE_DIR}/protocols/wayland.cpp
|
|
|
|
${CMAKE_SOURCE_DIR}/protocols/wayland.hpp
|
|
|
|
COMMAND hyprwayland-scanner --wayland-enums --client
|
|
|
|
${WAYLAND_SCANNER_PKGDATA_DIR}/wayland.xml ${CMAKE_SOURCE_DIR}/protocols/
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
|
|
|
target_sources(hyprlock PRIVATE protocols/wayland.cpp protocols/wayland.hpp)
|
2024-02-19 00:08:03 +01:00
|
|
|
endfunction()
|
|
|
|
|
2024-07-18 19:46:31 +02:00
|
|
|
make_directory(${CMAKE_SOURCE_DIR}/protocols) # we don't ship any custom ones so
|
|
|
|
# the dir won't be there
|
2024-12-29 19:36:08 +01:00
|
|
|
|
|
|
|
protocolwayland()
|
|
|
|
|
|
|
|
protocolnew("protocols" "wlr-screencopy-unstable-v1" true)
|
|
|
|
protocolnew("staging/ext-session-lock" "ext-session-lock-v1" false)
|
|
|
|
protocolnew("stable/linux-dmabuf" "linux-dmabuf-v1" false)
|
|
|
|
protocolnew("staging/fractional-scale" "fractional-scale-v1" false)
|
|
|
|
protocolnew("stable/viewporter" "viewporter" false)
|
|
|
|
protocolnew("staging/cursor-shape" "cursor-shape-v1" false)
|
|
|
|
protocolnew("stable/tablet" "tablet-v2" false)
|
2024-02-19 00:08:03 +01:00
|
|
|
|
|
|
|
# Installation
|
|
|
|
install(TARGETS hyprlock)
|
2024-03-02 00:49:44 +01:00
|
|
|
|
2024-07-18 19:46:31 +02:00
|
|
|
install(FILES ${CMAKE_SOURCE_DIR}/pam/hyprlock
|
|
|
|
DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}/pam.d)
|
2024-08-02 20:34:44 +02:00
|
|
|
|
|
|
|
install(
|
|
|
|
FILES ${CMAKE_SOURCE_DIR}/assets/example.conf
|
|
|
|
DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/hypr
|
|
|
|
RENAME hyprlock.conf)
|