-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
157 lines (117 loc) · 5.93 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
cmake_minimum_required(VERSION 3.21)
project(venmic LANGUAGES CXX VERSION 6.1.0)
# --------------------------------------------------------------------------------------------------------
# Library options
# --------------------------------------------------------------------------------------------------------
option(venmic_addon "Build as addon" OFF)
option(venmic_server "Build as rest server" ON)
option(venmic_prefer_remote "Prefer remote packages over local packages" ON)
# --------------------------------------------------------------------------------------------------------
# Addon and Rest-Server are mutually exclusive
# --------------------------------------------------------------------------------------------------------
if (venmic_addon)
set(venmic_server OFF)
endif()
if (venmic_server)
set(venmic_addon OFF)
endif()
# --------------------------------------------------------------------------------------------------------
# Sync `CPM_DOWNLOAD_ALL` with `venmic_prefer_remote`
# --------------------------------------------------------------------------------------------------------
if (venmic_prefer_remote)
message(STATUS "[venmic] Avoiding local packages as 'venmic_prefer_remote' is ON")
endif()
set(CPM_DOWNLOAD_ALL ${venmic_prefer_remote})
# --------------------------------------------------------------------------------------------------------
# CMake options
# --------------------------------------------------------------------------------------------------------
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# --------------------------------------------------------------------------------------------------------
# Create library
# --------------------------------------------------------------------------------------------------------
add_library(${PROJECT_NAME})
add_library(vencord::venmic ALIAS ${PROJECT_NAME})
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 20 CXX_EXTENSIONS OFF CXX_STANDARD_REQUIRED ON)
if (PROJECT_IS_TOP_LEVEL)
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic -Werror -pedantic -pedantic-errors -Wfatal-errors)
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
target_compile_options(${PROJECT_NAME} PUBLIC -Wno-attributes=vc::)
else()
target_compile_options(${PROJECT_NAME} PUBLIC -Wno-unknown-attributes)
endif()
target_compile_options(${PROJECT_NAME} PRIVATE -Wno-missing-field-initializers -Wno-cast-function-type)
# --------------------------------------------------------------------------------------------------------
# Add source files
# --------------------------------------------------------------------------------------------------------
file(GLOB src "src/*.cpp")
target_sources(${PROJECT_NAME} PRIVATE ${src})
# --------------------------------------------------------------------------------------------------------
# Include "include" folder
# --------------------------------------------------------------------------------------------------------
target_include_directories(${PROJECT_NAME} PUBLIC "include")
target_include_directories(${PROJECT_NAME} PRIVATE "include/vencord" "private")
# --------------------------------------------------------------------------------------------------------
# Setup compile definitions
# --------------------------------------------------------------------------------------------------------
target_compile_definitions(${PROJECT_NAME} PUBLIC VENMIC_VERSION="${PROJECT_VERSION}")
# --------------------------------------------------------------------------------------------------------
# Setup Dependencies
# --------------------------------------------------------------------------------------------------------
include("cmake/cpm.cmake")
CPMFindPackage(
NAME rohrkabel
VERSION 7.0
GIT_REPOSITORY "https://github.com/Curve/rohrkabel"
)
CPMFindPackage(
NAME tl-expected
VERSION 1.1.0
GIT_REPOSITORY "https://github.com/TartanLlama/expected"
)
CPMFindPackage(
NAME channel
VERSION 2.3
GIT_REPOSITORY "https://github.com/Curve/channel"
)
CPMFindPackage(
NAME range-v3
GIT_TAG 0.12.0
GIT_REPOSITORY "https://github.com/ericniebler/range-v3"
)
CPMFindPackage(
NAME glaze
VERSION 2.6.8
GIT_REPOSITORY "https://github.com/stephenberry/glaze"
)
CPMFindPackage(
NAME spdlog
VERSION 1.14.1
GIT_REPOSITORY "https://github.com/gabime/spdlog"
)
target_link_libraries(${PROJECT_NAME} PUBLIC cr::rohrkabel tl::expected cr::channel glaze::glaze range-v3::meta spdlog::spdlog)
# --------------------------------------------------------------------------------------------------------
# Custom Find-Package configurations
# --------------------------------------------------------------------------------------------------------
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# --------------------------------------------------------------------------------------------------------
# Link PulseAudio
# --------------------------------------------------------------------------------------------------------
find_package(PulseAudio)
target_link_libraries(${PROJECT_NAME} PUBLIC PulseAudio::PulseAudio)
# --------------------------------------------------------------------------------------------------------
# Setup Rest Server
# --------------------------------------------------------------------------------------------------------
if (venmic_server)
add_subdirectory(server)
endif()
# --------------------------------------------------------------------------------------------------------
# Setup Node Addon
# --------------------------------------------------------------------------------------------------------
if (venmic_addon AND NOT CMAKE_JS_VERSION)
message(FATAL_ERROR "[venmic] Please build the addon using CMake.js")
endif()
if (venmic_addon)
add_subdirectory(addon)
endif()