mirror of
https://github.com/hyprwm/hyprlock.git
synced 2024-11-16 23:05:58 +01:00
CMake: fmt
This commit is contained in:
parent
cac93f67e8
commit
a29012cbbd
1 changed files with 70 additions and 42 deletions
112
CMakeLists.txt
112
CMakeLists.txt
|
@ -3,33 +3,30 @@ cmake_minimum_required(VERSION 3.19)
|
||||||
file(READ "${CMAKE_SOURCE_DIR}/VERSION" VER_RAW)
|
file(READ "${CMAKE_SOURCE_DIR}/VERSION" VER_RAW)
|
||||||
string(STRIP ${VER_RAW} VERSION)
|
string(STRIP ${VER_RAW} VERSION)
|
||||||
|
|
||||||
project(hyprlock
|
project(
|
||||||
DESCRIPTION "A gpu-accelerated screen lock for Hyprland"
|
hyprlock
|
||||||
VERSION ${VERSION}
|
DESCRIPTION "A gpu-accelerated screen lock for Hyprland"
|
||||||
)
|
VERSION ${VERSION})
|
||||||
|
|
||||||
set(CMAKE_MESSAGE_LOG_LEVEL "STATUS")
|
set(CMAKE_MESSAGE_LOG_LEVEL "STATUS")
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
|
||||||
|
|
||||||
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 hyprlock in Debug with CMake")
|
message(STATUS "Configuring hyprlock in Debug with CMake")
|
||||||
add_compile_definitions(HYPRLAND_DEBUG)
|
add_compile_definitions(HYPRLAND_DEBUG)
|
||||||
else()
|
else()
|
||||||
add_compile_options(-O3)
|
add_compile_options(-O3)
|
||||||
message(STATUS "Configuring hyprlock in Release with CMake")
|
message(STATUS "Configuring hyprlock in Release with CMake")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include_directories(
|
include_directories(. "protocols/")
|
||||||
.
|
|
||||||
"protocols/"
|
|
||||||
)
|
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
# configure
|
# configure
|
||||||
set(CMAKE_CXX_STANDARD 23)
|
set(CMAKE_CXX_STANDARD 23)
|
||||||
add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value
|
add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value
|
||||||
-Wno-missing-field-initializers -Wno-narrowing)
|
-Wno-missing-field-initializers -Wno-narrowing)
|
||||||
|
|
||||||
# position independent build: __FILE__
|
# position independent build: __FILE__
|
||||||
add_compile_options(-fmacro-prefix-map=${CMAKE_SOURCE_DIR}/=)
|
add_compile_options(-fmacro-prefix-map=${CMAKE_SOURCE_DIR}/=)
|
||||||
|
@ -40,52 +37,83 @@ message(STATUS "Checking deps...")
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
find_package(OpenGL 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)
|
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)
|
||||||
|
|
||||||
file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp")
|
file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp")
|
||||||
add_executable(hyprlock ${SRCFILES})
|
add_executable(hyprlock ${SRCFILES})
|
||||||
target_link_libraries(hyprlock PRIVATE pam rt Threads::Threads PkgConfig::deps OpenGL::EGL OpenGL::GL)
|
target_link_libraries(hyprlock PRIVATE pam rt Threads::Threads PkgConfig::deps
|
||||||
|
OpenGL::EGL OpenGL::GL)
|
||||||
|
|
||||||
# protocols
|
# protocols
|
||||||
find_program(WaylandScanner NAMES wayland-scanner)
|
find_program(WaylandScanner NAMES wayland-scanner)
|
||||||
message(STATUS "Found WaylandScanner at ${WaylandScanner}")
|
message(STATUS "Found WaylandScanner at ${WaylandScanner}")
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND pkg-config --variable=pkgdatadir wayland-protocols
|
COMMAND pkg-config --variable=pkgdatadir wayland-protocols
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
OUTPUT_VARIABLE WAYLAND_PROTOCOLS_DIR
|
OUTPUT_VARIABLE WAYLAND_PROTOCOLS_DIR
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
message(STATUS "Found wayland-protocols at ${WAYLAND_PROTOCOLS_DIR}")
|
message(STATUS "Found wayland-protocols at ${WAYLAND_PROTOCOLS_DIR}")
|
||||||
|
|
||||||
function(protocol protoPath protoName external)
|
function(protocol protoPath protoName external)
|
||||||
if (external)
|
if(external)
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND ${WaylandScanner} client-header ${protoPath} protocols/${protoName}-protocol.h
|
COMMAND ${WaylandScanner} client-header ${protoPath}
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
protocols/${protoName}-protocol.h
|
||||||
execute_process(
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||||
COMMAND ${WaylandScanner} private-code ${protoPath} protocols/${protoName}-protocol.c
|
execute_process(
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
COMMAND ${WaylandScanner} private-code ${protoPath}
|
||||||
target_sources(hyprlock PRIVATE protocols/${protoName}-protocol.c)
|
protocols/${protoName}-protocol.c
|
||||||
else()
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||||
execute_process(
|
target_sources(hyprlock PRIVATE protocols/${protoName}-protocol.c)
|
||||||
COMMAND ${WaylandScanner} client-header ${WAYLAND_PROTOCOLS_DIR}/${protoPath} protocols/${protoName}-protocol.h
|
else()
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
execute_process(
|
||||||
execute_process(
|
COMMAND
|
||||||
COMMAND ${WaylandScanner} private-code ${WAYLAND_PROTOCOLS_DIR}/${protoPath} protocols/${protoName}-protocol.c
|
${WaylandScanner} client-header ${WAYLAND_PROTOCOLS_DIR}/${protoPath}
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
protocols/${protoName}-protocol.h
|
||||||
target_sources(hyprlock PRIVATE protocols/${protoName}-protocol.c)
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||||
endif()
|
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()
|
endfunction()
|
||||||
|
|
||||||
make_directory(${CMAKE_SOURCE_DIR}/protocols) # we don't ship any custom ones so the dir won't be there
|
make_directory(${CMAKE_SOURCE_DIR}/protocols) # we don't ship any custom ones so
|
||||||
protocol("staging/ext-session-lock/ext-session-lock-v1.xml" "ext-session-lock-v1" false)
|
# 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("staging/cursor-shape/cursor-shape-v1.xml" "cursor-shape-v1" false)
|
||||||
protocol("unstable/tablet/tablet-unstable-v2.xml" "tablet-unstable-v2" 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("staging/fractional-scale/fractional-scale-v1.xml"
|
||||||
|
"fractional-scale-v1" false)
|
||||||
protocol("stable/viewporter/viewporter.xml" "viewporter" false)
|
protocol("stable/viewporter/viewporter.xml" "viewporter" false)
|
||||||
protocol("protocols/wlr-screencopy-unstable-v1.xml" "wlr-screencopy-unstable-v1" true)
|
protocol("protocols/wlr-screencopy-unstable-v1.xml"
|
||||||
protocol("unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml" "linux-dmabuf-unstable-v1" false)
|
"wlr-screencopy-unstable-v1" true)
|
||||||
|
protocol("unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml"
|
||||||
|
"linux-dmabuf-unstable-v1" false)
|
||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
install(TARGETS hyprlock)
|
install(TARGETS hyprlock)
|
||||||
|
|
||||||
install(FILES ${CMAKE_SOURCE_DIR}/pam/hyprlock DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}/pam.d)
|
install(FILES ${CMAKE_SOURCE_DIR}/pam/hyprlock
|
||||||
|
DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}/pam.d)
|
||||||
|
|
Loading…
Reference in a new issue