CMakeLists.txt 10.3 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
############################################################################
# CMakeLists.txt
# Copyright (C) 2014  Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
############################################################################

Ghislain MARY's avatar
Ghislain MARY committed
23
cmake_minimum_required(VERSION 3.0)
24
project(LINPHONE C CXX)
25

26

27
set(LINPHONE_MAJOR_VERSION "3")
Ghislain MARY's avatar
Ghislain MARY committed
28
set(LINPHONE_MINOR_VERSION "9")
Ghislain MARY's avatar
Ghislain MARY committed
29
set(LINPHONE_MICRO_VERSION "1")
30
set(LINPHONE_VERSION "${LINPHONE_MAJOR_VERSION}.${LINPHONE_MINOR_VERSION}.${LINPHONE_MICRO_VERSION}")
Ghislain MARY's avatar
Ghislain MARY committed
31
set(LINPHONE_SO_VERSION "8")
32

33
file(GLOB LINPHONE_PO_FILES RELATIVE "${CMAKE_CURRENT_LIST_DIR}/po" "${CMAKE_CURRENT_LIST_DIR}/po/*.po")
34
35
string(REGEX REPLACE "([a-zA-Z_]+)\\.po" "\\1" LINPHONE_ALL_LANGS_LIST "${LINPHONE_PO_FILES}")
string(REPLACE ";" " " LINPHONE_ALL_LANGS "${LINPHONE_ALL_LANGS_LIST}")
36
37
38

include(CMakeDependentOption)

39
option(ENABLE_STATIC "Build static library (default is shared library)." NO)
40
41
option(ENABLE_CONSOLE_UI "Turn on or off compilation of console interface." YES)
option(ENABLE_DATE "Use build date in internal version number." NO)
42
option(ENABLE_DOC "Enable documentation generation with Doxygen." YES)
43
44
option(ENABLE_GTK_UI "Turn on or off compilation of gtk interface." YES)
option(ENABLE_LDAP "Enable LDAP support." NO)
45
option(ENABLE_LIME "Enable Instant Messaging Encryption." NO)
46
option(ENABLE_MSG_STORAGE "Turn on compilation of message storage." YES)
47
cmake_dependent_option(ENABLE_NOTIFY "Enable libnotify support." YES "ENABLE_GTK_UI;NOT APPLE" NO)
48
option(ENABLE_RELATIVE_PREFIX "Find resources relatively to the installation directory." NO)
49
option(ENABLE_STRICT "Build with strict compile options." YES)
50
option(ENABLE_TOOLS "Turn on or off compilation of tools." YES)
51
52
53
54
option(ENABLE_TUNNEL "Turn on compilation of tunnel support." NO)
option(ENABLE_TUTORIALS "Enable compilation of tutorials." YES)
option(ENABLE_UNIT_TESTS "Enable compilation of unit tests." YES)
option(ENABLE_UPNP "Build with uPnP support." YES)
55
option(ENABLE_VIDEO "Build with video support." YES)
56
cmake_dependent_option(ENABLE_ASSISTANT "Turn on assistant compiling." YES "ENABLE_GTK_UI" NO)
57
option(ENABLE_DEBUG_LOGS "Turn on or off debug level logs." NO)
58
option(ENABLE_NLS "Build with internationalisation support" YES)
59
option(ENABLE_CALL_LOGS_STORAGE "Turn on compilation of call logs storage." YES)
60
61


62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
macro(apply_compile_flags SOURCE_FILES)
	if(${SOURCE_FILES})
		set(options "")
		foreach(a ${ARGV})
			if(STRICT_OPTIONS_${a})
				string(REPLACE ";" " " options_${a} "${STRICT_OPTIONS_${a}}")
				set(options "${options} ${options_${a}}")
			endif()
		endforeach()
		if(options)
			set_source_files_properties(${${SOURCE_FILES}} PROPERTIES COMPILE_FLAGS "${options}")
		endif()
	endif()
