CMakeLists.txt 9.1 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")
François Grisez's avatar
François Grisez committed
28
set(LINPHONE_MINOR_VERSION "8")
François Grisez's avatar
François Grisez committed
29
set(LINPHONE_MICRO_VERSION "2")
30
set(LINPHONE_VERSION "${LINPHONE_MAJOR_VERSION}.${LINPHONE_MINOR_VERSION}.${LINPHONE_MICRO_VERSION}")
31
set(LINPHONE_SO_VERSION "7")
32

33
file(GLOB LINPHONE_PO_FILES RELATIVE "${CMAKE_SOURCE_DIR}/po" "${CMAKE_SOURCE_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 45
option(ENABLE_GTK_UI "Turn on or off compilation of gtk interface." YES)
option(ENABLE_LDAP "Enable LDAP support." NO)
option(ENABLE_MSG_STORAGE "Turn on compilation of message storage." YES)
46
cmake_dependent_option(ENABLE_NOTIFY "Enable libnotify support." YES "ENABLE_GTK_UI" NO)
47
option(ENABLE_RELATIVE_PREFIX "Find resources relatively to the installation directory." NO)
48
option(ENABLE_TOOLS "Turn on or off compilation of tools." YES)
49 50 51 52
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)
53
option(ENABLE_VIDEO "Build with video support." YES)
54
cmake_dependent_option(ENABLE_ASSISTANT "Turn on assistant compiling." YES "ENABLE_GTK_UI" NO)
55
option(ENABLE_DEBUG "Turn on or off debug level logs." NO)
56 57


58
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
59

60
include(CheckSymbolExists)
61
include(CMakePushCheckState)
62

63
set(MSVC_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include/MSVC")
64
if(MSVC)
65
	list(APPEND CMAKE_REQUIRED_INCLUDES "${MSVC_INCLUDE_DIR}")
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

	if(ENABLE_GTK_UI)
		if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/intltool_win32.zip")
			message(STATUS "Installing intltool")
			file(DOWNLOAD http://ftp.acc.umu.se/pub/GNOME/binaries/win32/intltool/0.40/intltool_0.40.4-1_win32.zip "${CMAKE_CURRENT_BINARY_DIR}/intltool_win32.zip" SHOW_PROGRESS)
			execute_process(
				COMMAND "${CMAKE_COMMAND}" "-E" "tar" "x" "${CMAKE_CURRENT_BINARY_DIR}/intltool_win32.zip"
				WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}"
			)
		endif()
		if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/gtk+-bundle_win32.zip")
			message(STATUS "Installing GTK")
			file(DOWNLOAD http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.24/gtk+-bundle_2.24.10-20120208_win32.zip "${CMAKE_CURRENT_BINARY_DIR}/gtk+-bundle_win32.zip" SHOW_PROGRESS)
			execute_process(
				COMMAND "${CMAKE_COMMAND}" "-E" "tar" "x" "${CMAKE_CURRENT_BINARY_DIR}/gtk+-bundle_win32.zip"
				WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}"
			)
		endif()
	endif()
	if(ENABLE_ASSISTANT)
		if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/libsoup.zip")
			message(STATUS "Installing libsoup")
			file(DOWNLOAD http://www.linphone.org/files/libsoup_2.24.0-1_win32.zip "${CMAKE_CURRENT_BINARY_DIR}/libsoup.zip" SHOW_PROGRESS)
			execute_process(
				COMMAND "${CMAKE_COMMAND}" "-E" "tar" "x" "${CMAKE_CURRENT_BINARY_DIR}/libsoup.zip"
				WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}"
			)
		endif()
	endif()
95 96 97
endif()

find_package(BelleSIP REQUIRED)
98
find_package(Mediastreamer2 REQUIRED)
99
find_package(XML2 REQUIRED)
100
find_package(Zlib)
101 102 103
if(ENABLE_UNIT_TESTS)
	find_package(CUnit)
	if(CUNIT_FOUND)
104 105 106 107 108 109
		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()
110 111 112 113 114
	else()
		message(WARNING "Could not find the cunit library!")
		set(ENABLE_UNIT_TESTS OFF CACHE BOOL "Enable compilation of unit tests." FORCE)
	endif()
endif()
115 116 117 118
if(ENABLE_TUNNEL)
	find_package(Tunnel)
	if(NOT TUNNEL_FOUND)
		message(WARNING "Could not find the tunnel library!")
119 120 121
		set(ENABLE_TUNNEL OFF CACHE BOOL "Enable tunnel support." FORCE)
	endif()
endif()
122
if(ENABLE_MSG_STORAGE)
123
	find_package(Sqlite3 REQUIRED)
124
endif()
125 126 127 128 129 130 131
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)
132 133
	endif()
endif()
134 135 136 137 138 139 140 141 142
if(ENABLE_ASSISTANT)
	find_package(Soup)
	if(SOUP_FOUND)
		set(BUILD_WIZARD 1)
	else()
		message(WARNING "Could not find the soup library!")
		set(ENABLE_ASSISTANT OFF CACHE BOOL "Turn on assistant compiling." FORCE)
	endif()
