-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
CMakeLists.txt
87 lines (69 loc) · 2.48 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
cmake_minimum_required(VERSION 3.19)
file(READ "${CMAKE_SOURCE_DIR}/VERSION" VER_RAW)
string(STRIP ${VER_RAW} HYPRLANG_VERSION)
project(
hyprlang
VERSION ${HYPRLANG_VERSION}
DESCRIPTION "A library to parse hypr config files")
include(CTest)
include(GNUInstallDirs)
set(PREFIX ${CMAKE_INSTALL_PREFIX})
set(INCLUDE ${CMAKE_INSTALL_FULL_INCLUDEDIR})
set(LIBDIR ${CMAKE_INSTALL_FULL_LIBDIR})
configure_file(hyprlang.pc.in hyprlang.pc @ONLY)
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()
add_compile_definitions(HYPRLANG_INTERNAL)
set(CMAKE_CXX_STANDARD 23)
find_package(PkgConfig REQUIRED)
pkg_check_modules(deps REQUIRED IMPORTED_TARGET hyprutils>=0.1.1)
file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp" "include/hyprlang.hpp")
add_library(hyprlang SHARED ${SRCFILES})
target_include_directories(
hyprlang
PUBLIC "./include"
PRIVATE "./src")
set_target_properties(
hyprlang
PROPERTIES VERSION ${HYPRLANG_VERSION}
SOVERSION 2
PUBLIC_HEADER include/hyprlang.hpp)
target_link_libraries(hyprlang PkgConfig::deps)
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)
add_compile_options(-stdlib=libc++)
add_link_options(-stdlib=libc++)
message(STATUS "Using clang++ to compile hyprlang")
endif()
add_library(hypr::hyprlang ALIAS hyprlang)
install(TARGETS hyprlang)
# tests
add_custom_target(tests)
add_executable(hyprlang_test "tests/parse/main.cpp")
target_link_libraries(hyprlang_test PRIVATE hypr::hyprlang)
add_test(
NAME "Parsing"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests
COMMAND hyprlang_test "parse")
add_dependencies(tests hyprlang_test)
add_executable(hyprlang_fuzz "tests/fuzz/main.cpp")
target_link_libraries(hyprlang_fuzz PRIVATE hypr::hyprlang)
add_test(
NAME "Fuzz"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests
COMMAND hyprlang_fuzz "fuzz")
add_dependencies(tests hyprlang_fuzz)
# Installation
install(
TARGETS hyprlang
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES ${CMAKE_BINARY_DIR}/hyprlang.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)