-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
145 lines (116 loc) · 3.15 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
#
# CMakeLists.txt
#
# Copyright (C) 2022 Sebastian Reimers
#
##############################################################################
#
# Project and Versioning
#
cmake_minimum_required(VERSION 3.18)
set(CMAKE_C_COMPILER clang)
project(slmix VERSION 1.0.0 LANGUAGES C)
##############################################################################
#
# Packages
#
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
find_package(LMDB REQUIRED)
##############################################################################
#
# Compile options
#
option(USE_SD_SOCK "Enable systemd socket" OFF)
option(USE_UNIX_SOCK "Enable UNIX socket" OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if(MSVC)
add_compile_options("/W3")
else()
add_compile_options(
-pedantic
-Wall
-Wbad-function-cast
-Wcast-align
-Wextra
-Wmissing-declarations
-Wmissing-prototypes
-Wnested-externs
-Wno-strict-aliasing
-Wold-style-definition
-Wshadow -Waggregate-return
-Wstrict-prototypes
-Wuninitialized
-Wvla
-Wno-gnu-zero-variadic-macro-arguments
)
endif()
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wshorten-64-to-32 -Watomic-implicit-seq-cst)
endif()
if(USE_SD_SOCK)
list(APPEND MIX_DEFS SLMIX_SD_SOCK)
list(APPEND LINKLIBS systemd)
endif()
if(USE_UNIX_SOCK)
list(APPEND MIX_DEFS SLMIX_UNIX_SOCK)
endif()
list(APPEND LINKLIBS gd ${LMDB_LIBRARIES})
##############################################################################
#
# Subdirectory section
#
set(RE_LIBRARY re CACHE STRING "re_library")
set(REM_LIBRARY rem CACHE STRING "rem_library")
set(STATIC ON CACHE BOOL "Build static")
set(APP_MODULES_DIR ${CMAKE_SOURCE_DIR}/modules)
set(APP_MODULES amix vmix)
set(MODULES ice dtls_srtp turn opus vp8 avcodec fakevideo auresamp CACHE STRING "")
add_subdirectory(external/re EXCLUDE_FROM_ALL)
add_subdirectory(external/baresip EXCLUDE_FROM_ALL)
find_package(re CONFIG REQUIRED)
list(APPEND RE_DEFINITIONS
_GNU_SOURCE
)
include_directories(
include
external/re/include
external/baresip/include
)
##############################################################################
#
# Source/Header section
#
set(SRCS_LIB
src/avatar.c
src/chat.c
src/db.c
src/http.c
src/http_client.c
src/mix.c
src/sess.c
src/sip.c
src/source.c
src/users.c
src/ws.c
${CMAKE_CURRENT_BINARY_DIR}/version.c
)
set(SRCS_EXE
src/main.c
)
##############################################################################
#
# Target objects
#
add_library(${PROJECT_NAME}-lib STATIC ${SRCS_LIB})
target_link_libraries(${PROJECT_NAME}-lib PRIVATE ${LINKLIBS} re)
target_compile_definitions(${PROJECT_NAME}-lib PRIVATE ${RE_DEFINITIONS} ${MIX_DEFS}
SLMIX_VERSION="${PROJECT_VERSION}")
add_executable(${PROJECT_NAME} ${SRCS_EXE})
target_link_libraries(${PROJECT_NAME} PRIVATE slmix-lib baresip)
target_compile_definitions(${PROJECT_NAME} PRIVATE ${RE_DEFINITIONS} ${MIX_DEFS}
SLMIX_VERSION="${PROJECT_VERSION}")
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version.c
${CMAKE_CURRENT_BINARY_DIR}/_version.c
COMMAND ${CMAKE_COMMAND} -P
${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.cmake)