CMakeLists.txt 10.8 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 VERSION 3.9.1 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})
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 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_DOC "Enable documentation generation with Doxygen." YES)
44 45
option(ENABLE_GTK_UI "Turn on or off compilation of gtk interface." YES)
option(ENABLE_LDAP "Enable LDAP support." NO)
46
option(ENABLE_LIME "Enable Instant Messaging Encryption." NO)
47
option(ENABLE_SQLITE_STORAGE "Turn on compilation sqlite storage, for messages, contacts, history" YES)
48
cmake_dependent_option(ENABLE_NOTIFY "Enable libnotify support." YES "ENABLE_GTK_UI;NOT APPLE" NO)
49
option(ENABLE_RELATIVE_PREFIX "Find resources relatively to the installation directory." NO)
50
option(ENABLE_STRICT "Build with strict compile options." YES)
51
option(ENABLE_TOOLS "Turn on or off compilation of tools." YES)
52 53 54 55
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)
56
option(ENABLE_VIDEO "Build with video support." YES)
57
cmake_dependent_option(ENABLE_ASSISTANT "Turn on assistant compiling." YES "ENABLE_GTK_UI" NO)
58
option(ENABLE_DEBUG_LOGS "Turn on or off debug level logs." NO)
59
option(ENABLE_NLS "Build with internationalisation support" YES)
60
option(ENABLE_VCARD "Turn on compilation of vcard4 support." YES)
61 62


63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
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()


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
if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
	include("${EP_bellesip_CONFIG_DIR}/BelleSIPConfig.cmake")
	include("${EP_ms2_CONFIG_DIR}/Mediastreamer2Config.cmake")
101
	set(BcToolbox_FIND_COMPONENTS tester)
jehan's avatar
jehan committed
102
	include("${EP_bctoolbox_CONFIG_DIR}/BcToolboxConfig.cmake")
103 104 105
else()
	find_package(BelleSIP REQUIRED)
	find_package(Mediastreamer2 REQUIRED)
106
	find_package(BcToolbox 0.0.3 REQUIRED OPTIONAL_COMPONENTS tester)
107
endif()
108
find_package(XML2 REQUIRED)
109
find_package(Zlib)
110
if(ENABLE_TUNNEL)
111 112 113 114 115
	if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
		include("${EP_tunnel_CONFIG_DIR}/TunnelConfig.cmake")
	else()
		find_package(Tunnel)
	endif()
116 117
	if(NOT TUNNEL_FOUND)
		message(WARNING "Could not find the tunnel library!")
118 119 120
		set(ENABLE_TUNNEL OFF CACHE BOOL "Enable tunnel support." FORCE)
	endif()
endif()
121
if(ENABLE_SQLITE_STORAGE)
122
	find_package(Sqlite3 REQUIRED)
123
endif()
124 125 126 127 128 129 130
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)
131 132
	endif()
endif()
133 134 135 136 137 138 139 140 141
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()
142 143 144 145 146 147 148 149 150
	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()
151 152 153 154
endif()
if(ENABLE_ASSISTANT)
	set(BUILD_WIZARD 1)
endif()
155 156 157 158
if(ENABLE_NLS)
	find_package(Gettext REQUIRED)
	find_package(Intl REQUIRED)
endif()
159 160 161
if(ENABLE_LIME)
	set(HAVE_LIME 1)
endif()
162
if (ENABLE_VCARD)
163 164 165 166 167
	if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
		include("${EP_belcard_CONFIG_DIR}/BelcardConfig.cmake")
	else()
		find_package(Belcard)
	endif()
168 169 170
	if(NOT BELCARD_FOUND)
		message(WARNING "Could not find the belcard library!")
		set(ENABLE_VCARD OFF CACHE BOOL "Enable vcard support." FORCE)
Sylvain Berfini's avatar
Sylvain Berfini committed
171 172
	else()
		add_definitions(-DVCARD_ENABLED)
173
	endif()
174
endif()
175

176 177 178 179
if(UNIX AND NOT APPLE)
	include(CheckIncludeFiles)
	check_include_files(libudev.h HAVE_LIBUDEV_H)
endif()
180

181 182
# 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)
183 184 185
include_directories(
	include/
	coreapi/
186
	${CMAKE_CURRENT_BINARY_DIR}
187
	${CMAKE_CURRENT_BINARY_DIR}/coreapi/
188
	${BELLESIP_INCLUDE_DIRS}
189
	${MEDIASTREAMER2_INCLUDE_DIRS}
190
	${BCTOOLBOX_CORE_INCLUDE_DIRS}
191
)
192 193 194
if(ENABLE_TUNNEL)
	include_directories(${TUNNEL_INCLUDE_DIRS})
endif()
195 196 197
if (ENABLE_VCARD)
	include_directories(${BELCARD_INCLUDE_DIRS})
endif()
198 199 200

include_directories(${XML2_INCLUDE_DIRS})

201 202 203 204
if(ZLIB_FOUND)
	include_directories(${ZLIB_INCLUDE_DIRS})
	set(HAVE_ZLIB 1)
endif()
205 206
if(SQLITE3_FOUND)
	include_directories(${SQLITE3_INCLUDE_DIRS})
207
	if(ENABLE_SQLITE_STORAGE)
208
		add_definitions("-DSQLITE_STORAGE_ENABLED")