endmacro()


78
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
79

80
include(CheckSymbolExists)
81
include(CMakePushCheckState)
82

83
set(MSVC_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include/MSVC")
84
if(MSVC)
85
	list(APPEND CMAKE_REQUIRED_INCLUDES "${MSVC_INCLUDE_DIR}")
86
87
endif()

88
89
90
# find_package should be invoked here to check for libraries - however do NOT
# call include_directories here (see below)

91
92
93
if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
	include("${EP_bellesip_CONFIG_DIR}/BelleSIPConfig.cmake")
	include("${EP_ms2_CONFIG_DIR}/Mediastreamer2Config.cmake")
jehan's avatar
jehan committed
94
	include("${EP_bctoolbox_CONFIG_DIR}/BcToolboxConfig.cmake")
95
96
97
else()
	find_package(BelleSIP REQUIRED)
	find_package(Mediastreamer2 REQUIRED)
johan's avatar
johan committed
98
	find_package(BcToolBox REQUIRED)
99
endif()
100
find_package(XML2 REQUIRED)
101
find_package(Zlib)
102
103
104
if(ENABLE_UNIT_TESTS)
	find_package(CUnit)
	if(CUNIT_FOUND)
105
106
107
108
109
110
		cmake_push_check_state(RESET)
		list(APPEND CMAKE_REQUIRED_INCLUDES ${CUNIT_INCLUDE_DIRS})
		list(APPEND CMAKE_REQUIRED_LIBRARIES ${CUNIT_LIBRARIES})
		check_symbol_exists("CU_get_suite" "CUnit/CUnit.h" HAVE_CU_GET_SUITE)
		check_symbol_exists("CU_curses_run_tests" "CUnit/CUnit.h" HAVE_CU_CURSES)
		cmake_pop_check_state()
111
112
113
114
115
	else()
		message(WARNING "Could not find the cunit library!")
		set(ENABLE_UNIT_TESTS OFF CACHE BOOL "Enable compilation of unit tests." FORCE)
	endif()
endif()
116
if(ENABLE_TUNNEL)
117
118
119
120
121
	if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
		include("${EP_tunnel_CONFIG_DIR}/TunnelConfig.cmake")
	else()
		find_package(Tunnel)
	endif()
122
123
	if(NOT TUNNEL_FOUND)
		message(WARNING "Could not find the tunnel library!")
124
125
126
		set(ENABLE_TUNNEL OFF CACHE BOOL "Enable tunnel support." FORCE)
	endif()
endif()
127
if(ENABLE_MSG_STORAGE)
128
	find_package(Sqlite3 REQUIRED)
129
endif()
130
131
132
133
134
135
136
if(ENABLE_NOTIFY)
	find_package(Notify)
	if(NOTIFY_FOUND)
		set(HAVE_NOTIFY4 1)
	else()
		message(WARNING "Could not find the notify library!")
		set(ENABLE_NOTIFY OFF CACHE BOOL "Enable libnotify support." FORCE)
137
138
	endif()
endif()
139
140
141
142
143
144
145
146
147
if(ENABLE_GTK_UI)
	if(WIN32)
		set(GTK2_ADDITIONAL_SUFFIXES "../lib/glib-2.0/include" "../lib/gtk-2.0/include")
	endif()
	find_package(GTK2 2.18 REQUIRED gtk)
	if(ENABLE_ASSISTANT AND GTK2_VERSION VERSION_LESS 2.22)
		message(WARNING "You need at least GTK 2.22 to enable the assistant")
		set(ENABLE_ASSISTANT OFF CACHE BOOL "Turn on assistant compiling." FORCE)
	endif()
148
149
150
151
152
153
154
155
156
	if(APPLE)
		find_package(GtkMacIntegration)
		if(GTKMACINTEGRATION_FOUND)
			set(HAVE_GTK_OSX 1)
			add_definitions("${GTKMACINTEGRATION_CPPFLAGS}")
		else()
			message(WARNING "gtk-mac-integration not found. Please install gtk-osx-application package.")
		endif()
	endif()
157
158
159
160
endif()
if(ENABLE_ASSISTANT)
	set(BUILD_WIZARD 1)
endif()
161
162
163
164
if(ENABLE_NLS)
	find_package(Gettext REQUIRED)
	find_package(Intl REQUIRED)
endif()
165
166
167
if(ENABLE_CALL_LOGS_STORAGE)
	find_package(Sqlite3 REQUIRED)
endif()
168
169
170
if(ENABLE_LIME)
	set(HAVE_LIME 1)
endif()
171

172
173
174
175
if(UNIX AND NOT APPLE)
	include(CheckIncludeFiles)
	check_include_files(libudev.h HAVE_LIBUDEV_H)
endif()
176

177
178
# include_directories must be called only UNDER THIS LINE in order to use our
# projects submodules first (we do NOT want to have system headers in first position)
179
180
181
include_directories(
	include/
	coreapi/
182
	${CMAKE_CURRENT_BINARY_DIR}
183
	${CMAKE_CURRENT_BINARY_DIR}/coreapi/
184
	${BELLESIP_INCLUDE_DIRS}
185
	${MEDIASTREAMER2_INCLUDE_DIRS}
johan's avatar
johan committed
186
	${BCTOOLBOX_INCLUDE_DIRS}
187
)
188
189
190
191
192
193
if(ENABLE_TUNNEL)
	include_directories(${TUNNEL_INCLUDE_DIRS})
endif()

include_directories(${XML2_INCLUDE_DIRS})

194
195
196
197
if(ZLIB_FOUND)
	include_directories(${ZLIB_INCLUDE_DIRS})
	set(HAVE_ZLIB 1)
endif()
198
199
if(SQLITE3_FOUND)
	include_directories(${SQLITE3_INCLUDE_DIRS})
200
201
202
203
204
205
	if(ENABLE_MSG_STORAGE)
		add_definitions("-DMSG_STORAGE_ENABLED")
	endif()
	if(ENABLE_CALL_LOGS_STORAGE)
		add_definitions("-DCALL_LOGS_STORAGE_ENABLED")
	endif()
206
endif()
207
208
209
if(INTL_FOUND)
	set(HAVE_INTL 1)
	include_directories(${INTL_INCLUDE_DIRS})
210
endif()
211
if(MSVC)
212
	include_directories(${MSVC_INCLUDE_DIR})
213
214
endif()

215
add_definitions("-DIN_LINPHONE")
216
217
218
if(ENABLE_DEBUG_LOGS)
	add_definitions("-DDEBUG")
endif()
219

220
221
set(STRICT_OPTIONS_CPP )
set(STRICT_OPTIONS_C )
222
set(STRICT_OPTIONS_CXX "-std=c++11")
223
224
set(STRICT_OPTIONS_OBJC )
if(NOT MSVC)
225
	list(APPEND STRICT_OPTIONS_CPP "-Wall" "-Wuninitialized" "-Wno-error=deprecated-declarations")
226
	list(APPEND STRICT_OPTIONS_C "-Wdeclaration-after-statement" "-Wstrict-prototypes" "-Wno-error=strict-prototypes")
227
	if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
228
		list(APPEND STRICT_OPTIONS_CPP "-Qunused-arguments" "-Wno-array-bounds")
229
230
	endif()
	if(APPLE)
231
232
233
234
		list(APPEND STRICT_OPTIONS_CPP "-Wno-error=unknown-warning-option" "-Qunused-arguments" "-Wno-tautological-compare" "-Wno-unused-function" "-Wno-array-bounds")
	endif()
	if(ENABLE_STRICT)
		list(APPEND STRICT_OPTIONS_CPP "-Werror" "-fno-strict-aliasing")
235
236
	endif()
endif()
237
238
239
if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
	list(APPEND STRICT_OPTIONS_CPP "/wd4996")
endif()
240
241
242
243
244
245
if(STRICT_OPTIONS_CPP)
	list(REMOVE_DUPLICATES STRICT_OPTIONS_CPP)
endif()
if(STRICT_OPTIONS_C)
	list(REMOVE_DUPLICATES STRICT_OPTIONS_C)
endif()
246
247


248
set(GETTEXT_PACKAGE "linphone")
249
if(ENABLE_RELATIVE_PREFIX)
250
	set(LINPHONE_DATA_DIR ".")
251
else()
252
	set(LINPHONE_DATA_DIR "${CMAKE_INSTALL_PREFIX}")
253
endif()
254
set(LINPHONE_PLUGINS_DIR "${LINPHONE_DATA_DIR}/lib/liblinphone/plugins")
255
256
257
if(WIN32)
	set(LINPHONE_CONFIG_DIR "Linphone")
endif()
258
259
260
set(PACKAGE_LOCALE_DIR "${LINPHONE_DATA_DIR}/share/locale")
set(PACKAGE_DATA_DIR "${LINPHONE_DATA_DIR}/share")
set(PACKAGE_SOUND_DIR "${LINPHONE_DATA_DIR}/share/sounds/linphone")
Ghislain MARY's avatar
Ghislain MARY committed
261
262
set(PACKAGE_RING_DIR "${PACKAGE_SOUND_DIR}/rings")
set(PACKAGE_FREEDESKTOP_DIR "${PACKAGE_DATA_DIR}/applications")
263
264
265
266
267
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/config.h PROPERTIES GENERATED ON)
add_definitions(-DHAVE_CONFIG_H)


