hyprutils/CMakeLists.txt

78 lines
2.4 KiB
Text
Raw Permalink Normal View History

2024-06-08 19:37:15 +02:00
cmake_minimum_required(VERSION 3.19)
2024-07-18 20:34:06 +03: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 20:34:31 +03: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)
add_compile_options(
-Wall
-Wextra
-Wpedantic
-Wno-unused-parameter
-Wno-unused-value
-Wno-missing-field-initializers
-Wno-narrowing
-Wno-pointer-arith)
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
2024-06-08 19:37:15 +02:00
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
2024-07-18 20:34:31 +03:00
message(STATUS "Configuring hyprutils in Debug")
add_compile_definitions(HYPRLAND_DEBUG)
2024-06-08 19:37:15 +02:00
else()
2024-07-18 20:34:31 +03: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 20:34:31 +03:00
target_include_directories(
hyprutils
PUBLIC "./include"
PRIVATE "./src")
set_target_properties(hyprutils PROPERTIES VERSION ${hyprutils_VERSION}
2025-10-05 00:11:09 +01:00
SOVERSION 9)
2024-06-18 14:10:18 +02:00
target_link_libraries(hyprutils PkgConfig::deps)
2024-06-08 19:37:15 +02:00
if(BUILD_TESTING)
# GTest
find_package(GTest CONFIG REQUIRED)
include(GoogleTest)
2025-11-21 16:22:40 +00:00
file(GLOB_RECURSE TESTFILES CONFIGURE_DEPENDS "tests/*.cpp")
add_executable(hyprutils_tests ${TESTFILES})
target_compile_options(hyprutils_tests PRIVATE --coverage)
target_link_options(hyprutils_tests PRIVATE --coverage)
target_include_directories(
2025-11-21 16:22:40 +00:00
hyprutils_tests
PUBLIC "./include"
PRIVATE "./src" "./src/include" "./protocols" "${CMAKE_BINARY_DIR}")
2025-11-21 16:22:40 +00:00
target_link_libraries(hyprutils_tests PRIVATE hyprutils GTest::gtest_main
PkgConfig::deps)
2025-11-21 16:22:40 +00:00
gtest_discover_tests(hyprutils_tests)
endif()
2024-06-08 19:37:15 +02:00
# Installation
install(TARGETS hyprutils)
install(DIRECTORY "include/hyprutils" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
2024-07-18 20:34:31 +03:00
install(FILES ${CMAKE_BINARY_DIR}/hyprutils.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)