209
	endif()
210
endif()
211 212 213
if(INTL_FOUND)
	set(HAVE_INTL 1)
	include_directories(${INTL_INCLUDE_DIRS})
214
endif()
215
if(MSVC)
216
	include_directories(${MSVC_INCLUDE_DIR})
217 218
endif()

219
add_definitions("-DIN_LINPHONE")
220 221 222
if(ENABLE_DEBUG_LOGS)
	add_definitions("-DDEBUG")
endif()
223 224 225
if(ANDROID)
	add_definitions("-DANDROID")
endif()
226

227 228
set(STRICT_OPTIONS_CPP )
set(STRICT_OPTIONS_C )
François Grisez's avatar
François Grisez committed
229
set(STRICT_OPTIONS_CXX )
230
set(STRICT_OPTIONS_OBJC )
231 232 233 234 235 236
if(MSVC)
	list(APPEND STRICT_OPTIONS_CPP "/wd4995") # Disable "name was marked as #pragma deprecated" warnings
	if(ENABLE_STRICT)
		list(APPEND STRICT_OPTIONS_CPP "/WX")
	endif()
else()
237
	list(APPEND STRICT_OPTIONS_CPP "-Wall" "-Wuninitialized" "-Wno-error=deprecated-declarations")
238
	list(APPEND STRICT_OPTIONS_C "-Wdeclaration-after-statement" "-Wstrict-prototypes" "-Wno-error=strict-prototypes")
239
	if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
240
		list(APPEND STRICT_OPTIONS_CPP "-Qunused-arguments" "-Wno-array-bounds")
241 242
	endif()
	if(APPLE)
243 244 245 246
		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")
247 248
	endif()
endif()
249 250 251
if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
	list(APPEND STRICT_OPTIONS_CPP "/wd4996")
endif()
252 253 254 255 256 257
if(STRICT_OPTIONS_CPP)
	list(REMOVE_DUPLICATES STRICT_OPTIONS_CPP)
endif()
if(STRICT_OPTIONS_C)
	list(REMOVE_DUPLICATES STRICT_OPTIONS_C)
endif()
258 259


260
set(GETTEXT_PACKAGE "linphone")
261
if(ENABLE_RELATIVE_PREFIX)
262
	set(LINPHONE_DATA_DIR ".")
263
else()
264
	set(LINPHONE_DATA_DIR "${CMAKE_INSTALL_PREFIX}")
265
endif()
266
set(LINPHONE_PLUGINS_DIR "${LINPHONE_DATA_DIR}/${CMAKE_INSTALL_LIBDIR}/liblinphone/plugins")
267 268 269
if(WIN32)
	set(LINPHONE_CONFIG_DIR "Linphone")
endif()
270 271 272
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
273 274
set(PACKAGE_RING_DIR "${PACKAGE_SOUND_DIR}/rings")
set(PACKAGE_FREEDESKTOP_DIR "${PACKAGE_DATA_DIR}/applications")
275 276 277 278 279
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)


280 281 282 283 284
if(ENABLE_VIDEO)
	add_definitions(-DVIDEO_ENABLED)
endif()


285 286 287 288 289 290 291
if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
	set(EXPORT_TARGETS_NAME "LinphoneBuilder")
else()
	set(EXPORT_TARGETS_NAME "Linphone")
endif()


292
add_subdirectory(java)
293 294
add_subdirectory(coreapi)
add_subdirectory(share)
295 296 297
if(ENABLE_CONSOLE_UI)
	add_subdirectory(console)
endif()
298 299 300
if(ENABLE_GTK_UI)
	add_subdirectory(gtk)
	add_subdirectory(pixmaps)
301
	add_subdirectory(po)
302
endif()
303 304 305
if(ENABLE_TOOLS)
	add_subdirectory(tools)
endif()
306
if(ENABLE_UNIT_TESTS AND BCTOOLBOX_TESTER_FOUND)
307 308
	add_subdirectory(tester)
endif()
309 310


311 312 313 314 315 316
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
	"${CMAKE_CURRENT_BINARY_DIR}/LinphoneConfigVersion.cmake"
	VERSION ${LINPHONE_VERSION}
	COMPATIBILITY AnyNewerVersion
)
317
export(EXPORT ${EXPORT_TARGETS_NAME}Targets
318 319 320 321 322 323
	FILE "${CMAKE_CURRENT_BINARY_DIR}/LinphoneTargets.cmake"
)
configure_file(cmake/LinphoneConfig.cmake.in
	"${CMAKE_CURRENT_BINARY_DIR}/LinphoneConfig.cmake"
	@ONLY
)
324

325
set(CONFIG_PACKAGE_LOCATION "${CMAKE_INSTALL_DATADIR}/Linphone/cmake")
326
install(EXPORT ${EXPORT_TARGETS_NAME}Targets
327
	FILE LinphoneTargets.cmake
328
	DESTINATION ${CONFIG_PACKAGE_LOCATION}
329 330 331 332
)
install(FILES
	"${CMAKE_CURRENT_BINARY_DIR}/LinphoneConfig.cmake"
	"${CMAKE_CURRENT_BINARY_DIR}/LinphoneConfigVersion.cmake"
333
	DESTINATION ${CONFIG_PACKAGE_LOCATION}
334
)