hyprlock/CMakeLists.txt

92 lines
3.6 KiB
CMake
Raw Normal View History

2024-02-19 00:08:03 +01:00
cmake_minimum_required(VERSION 3.19)
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
project(hyprlock
DESCRIPTION "A gpu-accelerated screen lock for Hyprland"
VERSION ${VERSION}
)
set(CMAKE_MESSAGE_LOG_LEVEL "STATUS")
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)
message(STATUS "Configuring hyprlock in Debug with CMake")
add_compile_definitions(HYPRLAND_DEBUG)
else()
add_compile_options(-O3)
message(STATUS "Configuring hyprlock in Release with CMake")
endif()
include_directories(
.
"protocols/"
)
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
-Wno-missing-field-initializers -Wno-narrowing)
# 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)
find_package(OpenGL REQUIRED)
pkg_check_modules(deps REQUIRED IMPORTED_TARGET wayland-client wayland-protocols wayland-egl hyprlang>=0.4.0 egl opengl xkbcommon libjpeg libwebp libmagic cairo pangocairo libdrm gbm hyprutils>=0.2.0)
2024-02-19 00:08:03 +01:00
file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp")
add_executable(hyprlock ${SRCFILES})
core: Unbreak build on FreeBSD (#71) * Add OpenPAM support (used by BSDs except OpenBSD) -- Package 'pam', required by 'virtual:world', not found CMake Error at /usr/local/share/cmake/Modules/FindPkgConfig.cmake:619 (message): The following required packages were not found: - pam src/core/Password.cpp:6:10: fatal error: 'security/pam_misc.h' file not found 6 | #include <security/pam_misc.h> | ^~~~~~~~~~~~~~~~~~~~~ * Add missing headers src/renderer/widgets/IWidget.cpp: In member function 'virtual IWidget::SFormatResult IWidget::formatString(std::string)': src/renderer/widgets/IWidget.cpp:51:41: error: 'getlogin' was not declared in this scope 51 | replaceAll(in, "$USER", std::string{getlogin()}); | ^~~~~~~~ src/renderer/widgets/IWidget.cpp:51:51: error: no matching function for call to 'std::__cxx11::basic_string<char>::basic_string(<brace-enclosed initializer list>)' 51 | replaceAll(in, "$USER", std::string{getlogin()}); | ^ src/renderer/DMAFrame.cpp: In member function 'bool CDMAFrame::onBufferDone()': src/renderer/DMAFrame.cpp:181:17: error: 'close' was not declared in this scope; did you mean 'pclose'? 181 | close(fd[plane_tmp]); | ^~~~~ | pclose src/renderer/DMAFrame.cpp:196:13: error: 'close' was not declared in this scope; did you mean 'pclose'? 196 | close(fd[plane]); | ^~~~~ | pclose src/core/Password.cpp: In lambda function: src/core/Password.cpp:44:31: error: 'strdup' was not declared in this scope 44 | reply->resp = strdup(pass.c_str()); | ^~~~~~ src/core/hyprlock.cpp: In member function 'void CHyprlock::spawnAsync(const std::string&)': src/core/hyprlock.cpp:768:9: error: 'sigemptyset' was not declared in this scope 768 | sigemptyset(&set); | ^~~~~~~~~~~ src/core/hyprlock.cpp:769:21: error: 'SIG_SETMASK' was not declared in this scope 769 | sigprocmask(SIG_SETMASK, &set, NULL); | ^~~~~~~~~~~ src/core/hyprlock.cpp:769:9: error: 'sigprocmask' was not declared in this scope 769 | sigprocmask(SIG_SETMASK, &set, NULL); | ^~~~~~~~~~~
2024-02-23 13:54:14 +01:00
target_link_libraries(hyprlock PRIVATE pam rt Threads::Threads PkgConfig::deps OpenGL::EGL OpenGL::GL)
2024-02-19 00:08:03 +01:00
# protocols
find_program(WaylandScanner NAMES wayland-scanner)
message(STATUS "Found WaylandScanner at ${WaylandScanner}")
execute_process(
COMMAND pkg-config --variable=pkgdatadir wayland-protocols
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE WAYLAND_PROTOCOLS_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Found wayland-protocols at ${WAYLAND_PROTOCOLS_DIR}")
function(protocol protoPath protoName external)
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(hyprlock 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(hyprlock PRIVATE protocols/${protoName}-protocol.c)
endif()
endfunction()
make_directory(${CMAKE_SOURCE_DIR}/protocols) # we don't ship any custom ones so the dir won't be there
protocol("staging/ext-session-lock/ext-session-lock-v1.xml" "ext-session-lock-v1" false)
protocol("staging/cursor-shape/cursor-shape-v1.xml" "cursor-shape-v1" false)
protocol("unstable/tablet/tablet-unstable-v2.xml" "tablet-unstable-v2" false)
protocol("staging/fractional-scale/fractional-scale-v1.xml" "fractional-scale-v1" false)
protocol("stable/viewporter/viewporter.xml" "viewporter" false)
2024-02-21 22:38:37 +01:00
protocol("protocols/wlr-screencopy-unstable-v1.xml" "wlr-screencopy-unstable-v1" true)
protocol("unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml" "linux-dmabuf-unstable-v1" false)
2024-02-19 00:08:03 +01:00
# Installation
install(TARGETS hyprlock)
2024-03-02 00:49:44 +01:00
2024-04-10 23:42:54 +02:00
install(FILES ${CMAKE_SOURCE_DIR}/pam/hyprlock DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}/pam.d)