2024-06-08 19:37:15 +02:00
|
|
|
cmake_minimum_required(VERSION 3.19)
|
|
|
|
|
2024-07-18 19:34:06 +02:00
|
|
|
file(READ "${CMAKE_SOURCE_DIR}/VERSION" VER_RAW)
|
|
|
|
string(STRIP ${VER_RAW} HYPRUTILS_VERSION)
|
2024-06-08 19:37:15 +02:00
|
|
|
add_compile_definitions(HYPRUTILS_VERSION="${HYPRUTILS_VERSION}")
|
|
|
|
|
2024-07-18 19:34:31 +02:00
|
|
|
project(
|
|
|
|
hyprutils
|
|
|
|
VERSION ${HYPRUTILS_VERSION}
|
|
|
|
DESCRIPTION "Small C++ library for utilities used across the Hypr* ecosystem")
|
2024-06-08 19:37:15 +02:00
|
|
|
|
|
|
|
include(CTest)
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
|
|
|
set(PREFIX ${CMAKE_INSTALL_PREFIX})
|
|
|
|
set(INCLUDE ${CMAKE_INSTALL_FULL_INCLUDEDIR})
|
|
|
|
set(LIBDIR ${CMAKE_INSTALL_FULL_LIBDIR})
|
|
|
|
|
|
|
|
configure_file(hyprutils.pc.in hyprutils.pc @ONLY)
|
|
|
|
|
|
|
|
set(CMAKE_CXX_STANDARD 23)
|
|
|
|
|
|
|
|
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
|
2024-07-18 19:34:31 +02:00
|
|
|
message(STATUS "Configuring hyprutils in Debug")
|
|
|
|
add_compile_definitions(HYPRLAND_DEBUG)
|
2024-06-08 19:37:15 +02:00
|
|
|
else()
|
2024-07-18 19:34:31 +02:00
|
|
|
add_compile_options(-O3)
|
|
|
|
message(STATUS "Configuring hyprutils in Release")
|
2024-06-08 19:37:15 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp" "include/*.hpp")
|
2024-06-08 19:40:52 +02:00
|
|
|
file(GLOB_RECURSE PUBLIC_HEADERS CONFIGURE_DEPENDS "include/*.hpp")
|
2024-06-08 19:37:15 +02:00
|
|
|
|
2024-06-18 14:10:18 +02:00
|
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
pkg_check_modules(deps REQUIRED IMPORTED_TARGET pixman-1)
|
|
|
|
|
2024-06-08 19:37:15 +02:00
|
|
|
add_library(hyprutils SHARED ${SRCFILES})
|
2024-07-18 19:34:31 +02:00
|
|
|
target_include_directories(
|
|
|
|
hyprutils
|
|
|
|
PUBLIC "./include"
|
|
|
|
PRIVATE "./src")
|
|
|
|
set_target_properties(hyprutils PROPERTIES VERSION ${hyprutils_VERSION}
|
|
|
|
SOVERSION 1)
|
2024-06-18 14:10:18 +02:00
|
|
|
target_link_libraries(hyprutils PkgConfig::deps)
|
2024-06-08 19:37:15 +02:00
|
|
|
|
|
|
|
# tests
|
|
|
|
add_custom_target(tests)
|
|
|
|
|
|
|
|
add_executable(hyprutils_memory "tests/memory.cpp")
|
2024-06-18 14:10:18 +02:00
|
|
|
target_link_libraries(hyprutils_memory PRIVATE hyprutils PkgConfig::deps)
|
2024-07-18 19:34:31 +02:00
|
|
|
add_test(
|
|
|
|
NAME "Memory"
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests
|
|
|
|
COMMAND hyprutils_memory "memory")
|
2024-06-08 19:37:15 +02:00
|
|
|
add_dependencies(tests hyprutils_memory)
|
|
|
|
|
|
|
|
add_executable(hyprutils_string "tests/string.cpp")
|
2024-06-18 14:10:18 +02:00
|
|
|
target_link_libraries(hyprutils_string PRIVATE hyprutils PkgConfig::deps)
|
2024-07-18 19:34:31 +02:00
|
|
|
add_test(
|
|
|
|
NAME "String"
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests
|
|
|
|
COMMAND hyprutils_string "string")
|
2024-06-08 19:37:15 +02:00
|
|
|
add_dependencies(tests hyprutils_string)
|
|
|
|
|
|
|
|
add_executable(hyprutils_signal "tests/signal.cpp")
|
2024-06-18 14:10:18 +02:00
|
|
|
target_link_libraries(hyprutils_signal PRIVATE hyprutils PkgConfig::deps)
|
2024-07-18 19:34:31 +02:00
|
|
|
add_test(
|
|
|
|
NAME "Signal"
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests
|
|
|
|
COMMAND hyprutils_signal "signal")
|
2024-06-08 19:37:15 +02:00
|
|
|
add_dependencies(tests hyprutils_signal)
|
|
|
|
|
2024-06-18 14:10:18 +02:00
|
|
|
add_executable(hyprutils_math "tests/math.cpp")
|
|
|
|
target_link_libraries(hyprutils_math PRIVATE hyprutils PkgConfig::deps)
|
2024-07-18 19:34:31 +02:00
|
|
|
add_test(
|
|
|
|
NAME "Math"
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests
|
|
|
|
COMMAND hyprutils_math "math")
|
2024-06-18 14:10:18 +02:00
|
|
|
add_dependencies(tests hyprutils_math)
|
|
|
|
|
2024-10-14 23:26:41 +02:00
|
|
|
add_executable(hyprutils_os "tests/os.cpp")
|
|
|
|
target_link_libraries(hyprutils_os PRIVATE hyprutils PkgConfig::deps)
|
|
|
|
add_test(
|
|
|
|
NAME "OS"
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests
|
|
|
|
COMMAND hyprutils_os "os")
|
|
|
|
add_dependencies(tests hyprutils_os)
|
|
|
|
|
2024-11-21 16:26:34 +01:00
|
|
|
add_executable(hyprutils_filedescriptor "tests/filedescriptor.cpp")
|
|
|
|
target_link_libraries(hyprutils_filedescriptor PRIVATE hyprutils PkgConfig::deps)
|
|
|
|
add_test(
|
|
|
|
NAME "Filedescriptor"
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests
|
|
|
|
COMMAND hyprutils_filedescriptor "filedescriptor")
|
|
|
|
add_dependencies(tests hyprutils_filedescriptor)
|
|
|
|
|
2024-06-08 19:37:15 +02:00
|
|
|
# Installation
|
|
|
|
install(TARGETS hyprutils)
|
|
|
|
install(DIRECTORY "include/hyprutils" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
2024-07-18 19:34:31 +02:00
|
|
|
install(FILES ${CMAKE_BINARY_DIR}/hyprutils.pc
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|