endif()
143
find_package(Gettext)
144

145

146 147 148
include_directories(
	include/
	coreapi/
149
	${CMAKE_CURRENT_BINARY_DIR}
150
	${CMAKE_CURRENT_BINARY_DIR}/coreapi/
151
	${BELLESIP_INCLUDE_DIRS}
152
	${MEDIASTREAMER2_INCLUDE_DIRS}
153
	${XML2_INCLUDE_DIRS}
154
)
155 156 157 158
if(ZLIB_FOUND)
	include_directories(${ZLIB_INCLUDE_DIRS})
	set(HAVE_ZLIB 1)
endif()
159 160 161 162
if(SQLITE3_FOUND)
	include_directories(${SQLITE3_INCLUDE_DIRS})
	add_definitions("-DMSG_STORAGE_ENABLED")
endif()
163 164 165
if(ENABLE_TUNNEL)
	include_directories(${TUNNEL_INCLUDE_DIRS})
endif()
166 167 168
if(ENABLE_ASSISTANT)
	include_directories(${SOUP_INCLUDE_DIRS})
endif()
169 170 171
if(ENABLE_DEBUG)
	add_definitions("-DDEBUG")
endif()
172
if(MSVC)
173
	include_directories(${MSVC_INCLUDE_DIR})
174 175
endif()

176
add_definitions("-DIN_LINPHONE")
Ghislain MARY's avatar
Ghislain MARY committed
177

178

179
if(MSVC)
180 181
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3")
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3")
182
else()
183 184
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wuninitialized -Wdeclaration-after-statement -fno-strict-aliasing -Werror")
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wuninitialized -Werror")
185 186 187 188 189 190 191 192 193 194 195 196 197
	if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Qunused-arguments -Wno-array-bounds")
	endif()
	if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
		set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments -Wno-array-bounds")
	endif()
	if(APPLE)
		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=unknown-warning-option -Wno-tautological-compare -Wno-unused-function")
		set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=unknown-warning-option -Wno-tautological-compare -Wno-unused-function")
	endif()
endif()


198
set(GETTEXT_PACKAGE "linphone")
199
if(ENABLE_RELATIVE_PREFIX)
200
	set(LINPHONE_DATA_DIR ".")
201
else()
202
	set(LINPHONE_DATA_DIR "${CMAKE_INSTALL_PREFIX}")
203
endif()
204
set(LINPHONE_PLUGINS_DIR "${LINPHONE_DATA_DIR}/lib/liblinphone/plugins")
205 206 207
if(WIN32)
	set(LINPHONE_CONFIG_DIR "Linphone")
endif()
208 209 210
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
211 212
set(PACKAGE_RING_DIR "${PACKAGE_SOUND_DIR}/rings")
set(PACKAGE_FREEDESKTOP_DIR "${PACKAGE_DATA_DIR}/applications")
213 214 215 216 217
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)


218 219 220 221 222
if(ENABLE_VIDEO)
	add_definitions(-DVIDEO_ENABLED)
endif()


223 224
add_subdirectory(coreapi)
add_subdirectory(share)
225 226 227
if(ENABLE_CONSOLE_UI)
	add_subdirectory(console)
endif()
228 229 230
if(ENABLE_GTK_UI)
	add_subdirectory(gtk)
	add_subdirectory(pixmaps)
231
	add_subdirectory(po)
232
endif()
233 234 235
if(ENABLE_TOOLS)
	add_subdirectory(tools)
endif()
236 237 238
if(ENABLE_UNIT_TESTS)
	add_subdirectory(tester)
endif()
239 240


241 242 243 244 245 246 247 248 249 250 251 252 253 254
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
	"${CMAKE_CURRENT_BINARY_DIR}/LinphoneConfigVersion.cmake"
	VERSION ${LINPHONE_VERSION}
	COMPATIBILITY AnyNewerVersion
)
export(EXPORT LinphoneTargets
	FILE "${CMAKE_CURRENT_BINARY_DIR}/LinphoneTargets.cmake"
	NAMESPACE BelledonneCommunications::
)
configure_file(cmake/LinphoneConfig.cmake.in
	"${CMAKE_CURRENT_BINARY_DIR}/LinphoneConfig.cmake"
	@ONLY
)
255

256 257 258 259 260 261 262 263 264 265
set(ConfigPackageLocation lib/cmake/Linphone)
install(EXPORT LinphoneTargets
	FILE LinphoneTargets.cmake
	NAMESPACE BelledonneCommunications::
	DESTINATION ${ConfigPackageLocation}
)
install(FILES
	"${CMAKE_CURRENT_BINARY_DIR}/LinphoneConfig.cmake"
	"${CMAKE_CURRENT_BINARY_DIR}/LinphoneConfigVersion.cmake"
	DESTINATION ${ConfigPackageLocation}
266
)