This repository has been archived by the owner on Mar 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
CMakeLists.txt
119 lines (87 loc) · 4.03 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
cmake_minimum_required(VERSION 3.0)
project(libdiscord VERSION 0.3.0 LANGUAGES C)
message(STATUS "We are on a ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_VERSION} system")
message(STATUS "The host processor is ${CMAKE_HOST_SYSTEM_PROCESSOR}")
## Library info
set(PACKAGE libdiscord)
set(CPACK_PACKAGE_NAME libdiscord)
set(LD_VERSION_MAJOR 0)
set(LD_VERSION_MINOR .3)
set(LD_VERSION_PATCH )
set(LD_VERSION "${LD_VERSION_MAJOR}${LD_VERSION_MINOR}${LD_VERSION_PATCH}")
## libdiscord options
set(LD_RINGBUFFER_DEFAULT_SIZE 16)
set(LD_CONNECT_DELAY_INTERVAL 5) # in ld_service, if ld_connect returns error, ld_service will block for this amount of time. not so good for event loops with other things happening in the background
## Discord-specific default options
set(LD_API_URL "\"https://discordapp.com/api\"")
set(LD_REST_API_VERSION "\"/v6\"")
set(LD_WS_API_VERSION 6)
#set(LD_GATEWAY_API_VERSION 3 "Only version 3 of the gateway API is supported")
set(LD_GITHUB_URL "\"https://github.com/dxing97/libdiscord\"") # do we need this?
## Compilation
set(CMAKE_C_STANDARD 99)
## Include directories
IF (CYGWIN)
SET (CMAKE_FIND_LIBRARY_PREFIXES "")
SET (CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".LIB" ".dll" ".DLL")
ELSE()
SET (CMAKE_FIND_LIBRARY_PREFIXES "lib")
SET (CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".a")
ENDIF (CYGWIN)
include_directories(/usr/local/lib /usr/local/include)
include_directories(example_bots lib cmake)
#homebrew on macOS
include_directories(/usr/local/opt/curl/include)
include_directories(/usr/local/opt/openssl/include)
link_directories(/usr/local/opt/openssl/lib)
include_directories(/usr/local/opt/libwebsockets/include)
link_directories(/usr/local/opt/libwebsockets/lib)
link_directories(/usr/local/opt/jansson/lib)
#include_directories(/usr/local/include/glib-2.0)
#include_directories(/usr/local/include/glib-2.0/glib)
include_directories("${PROJECT_BINARY_DIR}")
# If libwebsockets was compiled and installed in Cygwin:
include_directories(/usr/local/lib/include)
#find_library(LCRYPTO openssl)
#find_package(BZip2)
#find_package(PkgConfig REQUIRED)
#pkg_search_module(GLIB REQUIRED glib-2.0)
#
#set(LD_INCLUDE_DIRS ${GLIB_INCLUDE_DIRS})
set(LD_LIBS websockets jansson curl crypto ${GLIB_LDFLAGS})
## Sources and headers
configure_file(
"${PROJECT_SOURCE_DIR}/cmake/libdiscord_config.h.in"
"${PROJECT_BINARY_DIR}/libdiscord_config.h"
)
## Targets
## Library
set(LD_SOURCE lib/libdiscord.h lib/libdiscord.c lib/REST.h lib/REST.c lib/log.c lib/log.h lib/json.c lib/json.h lib/utils.c lib/utils.h lib/status.h)
add_library(discord SHARED ${LD_SOURCE})
target_include_directories(discord PRIVATE ${LD_INCLUDE_DIRS})
target_link_libraries(discord ${LD_LIBS})
set_target_properties(discord PROPERTIES VERSION ${PROJECT_VERSION})
target_compile_options(discord PRIVATE "-Wall")
target_compile_options(discord PRIVATE "-Werror")
target_compile_options(discord PRIVATE "-Wno-unknown-pragmas")
target_compile_options(discord PRIVATE "-g")
## Example Bots
set(BOT_AYY_SOURCE example_bots/example-ayylmao.c cmake/libdiscord_config.h.in)
add_executable(example-bot-ayylmao ${BOT_AYY_SOURCE})
target_link_libraries(example-bot-ayylmao discord)
set(BOT_PING_SOURCE example_bots/example-ping.c cmake/libdiscord_config.h.in)
add_executable(example-bot-ping ${BOT_PING_SOURCE})
target_link_libraries(example-bot-ping discord)
set(BOT_COUNTER_SOURCE example_bots/example-counter.c cmake/libdiscord_config.h.in)
add_executable(example-bot-counter ${BOT_COUNTER_SOURCE})
target_link_libraries(example-bot-counter discord)
set(EXAMPLE_SIMPLEPOST_SOURCE cmake/libdiscord_config.h.in example_bots/example-simplepost.c)
add_executable(example-simplepost ${EXAMPLE_SIMPLEPOST_SOURCE})
target_link_libraries(example-simplepost discord)
set(BOT_HASH_SOURCE cmake/libdiscord_config.h.in example_bots/example-hash.c)
add_executable(example-bot-hash ${BOT_HASH_SOURCE})
target_link_libraries(example-bot-hash discord)
## Tests
set(TESTS_JSON_SOURCE cmake/libdiscord_config.h.in tests/tests-json.c)
add_executable(tests-json ${TESTS_JSON_SOURCE})
target_link_libraries(tests-json discord)