@@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 3.6)
2
2
project (sleepy-discord)
3
3
4
4
option (BUILD_EXAMPLES "Build examples of Sleepy Discord and all dependencies" OFF )
5
- option (BUILD_SLEEPY_DISCORD_EXAMPLES "Build examples of Sleepy Discord" OFF )
5
+ option (SLEEPY_DISCORD_BUILD_EXAMPLES "Build examples of Sleepy Discord" OFF )
6
6
option (ONLY_SLEEPY_DISCORD "Sleepy Discord but none of the dependencies, except build in onces" OFF )
7
7
option (ENABLE_VOICE "Enable voice support" OFF )
8
8
if (NOT ONLY_SLEEPY_DISCORD)
@@ -15,9 +15,12 @@ if (NOT ONLY_SLEEPY_DISCORD)
15
15
option (USE_LIBSODIUM "Use libsodium cryptography library" OFF )
16
16
endif ()
17
17
18
+ #Define a variable to use to check if this file has been executed
19
+ set (SLEEPY_DISCORD_CMAKE ON )
20
+
18
21
#set variables based on other variables
19
22
if (BUILD_EXAMPLES)
20
- set (BUILD_SLEEPY_DISCORD_EXAMPLES ON )
23
+ set (SLEEPY_DISCORD_BUILD_EXAMPLES ON )
21
24
endif ()
22
25
23
26
if (ENABLE_VOICE)
@@ -29,50 +32,31 @@ if(USE_WEBSOCKETPP OR USE_UWEBSOCKETS)
29
32
set (USE_ASIO ON )
30
33
endif ()
31
34
35
+ find_package (Git)
36
+
32
37
# Find and Download libraries
33
38
if (AUTO_DOWNLOAD_LIBRARY)
39
+
40
+ if (NOT Git_FOUND)
41
+ string (CONCAT GIT_NOT_FOUND_WARNING
42
+ "GIT was not found, CMake list will likely fail. "
43
+ "Please make sure that GIT is inside your PATH variable" )
44
+ message (WARNING ${GIT_NOT_FOUND_WARNING} )
45
+ endif ()
46
+
47
+ #to do find librarys before downloading them
48
+
34
49
include (ExternalProject)
35
50
include (buildtools/cmake/DownloadProject.cmake)
36
51
if (USE_CPR)
37
52
#to do install libssl-dev
38
-
39
- #the cmake test has issues on visual studio so disable them
40
- if (NOT DEFINED BUILD_CPR_TESTS)
41
- set (BUILD_CPR_TESTS OFF CACHE BOOL "" )
42
- endif ()
43
-
44
- set (BUILD_CURL_EXE OFF CACHE BOOL "" )
45
- set (CURL_STATICLIB ON CACHE BOOL "" )
46
- set (CURL_ZLIB OFF CACHE BOOL "" )
47
-
48
- #set what ssl library to use for curl based on OS
49
- #this fixes
50
- if (NOT DEFINED CMAKE_USE_OPENSSL)
51
- if (WIN32 )
52
- set (CMAKE_USE_WINSSL ON CACHE BOOL "" )
53
- set (CMAKE_USE_OPENSSL OFF CACHE BOOL "" )
54
- elseif (APPLE )
55
- set (CMAKE_USE_DARWINSSL ON CACHE BOOL "" )
56
- set (CMAKE_USE_OPENSSL OFF CACHE BOOL "" )
57
- endif ()
58
- #to do, set one for linux
59
- endif ()
60
- if (NOT DEFINED USE_SYSTEM_CURL AND ${CMAKE_SYSTEM_NAME} MATCHES "Linux" )
61
- #using cmake to configure curl on linux has issues
62
- #so use system curl
63
- set (USE_SYSTEM_CURL ON CACHE BOOL "" )
64
- set (USE_SYSTEM_CURL ON CACHE INTERNAL BOOL "" )
65
- endif ()
66
-
67
53
download_project(
68
54
PROJ cpr
69
55
GIT_REPOSITORY https://github.com/whoshuu/cpr.git
70
- GIT_TAG master
56
+ GIT_TAG b748095
71
57
SOURCE_DIR ${PROJECT_SOURCE_DIR} /deps/cpr
72
58
UPDATE_DISCONNECTED 1
73
59
)
74
-
75
- add_subdirectory (deps/cpr)
76
60
endif ()
77
61
78
62
if (USE_ASIO)
@@ -95,10 +79,6 @@ if(AUTO_DOWNLOAD_LIBRARY)
95
79
SOURCE_DIR ${PROJECT_SOURCE_DIR} /deps/websocketpp
96
80
UPDATE_DISCONNECTED 1
97
81
)
98
-
99
- set (THREADS_PREFER_PTHREAD_FLAG ON )
100
- find_package (Threads REQUIRED)
101
- add_subdirectory (deps/websocketpp)
102
82
endif ()
103
83
104
84
if (USE_UWEBSOCKETS)
@@ -117,23 +97,21 @@ if(AUTO_DOWNLOAD_LIBRARY)
117
97
#needs libtool
118
98
download_project(
119
99
PROJ opus
120
- GIT_REPOSITORY https://git .xiph.org/opus.git
121
- GIT_TAG master
100
+ GIT_REPOSITORY https://gitlab .xiph.org/xiph /opus.git
101
+ GIT_TAG 7628d844
122
102
SOURCE_DIR ${PROJECT_SOURCE_DIR} /deps/opus
123
103
UPDATE_DISCONNECTED 1
124
104
)
125
- add_subdirectory (deps/opus)
126
105
endif ()
127
106
128
- if (USE_LIBSODIUM)
107
+ if (USE_LIBSODIUM AND NOT WIN32 )
129
108
download_project(
130
109
PROJ libsodium
131
110
GIT_REPOSITORY https://github.com/jedisct1/libsodium.git
132
111
GIT_TAG stable
133
112
SOURCE_DIR ${PROJECT_SOURCE_DIR} /deps/libsodium
134
113
UPDATE_DISCONNECTED 1
135
114
)
136
- #I would like use libsodium_BINARY_DIR as the BINARY_DIR but for some reason, that doesn't work
137
115
ExternalProject_Add(libsodium-make
138
116
SOURCE_DIR "${libsodium_SOURCE_DIR} "
139
117
BINARY_DIR "${libsodium_BINARY_DIR} "
@@ -144,10 +122,119 @@ if(AUTO_DOWNLOAD_LIBRARY)
144
122
TEST_COMMAND ""
145
123
)
146
124
endif ()
125
+ else ()
126
+ if (USE_CPR)
127
+ set (cpr_SOURCE_DIR ${PROJECT_SOURCE_DIR} /deps/cpr)
128
+ endif ()
129
+ if (USE_ASIO)
130
+ set (asio_SOURCE_DIR ${PROJECT_SOURCE_DIR} /deps/asio)
131
+ endif ()
132
+ if (USE_WEBSOCKETPP)
133
+ set (websocketpp_SOURCE_DIR ${PROJECT_SOURCE_DIR} /deps/websocketpp)
134
+ endif ()
135
+ if (USE_UWEBSOCKETS)
136
+ set (uwebsockets_SOURCE_DIR ${PROJECT_SOURCE_DIR} /deps/uwebsockets)
137
+ endif ()
138
+ if (USE_LIBOPUS)
139
+ set (opus_SOURCE_DIR ${PROJECT_SOURCE_DIR} /deps/opus)
140
+ endif ()
141
+ if (USE_LIBSODIUM AND NOT WIN32 )
142
+ set (libsodium_SOURCE_DIR ${PROJECT_SOURCE_DIR} /deps/libsodium)
143
+ endif ()
144
+ endif ()
145
+
146
+ # Configure libraries
147
+ if (USE_CPR)
148
+ #the cmake test has issues on visual studio so disable them
149
+ if (NOT DEFINED BUILD_CPR_TESTS)
150
+ set (BUILD_CPR_TESTS OFF CACHE BOOL "" )
151
+ endif ()
152
+
153
+ set (BUILD_CURL_EXE OFF CACHE BOOL "" )
154
+ set (CURL_STATICLIB ON CACHE BOOL "" )
155
+ set (CURL_ZLIB OFF CACHE BOOL "" )
156
+
157
+ #set what ssl library to use for curl based on OS
158
+ #this fixes
159
+ if (NOT DEFINED CMAKE_USE_OPENSSL)
160
+ if (WIN32 )
161
+ set (CMAKE_USE_WINSSL ON CACHE BOOL "" )
162
+ set (CMAKE_USE_OPENSSL OFF CACHE BOOL "" )
163
+ elseif (APPLE )
164
+ set (CMAKE_USE_DARWINSSL ON CACHE BOOL "" )
165
+ set (CMAKE_USE_OPENSSL OFF CACHE BOOL "" )
166
+ elseif (UNIX )
167
+ set (CMAKE_USE_OPENSSL OFF CACHE BOOL "" )
168
+ endif ()
169
+ endif ()
170
+ if (NOT DEFINED USE_SYSTEM_CURL AND ${CMAKE_SYSTEM_NAME} MATCHES "Linux" )
171
+ #using cmake to configure curl on linux has issues
172
+ #so use system curl
173
+ set (USE_SYSTEM_CURL ON CACHE BOOL "" )
174
+ endif ()
175
+
176
+ add_subdirectory (deps/cpr)
177
+ endif ()
178
+
179
+ if (USE_WEBSOCKETPP)
180
+ set (THREADS_PREFER_PTHREAD_FLAG ON )
181
+ find_package (Threads REQUIRED)
182
+ add_subdirectory (deps/websocketpp)
183
+ endif ()
184
+
185
+ if (USE_LIBOPUS)
186
+ add_subdirectory (deps/opus)
187
+ endif ()
188
+
189
+ # Get Version Info
190
+ if (Git_FOUND)
191
+ execute_process (
192
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
193
+ COMMAND ${GIT_EXECUTABLE} rev-list --count HEAD
194
+ OUTPUT_VARIABLE SLEEPY_DISCORD_VERSION_BUILD
195
+ OUTPUT_STRIP_TRAILING_WHITESPACE
196
+ )
197
+ execute_process (
198
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
199
+ COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
200
+ OUTPUT_VARIABLE SLEEPY_DISCORD_VERSION_BRANCH
201
+ OUTPUT_STRIP_TRAILING_WHITESPACE
202
+ )
203
+ execute_process (
204
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
205
+ COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
206
+ OUTPUT_VARIABLE SLEEPY_DISCORD_VERSION_HASH
207
+ OUTPUT_STRIP_TRAILING_WHITESPACE
208
+ )
209
+ if (SLEEPY_DISCORD_VERSION_BRANCH STREQUAL "master" )
210
+ set (SLEEPY_DISCORD_VERSION_IS_MASTER "1" )
211
+ else ()
212
+ set (SLEEPY_DISCORD_VERSION_IS_MASTER "0" )
213
+ endif ()
214
+ execute_process (
215
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
216
+ COMMAND ${GIT_EXECUTABLE} describe --always --long --dirty
217
+ OUTPUT_VARIABLE SLEEPY_DISCORD_VERSION_DESCRIPTION
218
+ OUTPUT_STRIP_TRAILING_WHITESPACE
219
+ )
220
+ if (
221
+ NOT SLEEPY_DISCORD_VERSION_DESCRIPTION STREQUAL ""
222
+ )
223
+ set (SLEEPY_DISCORD_VERSION_DESCRIPTION_CONCAT " " )
224
+ else ()
225
+ set (SLEEPY_DISCORD_VERSION_DESCRIPTION_CONCAT "" )
226
+ endif ()
227
+ configure_file (
228
+ "${PROJECT_SOURCE_DIR} /include/sleepy_discord/version.h.in"
229
+ "${PROJECT_SOURCE_DIR} /include/sleepy_discord/version.h"
230
+ )
147
231
endif ()
148
232
149
233
# Add Subdirectories
150
234
add_subdirectory (sleepy_discord)
151
- if (BUILD_SLEEPY_DISCORD_EXAMPLES )
235
+ if (SLEEPY_DISCORD_BUILD_EXAMPLES )
152
236
add_subdirectory (examples/hello)
237
+ if (ENABLE_VOICE)
238
+ add_subdirectory (examples/sound-player)
239
+ endif ()
153
240
endif ()
0 commit comments