-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
226 lines (196 loc) · 6.5 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
219
220
221
222
223
224
225
226
cmake_minimum_required(VERSION 3.2)
project(uTox LANGUAGES C)
#######################################################################
#
# project version
#
#######################################################################
# This version is for the entire project. All libraries (core, av, ...) move in
# versions in a synchronised way.
set(PROJECT_VERSION_MAJOR "0")
set(PROJECT_VERSION_MINOR "12")
set(PROJECT_VERSION_PATCH "1")
set(PROJECT_VERSION
"${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
# make version available in C files
configure_file(${uTox_SOURCE_DIR}/src/branding.h.in
${uTox_SOURCE_DIR}/src/branding.h)
configure_file(${uTox_SOURCE_DIR}/src/cocoa/Info.plist.in
${uTox_SOURCE_DIR}/src/cocoa/Info.plist)
configure_file(${uTox_SOURCE_DIR}/src/android/AndroidManifest.xml.in
${uTox_SOURCE_DIR}/src/android/AndroidManifest.xml)
#######################################################################
#
# C compiler flags
#
#######################################################################
set(CMAKE_C_STANDARD 11) # this requires at least cmake 3.1
include(CheckCCompilerFlag)
# add compiler flag for all build types
function(add_cflag flag)
string(REGEX REPLACE "[^a-zA-Z0-9_]" "_" var ${flag})
if(NOT DEFINED HAVE_C${var})
message(STATUS "checking for C compiler flag: ${flag}")
endif()
set(CMAKE_REQUIRED_QUIET TRUE)
check_c_compiler_flag("${flag}" HAVE_C${var} QUIET)
if(HAVE_C${var})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}" PARENT_SCOPE)
endif()
endfunction()
# Warn on non-ISO C.
#add_cflag("-pedantic") # throws a lot of warning, quite sure we do not want this at current state.
# Add all warning flags we can.
add_cflag("-Wall")
add_cflag("-Wextra")
# Warnings we don't tolerate
add_cflag("-Werror=implicit-function-declaration")
# Warnings we don't care about
add_cflag("-Wformat=0")
# Everything Else
add_cflag("-fno-strict-aliasing")
#######################################################################
#
# Build options
#
#######################################################################
# sanitize memory issues in Debug builds
# https://gcc.gnu.org/gcc-4.8/changes.html
# https://github.com/google/sanitizers/wiki/AddressSanitizer
option(ENABLE_ASAN "Enable Address Sanitizer on debug builds" ON)
if (ENABLE_ASAN)
message("")
message(" TIP: You may want to set the env variable ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer for ASAN to show nicer stack traces.")
message(" See <http://clang.llvm.org/docs/AddressSanitizer.html#symbolizing-the-reports> for more details.")
message("")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fsanitize=address -fno-omit-frame-pointer")
endif()
option(FILTER_AUDIO "Enable Filter Audio" ON)
if(FILTER_AUDIO)
add_cflag("-DAUDIO_FILTERING")
endif()
option(UTOX_STATIC "Link uTox staticlly" OFF)
if(UTOX_STATIC)
add_cflag("-static")
endif()
option(TOXCORE_STATIC "Build uTox with the static version of Toxcore" OFF)
if(TOXCORE_STATIC)
# The static windows libs need all of these... because REASONS!
set(TOX_LIBS
toxencryptsave
toxav
toxdns
toxcore
toxgroup
toxmessenger
toxfriends
toxdht
toxnetcrypto
toxcrypto
toxnetwork
)
else()
set(TOX_LIBS
toxencryptsave
toxdns
toxav
toxcore
)
endif()
# print a summary of build options
message("Build options:")
message("- Add ASAN: ${ENABLE_ASAN}")
message("- Filter Audio: ${FILTER_AUDIO}")
message("- uTox Static: ${UTOX_STATIC}")
message("- Toxcore Static: ${TOXCORE_STATIC}")
message("- Windows Legacy: ${WIN_XP_LEGACY}")
message("* C Compiler is '${CMAKE_C_COMPILER}' with the following flags:")
message("* C flags for Debug: ${CMAKE_C_FLAGS_DEBUG}")
message("* C flags for Release: ${CMAKE_C_FLAGS_RELEASE}")
message("* C flags for all types: ${CMAKE_C_FLAGS}")
# Protip, you must use a different directory for each build target...
# -DMAKE_TOOLCHAIN_FILE has no effect unless the target directory is empty
# 1.5 hours to learn this...
if(WIN32)
set(GUI_TYPE WIN32)
############################################################
## This is a hack, that we can remove once we have better
## separation of the sections of uTox, until then, this
## makes everything work.
############################################################
include_directories( libs/toktok/include libs/windows-x64/include/ )
if(WIN64)
link_directories( libs/toktok/lib /usr/x86_64-w64-mingw32/lib/ libs/windows-x64/lib )
else()
link_directories( libs/toktok_32/lib /usr/i686-w64-mingw32/lib/ libs/windows-x32/lib )
endif()
## Needed to build the widows icon
enable_language(RC)
set(WINDOWS_ICON icons/icon.rc)
add_subdirectory(src/windows)
elseif(APPLE)
set(GUI_TYPE MACOSX_BUNDLE)
set(MACOSX_BUNDLE_INFO_PLIST src/cocoa/Info.plist)
add_definitions("-x objective-c")
add_subdirectory(src/cocoa)
elseif(UNIX)
find_package(Freetype REQUIRED)
include_directories(${FREETYPE_INCLUDE_DIRS})
message("Found Freetype version ${FREETYPE_VERSION_STRING}")
message("Freetype include: ${FREETYPE_INCLUDE_DIRS}")
message("Freetype library: ${FREETYPE_LIBRARIES}")
add_subdirectory(src/xlib)
endif()
# include utoxUI
add_subdirectory(src/ui)
# include utoxAV
add_subdirectory(src/av)
#######################################################################
#
# :: uTox main
#
#######################################################################
add_executable(utox ${GUI_TYPE}
src/avatar.c
src/chatlog.c
src/command_funcs.c
src/commands.c
src/devices.c
src/dns.c
src/file_transfers.c
src/filesys.c
src/flist.c
src/friend.c
src/groups.c
src/inline_video.c
src/logging.c
src/main.c
src/messages.c
src/self.c
src/settings.c
src/text.c
src/theme.c
src/tox.c
src/tox_callbacks.c
src/ui.c
src/ui_i18n.c
src/updater.c
src/utox.c
${WINDOWS_ICON}
${APPLE_ICON}
)
target_link_libraries(utox
utoxAV utoxNATIVE utoxUI
${TOX_LIBS} ${LIBRARIES} sodium
vpx pthread m )
set_property(TARGET utox PROPERTY C_STANDARD 11)
if(APPLE)
install(TARGETS utox
RUNTIME DESTINATION "bin"
BUNDLE DESTINATION "resources"
)
elseif(UNIX)
install(TARGETS utox
RUNTIME DESTINATION "bin"
)
endif()