hyprcursor/CMakeLists.txt

122 lines
3.4 KiB
Text
Raw Normal View History

2024-03-07 04:19:38 +01:00
cmake_minimum_required(VERSION 3.19)
2024-07-18 21:18:35 +02:00
file(READ "${CMAKE_SOURCE_DIR}/VERSION" VER_RAW)
string(STRIP ${VER_RAW} HYPRCURSOR_VERSION)
2024-03-11 23:01:46 +01:00
add_compile_definitions(HYPRCURSOR_VERSION="${HYPRCURSOR_VERSION}")
2024-03-07 04:19:38 +01:00
2024-07-18 21:18:46 +02:00
project(
hyprcursor
VERSION ${HYPRCURSOR_VERSION}
DESCRIPTION "A library and toolkit for the Hyprland cursor format")
2024-03-07 04:19:38 +01:00
include(CTest)
include(GNUInstallDirs)
set(PREFIX ${CMAKE_INSTALL_PREFIX})
set(INCLUDE ${CMAKE_INSTALL_FULL_INCLUDEDIR})
set(LIBDIR ${CMAKE_INSTALL_FULL_LIBDIR})
configure_file(hyprcursor.pc.in hyprcursor.pc @ONLY)
set(CMAKE_CXX_STANDARD 23)
find_package(PkgConfig REQUIRED)
2024-07-18 21:18:46 +02:00
pkg_check_modules(
deps
REQUIRED
IMPORTED_TARGET
hyprlang>=0.4.2
libzip
cairo
librsvg-2.0
tomlplusplus)
2024-03-07 04:19:38 +01:00
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
2024-07-18 21:18:46 +02:00
message(STATUS "Configuring hyprcursor in Debug")
add_compile_definitions(HYPRLAND_DEBUG)
2024-03-07 04:19:38 +01:00
else()
2024-07-18 21:18:46 +02:00
add_compile_options(-O3)
message(STATUS "Configuring hyprcursor in Release")
2024-03-07 04:19:38 +01:00
endif()
2024-07-18 21:18:46 +02:00
file(
GLOB_RECURSE
SRCFILES
CONFIGURE_DEPENDS
"libhyprcursor/*.cpp"
"include/hyprcursor/hyprcursor.hpp"
"include/hyprcursor/hyprcursor.h"
"include/hyprcursor/shared.h")
2024-03-07 04:19:38 +01:00
add_library(hyprcursor SHARED ${SRCFILES})
2024-07-18 21:18:46 +02:00
target_include_directories(
hyprcursor
PUBLIC "./include"
PRIVATE "./libhyprcursor")
set_target_properties(
hyprcursor
PROPERTIES VERSION ${hyprcursor_VERSION}
SOVERSION 0
PUBLIC_HEADER include/hyprcursor/hyprcursor.hpp
include/hyprcursor/hyprcursor.h include/hyprcursor/shared.h)
2024-03-07 04:19:38 +01:00
target_link_libraries(hyprcursor PkgConfig::deps)
2024-07-18 21:18:46 +02:00
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# for std::expected. probably evil. Arch's clang is very outdated tho...
target_compile_options(
hyprcursor PUBLIC $<$<COMPILE_LANGUAGE:CXX>:-std=gnu++2b
-D__cpp_concepts=202002L> -Wno-builtin-macro-redefined)
2024-03-07 04:19:38 +01:00
endif()
# hyprcursor-util
2024-07-18 21:18:46 +02:00
file(
GLOB_RECURSE
UTILSRCFILES
CONFIGURE_DEPENDS
"hyprcursor-util/src/*.cpp"
"include/hyprcursor/hyprcursor.hpp"
"include/hyprcursor/hyprcursor.h"
"include/hyprcursor/shared.h")
2024-04-04 18:40:42 +02:00
add_executable(hyprcursor-util ${UTILSRCFILES})
2024-07-18 21:18:46 +02:00
target_include_directories(
hyprcursor-util
PUBLIC "./include"
PRIVATE "./libhyprcursor" "./hyprcursor-util/src")
2024-04-04 18:40:42 +02:00
target_link_libraries(hyprcursor-util PkgConfig::deps hyprcursor)
2024-03-07 04:19:38 +01:00
# tests
add_custom_target(tests)
add_executable(hyprcursor_test1 "tests/full_rendering.cpp")
target_link_libraries(hyprcursor_test1 PRIVATE hyprcursor)
2024-07-18 21:18:46 +02:00
add_test(
NAME "Test libhyprcursor in C++ (full rendering)"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests
COMMAND hyprcursor_test1)
add_dependencies(tests hyprcursor_test1)
2024-03-07 04:19:38 +01:00
add_executable(hyprcursor_test2 "tests/only_metadata.cpp")
target_link_libraries(hyprcursor_test2 PRIVATE hyprcursor)
2024-07-18 21:18:46 +02:00
add_test(
NAME "Test libhyprcursor in C++ (only metadata)"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests
COMMAND hyprcursor_test2)
add_dependencies(tests hyprcursor_test2)
add_executable(hyprcursor_test_c "tests/c_test.c")
2024-03-07 16:10:45 +01:00
target_link_libraries(hyprcursor_test_c PRIVATE hyprcursor)
2024-07-18 21:18:46 +02:00
add_test(
NAME "Test libhyprcursor in C"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests
COMMAND hyprcursor_test_c)
2024-03-07 16:10:45 +01:00
add_dependencies(tests hyprcursor_test_c)
2024-03-07 04:19:38 +01:00
# Installation
2024-04-04 18:40:42 +02:00
install(TARGETS hyprcursor)
install(TARGETS hyprcursor-util)
install(DIRECTORY "include/hyprcursor" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
2024-07-18 21:18:46 +02:00
install(FILES ${CMAKE_BINARY_DIR}/hyprcursor.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)