CMakeLists.txt 12.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
############################################################################
# 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
19
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 21 22
#
############################################################################

Ghislain MARY's avatar
Ghislain MARY committed
23
cmake_minimum_required(VERSION 3.0)
Ronan's avatar
Ronan committed
24
project(linphone VERSION 3.12.0 LANGUAGES C CXX)
25

26

27 28 29 30
set(LINPHONE_MAJOR_VERSION ${PROJECT_VERSION_MAJOR})
set(LINPHONE_MINOR_VERSION ${PROJECT_VERSION_MINOR})
set(LINPHONE_MICRO_VERSION ${PROJECT_VERSION_PATCH})
set(LINPHONE_VERSION ${PROJECT_VERSION})
31
set(LINPHONE_SO_VERSION "9")
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 40
option(ENABLE_SHARED "Build shared library." YES)
option(ENABLE_STATIC "Build static library." YES)
41 42
option(ENABLE_CONSOLE_UI "Turn on or off compilation of console interface." YES)
option(ENABLE_DATE "Use build date in internal version number." NO)
43
option(ENABLE_DAEMON "Enable the linphone daemon interface." YES)
44
option(ENABLE_DOC "Enable documentation generation with Doxygen." YES)
45
option(ENABLE_JAVADOC "Add a target to generate documentation for Java API" NO)
46
option(ENABLE_GTK_UI "Turn on or off compilation of gtk interface." NO)
47
option(ENABLE_LDAP "Enable LDAP support." NO)
48
option(ENABLE_SQLITE_STORAGE "Turn on compilation sqlite storage, for messages, contacts, history" YES)
49
cmake_dependent_option(ENABLE_LIME "Enable Instant Messaging Encryption." YES "ENABLE_SQLITE_STORAGE" NO)
50
cmake_dependent_option(ENABLE_NOTIFY "Enable libnotify support." YES "ENABLE_GTK_UI;NOT APPLE" NO)
51
option(ENABLE_RELATIVE_PREFIX "Find resources relatively to the installation directory." NO)
52
option(ENABLE_STRICT "Build with strict compile options." YES)
53
option(ENABLE_TOOLS "Turn on or off compilation of tools." YES)
54 55 56
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)
Ghislain MARY's avatar
Ghislain MARY committed
57
option(ENABLE_UPDATE_CHECK "Enable update check." NO)
58
option(ENABLE_VIDEO "Build with video support." YES)
59
cmake_dependent_option(ENABLE_ASSISTANT "Turn on assistant compiling." YES "ENABLE_GTK_UI" NO)
60
option(ENABLE_DEBUG_LOGS "Turn on or off debug level logs." NO)
61
option(ENABLE_NLS "Build with internationalisation support" YES)
62
option(ENABLE_VCARD "Turn on compilation of vcard4 support." YES)
63
option(ENABLE_ROOTCA_DOWNLOAD "Download rootca.pem at build time." YES)
Ghislain MARY's avatar
Ghislain MARY committed
64
option(ENABLE_CXX_WRAPPER "Build the C++ wrapper for Liblinphone." YES)
65
option(ENABLE_CSHARP_WRAPPER "Build the C# wrapper for Liblinphone." OFF)
66

67 68 69
set(CMAKE_CXX_STANDARD 11)


70 71 72 73 74
if(ENABLE_STATIC)
	set(LINPHONE_LIBS_FOR_TOOLS linphone-static)
else()
	set(LINPHONE_LIBS_FOR_TOOLS linphone)
endif()
François Grisez's avatar
François Grisez committed
75 76 77
if(WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
	list(APPEND LINPHONE_LIBS_FOR_TOOLS "Ws2_32")
endif()
78

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

81
include(CheckSymbolExists)
82
include(CMakePushCheckState)
83 84 85 86 87 88
include(GNUInstallDirs)

if(NOT CMAKE_INSTALL_RPATH AND CMAKE_INSTALL_PREFIX)
	set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR})
	message(STATUS "Setting install rpath to ${CMAKE_INSTALL_RPATH}")
endif()
89

