CMakeLists.txt 6.81 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.
#
############################################################################

23
cmake_minimum_required(VERSION 2.8.12)
24
project(LINPHONE C CXX)
25

26

27 28 29 30 31 32
set(LINPHONE_MAJOR_VERSION "3")
set(LINPHONE_MINOR_VERSION "7")
set(LINPHONE_MICRO_VERSION "0")
set(LINPHONE_VERSION "${LINPHONE_MAJOR_VERSION}.${LINPHONE_MINOR_VERSION}.${LINPHONE_MICRO_VERSION}")
set(LINPHONE_SO_VERSION "6")

33 34
set(LINPHONE_ALL_LANGS "cs de es fr he hu it ja nb_NO nl pl pt_BR ru sr sv zh_CN zh_TW")

35 36 37

include(CMakeDependentOption)

38
option(ENABLE_STATIC "Build static library (default is shared library)." NO)
39 40 41 42 43
option(ENABLE_CONSOLE_UI "Turn on or off compilation of console interface." YES)
option(ENABLE_DATE "Use build date in internal version number." NO)
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)
44
cmake_dependent_option(ENABLE_NOTIFY "Enable libnotify support." YES "ENABLE_GTK_UI" NO)
45
option(ENABLE_RELATIVE_PREFIX "Find resources relatively to the installation directory." NO)
46
option(ENABLE_TOOLS "Turn on or off compilation of tools." YES)
47 48 49 50
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)
51
option(ENABLE_VIDEO "Build with video support." YES)
52
cmake_dependent_option(ENABLE_ASSISTANT "Turn on assistant compiling." YES "ENABLE_GTK_UI" NO)
53 54


55 56
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/share/cmake/Modules")
57 58

include(CheckIncludeFile)
59
include(CheckSymbolExists)
60 61

if(MSVC)
62
	list(APPEND CMAKE_REQUIRED_INCLUDES "${CMAKE_PREFIX_PATH}/include/MSVC")
63 64 65 66 67
endif()

find_package(BelleSIP REQUIRED)
find_package(MS2 REQUIRED)
find_package(XML2 REQUIRED)
68 69 70
if(ENABLE_UNIT_TESTS)
	find_package(CUnit)
	if(CUNIT_FOUND)
71 72 73 74 75 76
		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()
77 78 79 80 81
	else()
		message(WARNING "Could not find the cunit library!")
		set(ENABLE_UNIT_TESTS OFF CACHE BOOL "Enable compilation of unit tests." FORCE)
	endif()
endif()
82 83 84 85
if(ENABLE_TUNNEL)
	find_package(Tunnel)
	if(NOT TUNNEL_FOUND)
		message(WARNING "Could not find the tunnel library!")
86 87 88
		set(ENABLE_TUNNEL OFF CACHE BOOL "Enable tunnel support." FORCE)
	endif()
endif()
89 90 91 92 93 94
if(ENABLE_MSG_STORAGE)
	find_package(Sqlite3)
	if(NOT SQLITE3_FOUND)
		message(FATAL_ERROR "Could not find the sqlite3 library!")
	endif()
endif()
95 96 97 98 99 100 101
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)
102 103
	endif()
endif()
104 105 106 107 108 109 110 111 112
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()
113
find_package(Gettext)
114

115

116 117 118
include_directories(
	include/
	coreapi/
119
	${CMAKE_CURRENT_BINARY_DIR}
120
	${CMAKE_CURRENT_BINARY_DIR}/coreapi/
121 122 123
	${BELLESIP_INCLUDE_DIRS}
	${MS2_INCLUDE_DIRS}
	${XML2_INCLUDE_DIRS}
124
)
125 126 127 128
if(SQLITE3_FOUND)
	include_directories(${SQLITE3_INCLUDE_DIRS})
	add_definitions("-DMSG_STORAGE_ENABLED")
endif()
129 130 131
if(ENABLE_TUNNEL)
	include_directories(${TUNNEL_INCLUDE_DIRS})
endif()
132 133 134
if(ENABLE_ASSISTANT)
	include_directories(${SOUP_INCLUDE_DIRS})
endif()
135

136 137 138 139
if(MSVC)
	include_directories(${CMAKE_PREFIX_PATH}/include/MSVC)
endif()

140
add_definitions("-DIN_LINPHONE")
141

142

143
if(MSVC)
144 145
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3")
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3")
146
else()
147 148
	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")
149 150 151 152 153 154 155 156 157 158 159 160 161
	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()


162
set(GETTEXT_PACKAGE "linphone")
163
if(ENABLE_RELATIVE_PREFIX)
164
	set(LINPHONE_DATA_DIR ".")
165
else()
166
	set(LINPHONE_DATA_DIR "${CMAKE_INSTALL_PREFIX}")
167
endif()
168 169 170 171
set(LINPHONE_PLUGINS_DIR "${LINPHONE_DATA_DIR}/lib/liblinphone/plugins")
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")
172 173
set(PACKAGE_RING_DIR "${PACKAGE_SOUND_DIR}/rings")
set(PACKAGE_FREEDESKTOP_DIR "${PACKAGE_DATA_DIR}/applications")
174 175 176 177 178
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)


179 180 181 182 183
if(ENABLE_VIDEO)
	add_definitions(-DVIDEO_ENABLED)
endif()


184 185
add_subdirectory(coreapi)
add_subdirectory(share)
186 187 188
if(ENABLE_GTK_UI)
	add_subdirectory(gtk)
	add_subdirectory(pixmaps)
189
	add_subdirectory(po)
190
endif()
191 192 193
if(ENABLE_TOOLS)
	add_subdirectory(tools)
endif()
194 195 196
if(ENABLE_UNIT_TESTS)
	add_subdirectory(tester)
endif()
197 198


199 200 201
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindLinphone.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FindLinphone.cmake)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/FindLinphone.cmake
202 203 204
	DESTINATION share/cmake/Modules
	PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)