2023-12-28 20:38:01 +01:00
|
|
|
cmake_minimum_required(VERSION 3.19)
|
2023-12-31 14:41:22 +01:00
|
|
|
|
2024-05-23 12:00:09 +02:00
|
|
|
set(HYPRLANG_VERSION "0.5.2")
|
2023-12-31 14:41:22 +01:00
|
|
|
|
2023-12-28 20:38:01 +01:00
|
|
|
project(hyprlang
|
2023-12-31 14:41:22 +01:00
|
|
|
VERSION ${HYPRLANG_VERSION}
|
2023-12-28 20:38:01 +01:00
|
|
|
DESCRIPTION "A library to parse hypr config files"
|
|
|
|
)
|
|
|
|
|
|
|
|
include(CTest)
|
2024-01-04 11:41:03 +01:00
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
|
|
|
set(PREFIX ${CMAKE_INSTALL_PREFIX})
|
|
|
|
set(INCLUDE ${CMAKE_INSTALL_FULL_INCLUDEDIR})
|
2024-01-09 10:14:50 +01:00
|
|
|
set(LIBDIR ${CMAKE_INSTALL_FULL_LIBDIR})
|
2024-01-04 11:41:03 +01:00
|
|
|
|
|
|
|
configure_file(hyprlang.pc.in hyprlang.pc @ONLY)
|
2023-12-28 20:38:01 +01:00
|
|
|
|
2024-03-07 02:41:15 +01:00
|
|
|
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
|
|
|
|
message(STATUS "Configuring hyprlang in Debug")
|
|
|
|
add_compile_definitions(HYPRLAND_DEBUG)
|
|
|
|
else()
|
|
|
|
add_compile_options(-O3)
|
|
|
|
message(STATUS "Configuring hyprlang in Release")
|
|
|
|
endif()
|
|
|
|
|
2024-03-08 17:15:01 +01:00
|
|
|
add_compile_definitions(HYPRLANG_INTERNAL)
|
|
|
|
|
2023-12-28 20:38:01 +01:00
|
|
|
set(CMAKE_CXX_STANDARD 23)
|
|
|
|
|
2024-06-08 23:24:12 +02:00
|
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
pkg_check_modules(deps REQUIRED IMPORTED_TARGET
|
|
|
|
hyprutils>=0.1.1
|
|
|
|
)
|
|
|
|
|
2023-12-28 20:38:01 +01:00
|
|
|
file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp" "include/hyprlang.hpp")
|
|
|
|
|
2023-12-28 21:26:25 +01:00
|
|
|
add_library(hyprlang SHARED ${SRCFILES})
|
2023-12-28 20:38:01 +01:00
|
|
|
target_include_directories( hyprlang
|
|
|
|
PUBLIC "./include"
|
|
|
|
PRIVATE "./src"
|
|
|
|
)
|
2024-01-05 22:27:26 +01:00
|
|
|
set_target_properties(hyprlang PROPERTIES
|
|
|
|
VERSION ${HYPRLANG_VERSION}
|
2024-03-08 17:18:28 +01:00
|
|
|
SOVERSION 2
|
2024-01-05 22:27:26 +01:00
|
|
|
PUBLIC_HEADER include/hyprlang.hpp)
|
2023-12-28 20:38:01 +01:00
|
|
|
|
2024-06-08 23:24:12 +02:00
|
|
|
target_link_libraries(hyprlang PkgConfig::deps)
|
|
|
|
|
2024-02-12 18:23:15 +01:00
|
|
|
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
|
|
# for std::expected.
|
|
|
|
# probably evil. Arch's clang is very outdated tho...
|
|
|
|
target_compile_options(hyprlang PUBLIC -std=gnu++2b -D__cpp_concepts=202002L -Wno-macro-redefined)
|
2024-05-23 11:54:00 +02:00
|
|
|
add_compile_options(-stdlib=libc++)
|
2024-05-23 16:16:17 +02:00
|
|
|
add_link_options(-stdlib=libc++)
|
2024-05-23 11:54:00 +02:00
|
|
|
message(STATUS "Using clang++ to compile hyprlang")
|
2024-02-12 18:23:15 +01:00
|
|
|
endif()
|
|
|
|
|
2023-12-28 22:11:27 +01:00
|
|
|
install(TARGETS hyprlang)
|
2023-12-28 20:38:01 +01:00
|
|
|
|
2023-12-31 16:51:50 +01:00
|
|
|
# tests
|
|
|
|
add_custom_target(tests)
|
|
|
|
|
|
|
|
add_executable(hyprlang_test "tests/parse/main.cpp")
|
2024-06-08 23:24:12 +02:00
|
|
|
target_link_libraries(hyprlang_test PRIVATE hyprlang hyprutils)
|
2024-01-03 14:13:49 +01:00
|
|
|
add_test(NAME "Parsing" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests COMMAND hyprlang_test "parse")
|
2023-12-31 16:51:50 +01:00
|
|
|
add_dependencies(tests hyprlang_test)
|
|
|
|
|
|
|
|
add_executable(hyprlang_fuzz "tests/fuzz/main.cpp")
|
2024-06-08 23:24:12 +02:00
|
|
|
target_link_libraries(hyprlang_fuzz PRIVATE hyprlang hyprutils)
|
2024-01-03 14:13:49 +01:00
|
|
|
add_test(NAME "Fuzz" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests COMMAND hyprlang_fuzz "fuzz")
|
2023-12-31 16:51:50 +01:00
|
|
|
add_dependencies(tests hyprlang_fuzz)
|
2023-12-29 20:04:23 +01:00
|
|
|
|
|
|
|
# Installation
|
|
|
|
install(TARGETS hyprlang
|
2024-01-05 22:41:34 +01:00
|
|
|
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
2024-01-09 09:54:21 +01:00
|
|
|
install(FILES ${CMAKE_BINARY_DIR}/hyprlang.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|