90
set(MSVC_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include/MSVC")
91
if(MSVC)
92
	list(APPEND CMAKE_REQUIRED_INCLUDES "${MSVC_INCLUDE_DIR}")
93 94
endif()

95 96 97
# find_package should be invoked here to check for libraries - however do NOT
# call include_directories here (see below)

98 99 100 101 102 103 104 105 106 107 108 109 110 111
if (ENABLE_VCARD)
	if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
		include("${EP_belcard_CONFIG_DIR}/BelcardConfig.cmake")
	else()
		find_package(Belcard)
	endif()
	if(NOT BELCARD_FOUND)
		message(WARNING "Could not find the belcard library!")
		set(ENABLE_VCARD OFF CACHE BOOL "Enable vcard support." FORCE)
	else()
		add_definitions(-DVCARD_ENABLED)
	endif()
endif()

112 113 114
if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
	include("${EP_bellesip_CONFIG_DIR}/BelleSIPConfig.cmake")
	include("${EP_ms2_CONFIG_DIR}/Mediastreamer2Config.cmake")
115
	include("${EP_ortp_CONFIG_DIR}/ORTPConfig.cmake")
116
	set(BcToolbox_FIND_COMPONENTS tester)
jehan's avatar
jehan committed
117
	include("${EP_bctoolbox_CONFIG_DIR}/BcToolboxConfig.cmake")
Ronan's avatar
Ronan committed
118
	include("${EP_belr_CONFIG_DIR}/BelrConfig.cmake")
119 120 121
else()
	find_package(BelleSIP REQUIRED)
	find_package(Mediastreamer2 REQUIRED)
122
	find_package(ORTP REQUIRED)
123
	find_package(BcToolbox 0.0.3 REQUIRED OPTIONAL_COMPONENTS tester)
Ronan's avatar
Ronan committed
124
	find_package(Belr REQUIRED)
125
endif()
126
find_package(XML2 REQUIRED)
Benjamin REIS's avatar
Benjamin REIS committed
127
find_package(Soci)
128
find_package(Zlib)
129
if(ENABLE_TUNNEL)
130 131 132 133 134
	if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
		include("${EP_tunnel_CONFIG_DIR}/TunnelConfig.cmake")
	else()
		find_package(Tunnel)
	endif()
135 136
	if(NOT TUNNEL_FOUND)
		message(WARNING "Could not find the tunnel library!")
137 138 139
		set(ENABLE_TUNNEL OFF CACHE BOOL "Enable tunnel support." FORCE)
	endif()
endif()
140
if(ENABLE_SQLITE_STORAGE)
141
	find_package(Sqlite3 REQUIRED)
142
endif()
143 144 145 146 147 148 149
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)
150 151
	endif()
endif()
152 153 154 155 156 157 158 159 160
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()
161 162 163 164 165 166 167 168 169
	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()
170 171 172 173
endif()
if(ENABLE_ASSISTANT)
	set(BUILD_WIZARD 1)
endif()
174 175 176 177
if(ENABLE_NLS)
	find_package(Gettext REQUIRED)
	find_package(Intl REQUIRED)
endif()
178 179
if(ENABLE_LIME)
	#bzrtp is only required for LIME
johan's avatar
johan committed
180 181 182
	if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
		include("${EP_bzrtp_CONFIG_DIR}/BZRTPConfig.cmake")
	else()
183
		find_package(BZRTP REQUIRED)
johan's avatar
johan committed
184
	endif()
185
	set(HAVE_LIME 1)
186
endif()
187
if(ENABLE_CXX_WRAPPER OR ENABLE_CSHARP_WRAPPER)
188 189
	find_package(PythonInterp REQUIRED)
endif()
190

191 192 193 194
if(UNIX AND NOT APPLE)
	include(CheckIncludeFiles)
	check_include_files(libudev.h HAVE_LIBUDEV_H)
endif()
195

196 197 198 199 200
set(LINPHONE_LDFLAGS "${BELLESIP_LDFLAGS} ${MEDIASTREAMER2_LDFLAGS}")
if(BELCARD_FOUND AND APPLE)
    set(LINPHONE_LDFLAGS "${LINPHONE_LDFLAGS} -stdlib=libc++")
endif()

201 202
# 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)
203
include_directories(
204
	${CMAKE_CURRENT_BINARY_DIR}
205
	${CMAKE_CURRENT_BINARY_DIR}/coreapi/
206 207 208
	coreapi/
	include/
	src/
209 210
)
set(LINPHONE_INCLUDE_DIRS
211
	${BELLESIP_INCLUDE_DIRS}
212
	${MEDIASTREAMER2_INCLUDE_DIRS}
213
	${BCTOOLBOX_CORE_INCLUDE_DIRS}
Ronan's avatar
Ronan committed
214
	${BELR_INCLUDE_DIRS}
215
)
johan's avatar
johan committed
216 217 218
if (BZRTP_FOUND)
	list(APPEND LINPHONE_INCLUDE_DIRS ${BZRTP_INCLUDE_DIRS})
