-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
218 lines (175 loc) · 5.96 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# minimum CMake version required
cmake_minimum_required(VERSION 3.15)
# Project name, version and description
project(Musicat
VERSION 0.1.1
LANGUAGES CXX
DESCRIPTION "Discord Music Bot written in C++")
option(MUSICAT_WITH_CORO "Configure Musicat with C++20 coroutines" OFF)
option(MUSICAT_DEBUG_SYMBOL "Build Musicat with debug symbol" ON)
option(COMPILE_GNUPLOT "Download and compile gnuplot" OFF)
set(MUSICAT_CXX_STANDARD 17)
set(DPP_INSTALL OFF)
set(DPP_USE_EXTERNAL_JSON ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic")
set(WITH_COMPILE_GNUPLOT 0)
if (COMPILE_GNUPLOT)
set(WITH_COMPILE_GNUPLOT 1)
set(GNUPLOT_VERSION 6.0.0)
message("-- INFO: Will compile gnuplot version ${GNUPLOT_VERSION}")
endif()
set(SED_NLOHMANN_JSON_INCLUDE_CMD "sed" "-i" "s/\#include <nlohmann\\/json.hpp>/\#include \"nlohmann\\/json.hpp\"/" "${CMAKE_CURRENT_SOURCE_DIR}/libs/DPP/include/dpp/json.h")
message(${SED_NLOHMANN_JSON_INCLUDE_CMD})
execute_process(COMMAND ${SED_NLOHMANN_JSON_INCLUDE_CMD})
file(GLOB_RECURSE MUSICAT_HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/include/musicat/*.h)
file(GLOB_RECURSE MUSICAT_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/src/musicat/*.cpp)
# file(GLOB_RECURSE ELIZA_HEADER_FILES
# ${CMAKE_CURRENT_SOURCE_DIR}/libs/ELIZA/src/*.h)
file(GLOB_RECURSE ELIZA_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/libs/ELIZA/src/eliza.cpp)
# Create an executable
add_executable(Shasha
# include files
${MUSICAT_HEADER_FILES}
include/nlohmann/json.hpp
libs/uWebSockets/uSockets/src/libusockets.h
libs/uWebSockets/uSockets/src/quic.h
# ${ELIZA_HEADER_FILES}
# !TODO: include/uWebSockets/files
# impl files
${MUSICAT_SOURCE_FILES}
libs/yt-search.h/src/yt-search/encode.cpp
libs/yt-search.h/src/yt-search/yt-playlist.cpp
libs/yt-search.h/src/yt-search/yt-search.cpp
libs/yt-search.h/src/yt-search/yt-track-info.cpp
libs/nekos-bestpp/src/nekos-best++.cpp
${ELIZA_SOURCE_FILES}
src/main.cpp)
set(USOCKETS_OBJECT_FILES
${CMAKE_CURRENT_SOURCE_DIR}/libs/uWebSockets/uSockets/bsd.o
${CMAKE_CURRENT_SOURCE_DIR}/libs/uWebSockets/uSockets/context.o
${CMAKE_CURRENT_SOURCE_DIR}/libs/uWebSockets/uSockets/epoll_kqueue.o
${CMAKE_CURRENT_SOURCE_DIR}/libs/uWebSockets/uSockets/gcd.o
${CMAKE_CURRENT_SOURCE_DIR}/libs/uWebSockets/uSockets/libuv.o
${CMAKE_CURRENT_SOURCE_DIR}/libs/uWebSockets/uSockets/loop.o
${CMAKE_CURRENT_SOURCE_DIR}/libs/uWebSockets/uSockets/openssl.o
${CMAKE_CURRENT_SOURCE_DIR}/libs/uWebSockets/uSockets/quic.o
${CMAKE_CURRENT_SOURCE_DIR}/libs/uWebSockets/uSockets/sni_tree.o
${CMAKE_CURRENT_SOURCE_DIR}/libs/uWebSockets/uSockets/socket.o
${CMAKE_CURRENT_SOURCE_DIR}/libs/uWebSockets/uSockets/udp.o)
file(GLOB_RECURSE USOCKETS_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/libs/uWebSockets/uSockets/src/*.c)
file(GLOB_RECURSE UWEBSOCKETS_HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/libs/uWebSockets/src/*.h)
add_custom_target(uWebSockets
DEPENDS ${USOCKETS_OBJECT_FILES})
add_custom_command(OUTPUT ${USOCKETS_OBJECT_FILES}
COMMAND WITH_OPENSSL=1 WITH_ZLIB=1 make
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/libs/uWebSockets/uSockets
DEPENDS ${USOCKETS_SOURCE_FILES} ${UWEBSOCKETS_HEADER_FILES})
add_custom_target(deps
DEPENDS ShashaDeps)
add_custom_command(OUTPUT ShashaDeps
COMMAND COMPILE_GNUPLOT=${WITH_COMPILE_GNUPLOT} GNUPLOT_VERSION=${GNUPLOT_VERSION} make
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/libs)
add_dependencies(Shasha deps uWebSockets)
add_custom_target(archlinux-dist-folder
COMMAND mkdir -p archlinux-dist
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
add_custom_target(archlinux-dist
COMMAND cp build/Shasha
build/libs/DPP/library/libdpp.so*
libs/curlpp/build/libcurlpp.so*
libs/icu/usr/local/lib/lib*
build/libs/ogg/libogg.so*
src/yt-dlp/ytdlp.py
archlinux-dist
COMMAND cp -r libs/yt-dlp
src/yt-dlp/utils
archlinux-dist
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS archlinux-dist-folder Shasha)
if (COMPILE_GNUPLOT)
add_custom_target(archlinux-dist-cp-gnuplot
COMMAND cp libs/gnuplot-${GNUPLOT_VERSION}/build/bin/gnuplot
archlinux-dist
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS archlinux-dist-folder Shasha)
add_dependencies(archlinux-dist archlinux-dist-cp-gnuplot)
endif()
if (MUSICAT_WITH_CORO)
message("-- INFO: Configuring Musicat with coroutines")
set(DPP_CORO ON)
target_compile_definitions(Shasha PUBLIC MUSICAT_WITH_CORO)
set(MUSICAT_CXX_STANDARD 20)
endif()
if (MUSICAT_DEBUG_SYMBOL)
message("-- INFO: Will build Musicat with debug symbol")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
# set(CMAKE_BUILD_TYPE "Debug")
endif()
# Linking libraries
target_link_libraries(Shasha
dpp
# oggz
ogg
pq
curlpp
curl
cppcodec
icui18n
icuuc
icudata
icuio
${USOCKETS_OBJECT_FILES}
ssl
crypto
z
pthread
# Add any other libs you want to use here
)
# Specify includes
target_include_directories(Shasha PRIVATE
include
# uWebSockets
libs
libs/DPP/include
libs/yt-search.h/include
libs/nekos-bestpp/include
libs/uWebSockets/uSockets/src
libs/icu/usr/local/include
libs/curlpp/include
# libs/liboggz/include
libs/jwt-cpp/include
/usr/include/postgresql
libs/ELIZA/src
# Remember to add the include directories of any other libraries too
)
target_link_directories(Shasha PRIVATE
libs/curlpp/build
libs/icu/usr/local/lib
# libs/liboggz/build/lib
)
# Set C++ version
set_target_properties(Shasha PROPERTIES
CXX_STANDARD ${MUSICAT_CXX_STANDARD}
CXX_STANDARD_REQUIRED ON
EXPORT_COMPILE_COMMANDS ON
)
# Add DPP as dependency
add_subdirectory(libs/DPP)
add_subdirectory(libs/cppcodec)
# libogg build options
set(INSTALL_DOCS OFF)
set(INSTALL_PKG_CONFIG_MODULE OFF)
set(INSTALL_CMAKE_PACKAGE_MODULE OFF)
add_subdirectory(libs/ogg)
# You can also add any other libs you want to use
message(WARNING "If you like this bot or wanna suggest smt, say hi in https://discord.gg/ADGcaHnRFs <3")
# add_executable(base32 include/musicat/util/base32.h base32.cpp src/musicat/util/base32.cpp)
# target_link_libraries(base32 cppcodec)
# target_include_directories(base32 PRIVATE
# include)
# vim: sw=8 noet