268
269
270
271
272
if(ENABLE_VIDEO)
	add_definitions(-DVIDEO_ENABLED)
endif()


273
274
275
276
277
278
279
if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
	set(EXPORT_TARGETS_NAME "LinphoneBuilder")
else()
	set(EXPORT_TARGETS_NAME "Linphone")
endif()


280
281
add_subdirectory(coreapi)
add_subdirectory(share)
282
283
284
if(ENABLE_CONSOLE_UI)
	add_subdirectory(console)
endif()
285
286
287
if(ENABLE_GTK_UI)
	add_subdirectory(gtk)
	add_subdirectory(pixmaps)
288
	add_subdirectory(po)
289
endif()
290
291
292
if(ENABLE_TOOLS)
	add_subdirectory(tools)
endif()
293
294
295
if(ENABLE_UNIT_TESTS)
	add_subdirectory(tester)
endif()
296
297


298
299
300
301
302
303
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
	"${CMAKE_CURRENT_BINARY_DIR}/LinphoneConfigVersion.cmake"
	VERSION ${LINPHONE_VERSION}
	COMPATIBILITY AnyNewerVersion
)
304
export(EXPORT ${EXPORT_TARGETS_NAME}Targets
305
306
307
308
309
310
	FILE "${CMAKE_CURRENT_BINARY_DIR}/LinphoneTargets.cmake"
)
configure_file(cmake/LinphoneConfig.cmake.in
	"${CMAKE_CURRENT_BINARY_DIR}/LinphoneConfig.cmake"
	@ONLY
)
311

312
set(ConfigPackageLocation lib/cmake/Linphone)
313
install(EXPORT ${EXPORT_TARGETS_NAME}Targets
314
315
316
317
318
319
320
	FILE LinphoneTargets.cmake
	DESTINATION ${ConfigPackageLocation}
)
install(FILES
	"${CMAKE_CURRENT_BINARY_DIR}/LinphoneConfig.cmake"
	"${CMAKE_CURRENT_BINARY_DIR}/LinphoneConfigVersion.cmake"
	DESTINATION ${ConfigPackageLocation}
321
)