config-flexisip-rpm.cmake 4.78 KB
Newer Older
1
############################################################################
Ghislain MARY's avatar
Ghislain MARY committed
2
# config-flexisip-rpm.cmake
3
# Copyright (C) 2014-2018  Belledonne Communications, Grenoble France
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#
############################################################################
#
# 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
#
############################################################################

23
include(GNUInstallDirs)
24
include(${CMAKE_SOURCE_DIR}/cmake/FindLinuxPlatform.cmake)
25

26 27
# Check if we have everything to compile correctly

28
function(CHECK_LIBRARY libname)
29 30
	find_library(${libname}_LIBRARY
		NAMES ${libname}
31
		PATHS /usr/lib/mysql/
32 33 34 35 36 37
	)
	if(NOT ${libname}_LIBRARY)
		message(FATAL_ERROR "Could not find the ${libname} library, which is needed for RPMBuild of flexisip")
	else()
		message(STATUS "Found ${libname} : ${${libname}_LIBRARY}.")
	endif()
38
endfunction()
39

40 41
set(FLEXISIP_LIBDEPS ssl mysqlclient_r mysqlclient)

42 43 44
foreach(LIBNAME ${FLEXISIP_LIBDEPS})
	check_library(${LIBNAME})
endforeach()
45

46 47 48 49 50 51 52 53


find_program(LSB_RELEASE lsb_release)
execute_process(COMMAND ${LSB_RELEASE} -is OUTPUT_VARIABLE LSB_RELEASE_DISTRO OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${LSB_RELEASE} -cs OUTPUT_VARIABLE LSB_RELEASE_DISTRO_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)



54 55 56
# Force build of RPM packages
set(LINPHONE_BUILDER_ENABLE_RPM_PACKAGING YES CACHE BOOL "" FORCE)

57 58
# Force use of system dependencies to build RPM packages
set(LINPHONE_BUILDER_USE_SYSTEM_DEPENDENCIES YES CACHE BOOL "" FORCE)
59

Ghislain MARY's avatar
Ghislain MARY committed
60
# Define default values for the flexisip builder options
61
set(DEFAULT_VALUE_ENABLE_CXX_WRAPPER ON)
62
if(LSB_RELEASE_DISTRO STREQUAL "Debian" AND (LSB_RELEASE_DISTRO_VERSION STREQUAL "wheezy" OR LSB_RELEASE_DISTRO_VERSION STREQUAL "jessie"))
63 64 65 66
       set(DEFAULT_VALUE_ENABLE_POLARSSL ON)
else()
       set(DEFAULT_VALUE_ENABLE_MBEDTLS ON)
endif()
Simon Morlat's avatar
Simon Morlat committed
67
set(DEFAULT_VALUE_ENABLE_TRANSCODER ON)
Ghislain MARY's avatar
Ghislain MARY committed
68
set(DEFAULT_VALUE_ENABLE_REDIS ON)
69
set(DEFAULT_VALUE_ENABLE_SOCI ON)
Simon Morlat's avatar
Simon Morlat committed
70
set(DEFAULT_VALUE_ENABLE_UNIT_TESTS OFF)
71
set(ENABLE_SRTP NO CACHE BOOL "" FORCE) # Mainly to avoid issues with old libsrtp (sha1_update conflict with polarssl)
72

73
set(DEFAULT_VALUE_CMAKE_LINKING_TYPE "-DENABLE_SHARED=YES" "-DENABLE_STATIC=NO")
74

75 76
# Global configuration
set(LINPHONE_BUILDER_HOST "")
77
set(RPM_INSTALL_PREFIX "/opt/belledonne-communications")
78
set(LINPHONE_BUILDER_RPMBUILD_PACKAGE_PREFIX "bc-")
79

80 81
# Adjust PKG_CONFIG_PATH to include install directory
if(UNIX)
82 83 84
	set(LINPHONE_BUILDER_PKG_CONFIG_PATH "${RPM_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig/:${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig/:$ENV{PKG_CONFIG_PATH}:/usr/${CMAKE_INSTALL_LIBDIR}/pkgconfig/:/usr/${CMAKE_INSTALL_LIBDIR}/x86_64-linux-gnu/pkgconfig/:/usr/share/pkgconfig/:/usr/local/${CMAKE_INSTALL_LIBDIR}/pkgconfig/:/opt/local/${CMAKE_INSTALL_LIBDIR}/pkgconfig/")
	message(STATUS "PKG CONFIG PATH: ${LINPHONE_BUILDER_PKG_CONFIG_PATH}")
	message(STATUS "LIBDIR: ${LIBDIR}")
85 86
endif()

87

88 89 90
# Include builders
include(builders/CMakeLists.txt)

91 92 93
lcb_builder_cmake_options(linphone
	"-DENABLE_CONSOLE_UI=NO"
	"-DENABLE_DAEMON=NO"
94
)
95

Ghislain MARY's avatar
Ghislain MARY committed
96 97 98
lcb_builder_cmake_options(soci
	"-DWITH_MYSQL=ON"
	"-DWITH_POSTGRESQL=ON"
Simon Morlat's avatar
Simon Morlat committed
99
	"-DSOCI_SHARED=ON"
Ghislain MARY's avatar
Ghislain MARY committed
100 101
)

102
# prepare the RPMBUILD options that we need to pass
103
set(LINPHONE_BUILDER_RPMBUILD_GLOBAL_OPTIONS "--define '_mandir %{_prefix}'")
104
if(PLATFORM STREQUAL "Debian")
105
	# dependencies cannot be checked by rpmbuild in debian
106
	set(LINPHONE_BUILDER_RPMBUILD_GLOBAL_OPTIONS "${LINPHONE_BUILDER_RPMBUILD_GLOBAL_OPTIONS} --nodeps")
107

108
	# dist is not defined in debian for rpmbuild..
109
	set(LINPHONE_BUILDER_RPMBUILD_GLOBAL_OPTIONS "${LINPHONE_BUILDER_RPMBUILD_GLOBAL_OPTIONS} --define 'dist .deb'")
110

111
	# debian has multi-arch lib dir instead of lib and lib64
112
	set(LINPHONE_BUILDER_RPMBUILD_GLOBAL_OPTIONS "${LINPHONE_BUILDER_RPMBUILD_GLOBAL_OPTIONS} --define '_lib lib'")
jehan's avatar
jehan committed
113 114

	# debian has multi-arch lib dir instead of lib and lib64
115
	set(LINPHONE_BUILDER_RPMBUILD_GLOBAL_OPTIONS "${LINPHONE_BUILDER_RPMBUILD_GLOBAL_OPTIONS} --define '_libdir %{_prefix}/%{_lib}'")
116

117
	# some debians are using dash as shell, which doesn't support "export -n", so we override and use bash
118
	set(LINPHONE_BUILDER_RPMBUILD_GLOBAL_OPTIONS "${LINPHONE_BUILDER_RPMBUILD_GLOBAL_OPTIONS} --define '_buildshell /bin/bash'")
119
endif()