config-desktop-common.cmake 5.73 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
############################################################################
# config-desktop.cmake
# 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 23

# Define options that are specific to the desktop config
24 25 26
lcb_add_option("Theora" "Theora video encoding/decoding support." "${DEFAULT_VALUE_ENABLE_THEORA}")
lcb_add_option("Static only" "Enable compilation of libraries in static mode." "${DEFAULT_VALUE_ENABLE_STATIC_ONLY}")
lcb_add_option("Packaging" "Enable packaging" "${DEFAULT_VALUE_ENABLE_PACKAGING}")
27
lcb_add_option("Source packaging" "Enable source packaging" "${DEFAULT_VALUE_ENABLE_SOURCE_PACKAGING}")
28 29 30
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
	set(LINPHONE_BUILDER_LDFLAGS "${LINPHONE_BUILDER_LDFLAGS} -Wl,--fatal-warnings -Wl,-warn-common")
endif()
31 32

if(ENABLE_STATIC_ONLY)
33 34 35 36
	set(DEFAULT_VALUE_CMAKE_LINKING_TYPE "-DENABLE_SHARED=NO" "-DENABLE_STATIC=YES")
else()
	set(DEFAULT_VALUE_CMAKE_LINKING_TYPE "-DENABLE_SHARED=YES" "-DENABLE_STATIC=NO")
endif()
37

38 39 40 41 42 43 44 45 46 47 48 49
# Global configuration
if(APPLE)
	if(NOT CMAKE_OSX_DEPLOYMENT_TARGET) #is it still useful?
		#without instruction chose to target lower version between current machine and current used SDK
		execute_process(COMMAND sw_vers -productVersion  COMMAND awk -F \\. "{printf \"%i.%i\",$1,$2}"  RESULT_VARIABLE sw_vers_version OUTPUT_VARIABLE CURRENT_OSX_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
		execute_process(COMMAND xcrun --sdk macosx --show-sdk-version RESULT_VARIABLE xcrun_sdk_version OUTPUT_VARIABLE CURRENT_SDK_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
		if(${CURRENT_OSX_VERSION} VERSION_LESS ${CURRENT_SDK_VERSION})
			set(CMAKE_OSX_DEPLOYMENT_TARGET ${CURRENT_OSX_VERSION})
		else()
			set(CMAKE_OSX_DEPLOYMENT_TARGET ${CURRENT_SDK_VERSION})
		endif()
	endif()
50 51
	if(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS "10.9")
		message(FATAL_ERROR "Minimal OS X deployment target of 10.9 required!")
52 53 54 55 56 57 58 59 60 61 62 63 64 65
	endif()

	if(CMAKE_SIZEOF_VOID_P EQUAL 8)
		set(CMAKE_OSX_ARCHITECTURES "x86_64")
		set(LINPHONE_BUILDER_HOST "x86_64-apple-darwin")
	else()
		set(CMAKE_OSX_ARCHITECTURES "i386")
		set(LINPHONE_BUILDER_HOST "i686-apple-darwin")
	endif()
	set(CMAKE_MACOSX_RPATH 1)
endif()
if(WIN32)
	set(LINPHONE_BUILDER_CPPFLAGS "-D_WIN32_WINNT=0x0600 -D_CRT_SECURE_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS")
	if(MSVC AND MSVC_VERSION GREATER 1600) # Visual Studio 2010 defines this macro itself
66
		set(LINPHONE_BUILDER_CPPFLAGS "${LINPHONE_BUILDER_CPPFLAGS} -D_ALLOW_KEYWORD_MACROS /MP")
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 95 96
	endif()
endif()

# Adjust PKG_CONFIG_PATH to include install directory
if(NOT LINPHONE_BUILDER_PKG_CONFIG_PATH)
	if(UNIX)
		set(LINPHONE_BUILDER_PKG_CONFIG_PATH "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig/:$ENV{PKG_CONFIG_PATH}:/usr/lib/pkgconfig/:/usr/lib/x86_64-linux-gnu/pkgconfig/:/usr/share/pkgconfig/:/usr/local/lib/pkgconfig/:/opt/local/lib/pkgconfig/")
	else() # Windows
		set(LINPHONE_BUILDER_PKG_CONFIG_PATH "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig/")
	endif()
endif()


include(GNUInstallDirs)
if(NOT CMAKE_INSTALL_RPATH)
	list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" _IS_SYSTEM_DIR)
	if(_IS_SYSTEM_DIR STREQUAL "-1")
		set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
		if(NOT CMAKE_INSTALL_LIBDIR STREQUAL "lib")
			list(APPEND CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
		endif()
	endif()
endif()


# Include builders
include(builders/CMakeLists.txt)

# linphone
if(WIN32)
97
	lcb_builder_cmake_options(linphone "-DENABLE_RELATIVE_PREFIX=YES")
98
	lcb_builder_extra_ldflags(linphone "/SAFESEH:NO")
99
else()
100
	lcb_builder_cmake_options(linphone "-DENABLE_RELATIVE_PREFIX=${ENABLE_RELATIVE_PREFIX}")
101 102 103 104
endif()

# ms2
if(WIN32)
105 106
	lcb_builder_cmake_options(ms2 "-DENABLE_RELATIVE_PREFIX=YES")
	lcb_builder_extra_ldflags(ms2 "/SAFESEH:NO")
107
else()
108 109
	lcb_builder_cmake_options(ms2 "-DENABLE_THEORA=${ENABLE_THEORA}")
	lcb_builder_cmake_options(ms2 "-DENABLE_RELATIVE_PREFIX=${ENABLE_RELATIVE_PREFIX}")
110 111 112 113
endif()

# opencoreamr
if(NOT WIN32)
114 115 116
	lcb_builder_extra_cflags(opencoreamr "-fPIC")
	lcb_builder_extra_cxxflags(opencoreamr "-fPIC")
	lcb_builder_extra_ldflags(opencoreamr "-fPIC")
117 118
endif()

119
if(ENABLE_STATIC_ONLY)
120
	# ffmpeg
121
	lcb_builder_linking_type(ffmpeg "--enable-static" "--disable-shared" "--enable-pic")
122 123

	# mbedtls
124
	lcb_builder_linking_type(mbedtls "-DUSE_STATIC_MBEDTLS_LIBRARY=YES" "-DUSE_SHARED_MBEDTLS_LIBRARY=NO")
125 126

	# polarssl
127
	lcb_builder_linking_type(polarssl "-DUSE_SHARED_POLARSSL_LIBRARY=0")
128 129 130 131 132 133
else()
	if (NOT ENABLE_EMBEDDED_OPENH264)
		# openh264
		lcb_builder_linking_type(openh264 "-shared")
	endif()
	lcb_builder_linking_type(opus "-DBUILD_SHARED_LIBS=YES")
134
endif()
135 136 137

# voamrwbenc
if(NOT WIN32)
138 139 140
	lcb_builder_extra_cflags(voamrwbenc "-fPIC")
	lcb_builder_extra_cxxflags(voamrwbenc "-fPIC")
	lcb_builder_extra_ldflags(voamrwbenc "-fPIC")
141 142 143 144
endif()

# vpx
if(WIN32)
145
	lcb_builder_linking_type(vpx "--enable-static" "--disable-shared" "--enable-pic")
146
endif()
147 148 149 150 151

# zlib
lcb_builder_linking_type(zlib "-DENABLE_SHARED=NO" "-DENABLE_STATIC=YES")
lcb_builder_extra_cflags(zlib "-fPIC")