endif()
Ghislain MARY's avatar
Ghislain MARY committed
219 220 221
if(ANDROID)
	include_directories(${CMAKE_CURRENT_BINARY_DIR}/java)
endif()
222
if(ENABLE_TUNNEL)
223
	list(APPEND LINPHONE_INCLUDE_DIRS ${TUNNEL_INCLUDE_DIRS})
224
endif()
225
if (ENABLE_VCARD)
226
	list(APPEND LINPHONE_INCLUDE_DIRS ${BELCARD_INCLUDE_DIRS})
227
endif()
228

229
list(APPEND LINPHONE_INCLUDE_DIRS ${XML2_INCLUDE_DIRS})
230

231
if(ZLIB_FOUND)
232
	list(APPEND LINPHONE_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS})
233 234
	set(HAVE_ZLIB 1)
endif()
235
if(SQLITE3_FOUND)
236
	list(APPEND LINPHONE_INCLUDE_DIRS ${SQLITE3_INCLUDE_DIRS})
237
	if(ENABLE_SQLITE_STORAGE)
238
		add_definitions("-DSQLITE_STORAGE_ENABLED")
239
	endif()
240
endif()
241 242
if(INTL_FOUND)
	set(HAVE_INTL 1)
243
	list(APPEND LINPHONE_INCLUDE_DIRS ${INTL_INCLUDE_DIRS})
244
endif()
245
if(MSVC)
246
	include_directories(${MSVC_INCLUDE_DIR})
247 248
endif()

249
add_definitions("-DLINPHONE_EXPORTS")
Ronan's avatar
Ronan committed
250
set(LINPHONE_CPPFLAGS ${BELCARD_CPPFLAGS} ${BELLESIP_CPPFLAGS} ${MEDIASTREAMER2_CPPFLAGS} ${BCTOOLBOX_CPPFLAGS} ${BELR_CPPFLAGS})
251 252
if(ENABLE_STATIC)
	list(APPEND LINPHONE_CPPFLAGS "-DLINPHONE_STATIC")
253 254
endif()
if(LINPHONE_CPPFLAGS)
Ghislain MARY's avatar
Ghislain MARY committed
255
	list(REMOVE_DUPLICATES LINPHONE_CPPFLAGS)
256 257
	add_definitions(${LINPHONE_CPPFLAGS})
endif()
258

259 260 261
if(ENABLE_DEBUG_LOGS)
	add_definitions("-DDEBUG")
endif()
262

263 264
set(STRICT_OPTIONS_CPP )
set(STRICT_OPTIONS_C )
François Grisez's avatar
François Grisez committed
265
set(STRICT_OPTIONS_CXX )
266
set(STRICT_OPTIONS_OBJC )
267 268
if(MSVC)
	list(APPEND STRICT_OPTIONS_CPP "/wd4995") # Disable "name was marked as #pragma deprecated" warnings
269
	list(APPEND STRICT_OPTIONS_CPP "/wd4996") # Disable deprecated function warnings
270 271 272 273
	if(ENABLE_STRICT)
		list(APPEND STRICT_OPTIONS_CPP "/WX")
	endif()
else()
274
	list(APPEND STRICT_OPTIONS_CPP "-Wall" "-Wuninitialized" "-Wno-error=deprecated-declarations")
275
	list(APPEND STRICT_OPTIONS_C "-Wstrict-prototypes" "-Werror=strict-prototypes")
276 277 278
	if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
		list(APPEND STRICT_OPTIONS_C "-fno-inline-small-functions")
	endif()
279
	if(CMAKE_C_COMPILER_ID MATCHES "Clang")
280
		list(APPEND STRICT_OPTIONS_CPP "-Qunused-arguments" "-Wno-array-bounds")
281
	endif()
282
	if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
283 284
		list(APPEND STRICT_OPTIONS_CXX "-x c++")
	endif()
285
	if(APPLE)
286 287 288
		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)
Simon Morlat's avatar
Simon Morlat committed
289 290
		list(APPEND STRICT_OPTIONS_C "-Werror" "-Wextra" "-Wno-unused-parameter" "-Wno-missing-field-initializers" "-fno-strict-aliasing")
		list(APPEND STRICT_OPTIONS_CPP "-Werror" "-Wextra" "-Wno-unused-parameter" "-Wno-missing-field-initializers" "-fno-strict-aliasing")
291 292
	endif()
