2024-07-17 17:08:10 +02:00
|
|
|
cmake_minimum_required(VERSION 3.12)
|
2024-07-18 19:52:39 +02:00
|
|
|
|
|
|
|
file(READ "${CMAKE_SOURCE_DIR}/VERSION" VER_RAW)
|
|
|
|
string(STRIP ${VER_RAW} VERSION)
|
|
|
|
|
2024-07-18 19:53:14 +02:00
|
|
|
project(
|
|
|
|
hyprpicker
|
|
|
|
DESCRIPTION "A blazing fast wayland wallpaper utility"
|
|
|
|
VERSION ${VERSION})
|
2022-09-02 18:06:00 +02:00
|
|
|
|
|
|
|
set(CMAKE_MESSAGE_LOG_LEVEL "STATUS")
|
|
|
|
|
2024-09-29 19:24:57 +02:00
|
|
|
add_compile_definitions(HYPRPICKER_VERSION="${VERSION}")
|
|
|
|
|
2022-09-02 18:06:00 +02:00
|
|
|
message(STATUS "Configuring hyprpicker!")
|
|
|
|
|
2024-07-18 19:53:14 +02:00
|
|
|
# Get git info hash and branch
|
2022-09-02 18:06:00 +02:00
|
|
|
execute_process(
|
2024-07-18 19:53:14 +02:00
|
|
|
COMMAND git rev-parse --abbrev-ref HEAD
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
|
|
OUTPUT_VARIABLE GIT_BRANCH
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
2022-09-02 18:06:00 +02:00
|
|
|
|
|
|
|
execute_process(
|
2024-07-18 19:53:14 +02:00
|
|
|
COMMAND git rev-parse HEAD
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
|
|
OUTPUT_VARIABLE GIT_COMMIT_HASH
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
2022-09-02 18:06:00 +02:00
|
|
|
|
|
|
|
execute_process(
|
2024-07-18 19:53:14 +02:00
|
|
|
COMMAND bash -c "git show ${GIT_COMMIT_HASH} | head -n 5 | tail -n 1"
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
|
|
OUTPUT_VARIABLE GIT_COMMIT_MESSAGE
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
2022-09-02 18:06:00 +02:00
|
|
|
|
|
|
|
execute_process(
|
2024-07-18 19:53:14 +02:00
|
|
|
COMMAND bash -c "git diff-index --quiet HEAD -- || echo \"dirty\""
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
|
|
OUTPUT_VARIABLE GIT_DIRTY
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
2022-09-02 18:06:00 +02:00
|
|
|
#
|
|
|
|
|
|
|
|
include_directories(.)
|
2024-06-06 11:49:13 +02:00
|
|
|
set(CMAKE_CXX_STANDARD 23)
|
|
|
|
add_compile_options(-DWLR_USE_UNSTABLE)
|
2024-07-18 19:53:14 +02:00
|
|
|
add_compile_options(
|
|
|
|
-Wall
|
|
|
|
-Wextra
|
|
|
|
-Wno-unused-parameter
|
|
|
|
-Wno-unused-value
|
|
|
|
-Wno-missing-field-initializers
|
|
|
|
-Wno-narrowing
|
|
|
|
-Wno-pointer-arith)
|
2022-09-02 18:06:00 +02:00
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
|
|
|
|
find_package(PkgConfig REQUIRED)
|
2024-07-18 19:53:14 +02:00
|
|
|
pkg_check_modules(
|
|
|
|
deps
|
|
|
|
REQUIRED
|
|
|
|
IMPORTED_TARGET
|
|
|
|
wayland-client
|
|
|
|
wayland-protocols
|
|
|
|
xkbcommon
|
|
|
|
cairo
|
|
|
|
pango
|
|
|
|
pangocairo
|
|
|
|
libjpeg
|
2024-09-26 13:58:43 +02:00
|
|
|
hyprutils>=0.2.0
|
|
|
|
hyprwayland-scanner>=0.4.0)
|
2022-09-02 18:06:00 +02:00
|
|
|
|
|
|
|
file(GLOB_RECURSE SRCFILES "src/*.cpp")
|
|
|
|
|
|
|
|
add_executable(hyprpicker ${SRCFILES})
|
|
|
|
|
2024-09-26 13:58:43 +02:00
|
|
|
pkg_get_variable(WAYLAND_PROTOCOLS_DIR wayland-protocols pkgdatadir)
|
|
|
|
message(STATUS "Found wayland-protocols at ${WAYLAND_PROTOCOLS_DIR}")
|
|
|
|
pkg_get_variable(WAYLAND_SCANNER_DIR wayland-scanner pkgdatadir)
|
|
|
|
message(STATUS "Found wayland-scanner at ${WAYLAND_SCANNER_DIR}")
|
|
|
|
|
|
|
|
function(protocolnew protoPath protoName external)
|
|
|
|
if(external)
|
|
|
|
set(path ${CMAKE_SOURCE_DIR}/${protoPath})
|
|
|
|
else()
|
|
|
|
set(path ${WAYLAND_PROTOCOLS_DIR}/${protoPath})
|
|
|
|
endif()
|
|
|
|
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(hyprpicker 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_DIR}/wayland.xml ${CMAKE_SOURCE_DIR}/protocols/
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
|
|
|
target_sources(hyprpicker PRIVATE protocols/wayland.cpp protocols/wayland.hpp)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
protocolwayland()
|
|
|
|
|
|
|
|
protocolnew("protocols" "wlr-layer-shell-unstable-v1" true)
|
|
|
|
protocolnew("protocols" "wlr-screencopy-unstable-v1" true)
|
|
|
|
protocolnew("stable/linux-dmabuf" "linux-dmabuf-v1" false)
|
|
|
|
protocolnew("staging/fractional-scale" "fractional-scale-v1" false)
|
|
|
|
protocolnew("stable/viewporter" "viewporter" false)
|
|
|
|
protocolnew("stable/xdg-shell" "xdg-shell" false)
|
|
|
|
protocolnew("staging/cursor-shape" "cursor-shape-v1" false)
|
|
|
|
protocolnew("stable/tablet" "tablet-v2" false)
|
2024-03-12 20:50:23 +01:00
|
|
|
|
2024-07-18 19:53:14 +02:00
|
|
|
target_compile_definitions(hyprpicker
|
|
|
|
PRIVATE "-DGIT_COMMIT_HASH=\"${GIT_COMMIT_HASH}\"")
|
2022-09-02 18:06:00 +02:00
|
|
|
target_compile_definitions(hyprpicker PRIVATE "-DGIT_BRANCH=\"${GIT_BRANCH}\"")
|
2024-07-18 19:53:14 +02:00
|
|
|
target_compile_definitions(
|
|
|
|
hyprpicker PRIVATE "-DGIT_COMMIT_MESSAGE=\"${GIT_COMMIT_MESSAGE}\"")
|
2022-09-02 18:06:00 +02:00
|
|
|
target_compile_definitions(hyprpicker PRIVATE "-DGIT_DIRTY=\"${GIT_DIRTY}\"")
|
|
|
|
|
|
|
|
target_link_libraries(hyprpicker rt)
|
|
|
|
|
|
|
|
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
|
|
|
|
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
|
|
|
|
include(CPack)
|
|
|
|
|
|
|
|
target_link_libraries(hyprpicker PkgConfig::deps)
|
|
|
|
|
2024-07-18 19:53:14 +02:00
|
|
|
target_link_libraries(hyprpicker pthread ${CMAKE_THREAD_LIBS_INIT}
|
|
|
|
wayland-cursor)
|
2022-09-02 18:06:00 +02:00
|
|
|
|
2024-07-18 19:53:14 +02:00
|
|
|
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg -no-pie -fno-builtin")
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS
|
|
|
|
"${CMAKE_EXE_LINKER_FLAGS} -pg -no-pie -fno-builtin")
|
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS
|
|
|
|
"${CMAKE_SHARED_LINKER_FLAGS} -pg -no-pie -fno-builtin")
|
|
|
|
endif(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
|
2024-03-12 20:50:23 +01:00
|
|
|
|
2024-08-22 13:26:50 +02:00
|
|
|
if(NOT DEFINED CMAKE_INSTALL_MANDIR)
|
|
|
|
set(CMAKE_INSTALL_MANDIR "${CMAKE_INSTALL_PREFIX}/share/man")
|
|
|
|
endif()
|
|
|
|
|
2024-03-12 20:50:23 +01:00
|
|
|
install(TARGETS hyprpicker)
|
2024-07-18 19:53:14 +02:00
|
|
|
install(FILES ${CMAKE_SOURCE_DIR}/doc/hyprpicker.1
|
|
|
|
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
|