endif()
293 294 295 296 297 298
if(STRICT_OPTIONS_CPP)
	list(REMOVE_DUPLICATES STRICT_OPTIONS_CPP)
endif()
if(STRICT_OPTIONS_C)
	list(REMOVE_DUPLICATES STRICT_OPTIONS_C)
endif()
299 300


301
set(GETTEXT_PACKAGE "linphone")
302
if(ENABLE_RELATIVE_PREFIX)
303
	set(LINPHONE_DATA_DIR ".")
304
else()
305
	set(LINPHONE_DATA_DIR "${CMAKE_INSTALL_PREFIX}")
306
endif()
307
set(LINPHONE_PLUGINS_DIR "${LINPHONE_DATA_DIR}/${CMAKE_INSTALL_LIBDIR}/liblinphone/plugins")
308 309 310
if(WIN32)
	set(LINPHONE_CONFIG_DIR "Linphone")
endif()
311 312 313
set(PACKAGE_LOCALE_DIR "${LINPHONE_DATA_DIR}/${CMAKE_INSTALL_DATADIR}/locale")
set(PACKAGE_DATA_DIR "${LINPHONE_DATA_DIR}/${CMAKE_INSTALL_DATADIR}")
set(PACKAGE_SOUND_DIR "${LINPHONE_DATA_DIR}/${CMAKE_INSTALL_DATADIR}/sounds/linphone")
Ghislain MARY's avatar
Ghislain MARY committed
314 315
set(PACKAGE_RING_DIR "${PACKAGE_SOUND_DIR}/rings")
set(PACKAGE_FREEDESKTOP_DIR "${PACKAGE_DATA_DIR}/applications")
316 317 318 319 320
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)


321 322 323 324 325
if(ENABLE_VIDEO)
	add_definitions(-DVIDEO_ENABLED)
endif()


326 327 328 329 330 331
if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
	set(EXPORT_TARGETS_NAME "LinphoneBuilder")
else()
	set(EXPORT_TARGETS_NAME "Linphone")
endif()

332
add_subdirectory(include)
333
add_subdirectory(java)
334
add_subdirectory(src)
335 336
add_subdirectory(coreapi)
add_subdirectory(share)
337 338 339
if(ENABLE_CONSOLE_UI)
	add_subdirectory(console)
endif()
340 341 342
if(ENABLE_DAEMON)
	add_subdirectory(daemon)
endif()
343 344 345
if(ENABLE_GTK_UI)
	add_subdirectory(gtk)
	add_subdirectory(pixmaps)
346
	add_subdirectory(po)
347
endif()
348 349 350
if(ENABLE_TOOLS)
	add_subdirectory(tools)
endif()
351
if(ENABLE_UNIT_TESTS AND BCTOOLBOX_TESTER_FOUND)
352 353
	add_subdirectory(tester)
endif()
354
if(ENABLE_CXX_WRAPPER)
355 356
	add_subdirectory(wrappers/cpp)
endif()
357 358 359
if(ENABLE_CSHARP_WRAPPER)
	add_subdirectory(wrappers/csharp)
endif()
360

361 362 363 364 365 366
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
	"${CMAKE_CURRENT_BINARY_DIR}/LinphoneConfigVersion.cmake"
	VERSION ${LINPHONE_VERSION}
	COMPATIBILITY AnyNewerVersion
)
367
export(EXPORT ${EXPORT_TARGETS_NAME}Targets
368 369 370 371 372 373
	FILE "${CMAKE_CURRENT_BINARY_DIR}/LinphoneTargets.cmake"
)
configure_file(cmake/LinphoneConfig.cmake.in
	"${CMAKE_CURRENT_BINARY_DIR}/LinphoneConfig.cmake"
	@ONLY
)
374

375
set(CONFIG_PACKAGE_LOCATION "${CMAKE_INSTALL_DATADIR}/Linphone/cmake")
376
install(EXPORT ${EXPORT_TARGETS_NAME}Targets
377
	FILE LinphoneTargets.cmake
378
	DESTINATION ${CONFIG_PACKAGE_LOCATION}
379 380 381 382
)
install(FILES
	"${CMAKE_CURRENT_BINARY_DIR}/LinphoneConfig.cmake"
	"${CMAKE_CURRENT_BINARY_DIR}/LinphoneConfigVersion.cmake"
383
	DESTINATION ${CONFIG_PACKAGE_LOCATION}
384
)
385

jehan's avatar
jehan committed
386
add_subdirectory(build)