vpx.cmake 6.23 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
############################################################################
# vpx.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
if(LINPHONE_BUILDER_PREBUILT_URL)
24 25 26 27 28
	set(VPX_FILENAME "vpx-v1.3.0-${LINPHONE_BUILDER_ARCHITECTURE}.zip")
	file(DOWNLOAD "${LINPHONE_BUILDER_PREBUILT_URL}/${VPX_FILENAME}" "${CMAKE_CURRENT_BINARY_DIR}/${VPX_FILENAME}" STATUS VPX_FILENAME_STATUS)
	list(GET VPX_FILENAME_STATUS 0 VPX_DOWNLOAD_STATUS)
	if(NOT VPX_DOWNLOAD_STATUS)
		set(VPX_PREBUILT 1)
29
	endif()
30 31
endif()

32 33 34
if(VPX_PREBUILT)
	lcb_url("${CMAKE_CURRENT_BINARY_DIR}/${VPX_FILENAME}")
	lcb_build_method("prebuilt")
35 36
elseif(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
	# Use prebuilt library in the source tree for Windows 10
37
	lcb_external_source_paths("build/libvpx")
38
else()
39 40 41 42 43 44 45 46 47 48
	lcb_url("http://storage.googleapis.com/downloads.webmproject.org/releases/webm/libvpx-1.5.0.tar.bz2")
	lcb_url_hash("MD5=49e59dd184caa255886683facea56fca")
	lcb_external_source_paths("externals/libvpx")
	lcb_may_be_found_on_system(YES)
	lcb_ignore_warnings(YES)

	lcb_build_method("autotools")
	lcb_do_not_use_cmake_flags(YES)
	lcb_config_h_file("vpx_config.h")
	lcb_configure_options(
49
		"--enable-error-concealment"
50
		"--enable-multithread"
51 52 53 54 55 56 57 58 59 60 61
		"--enable-realtime-only"
		"--enable-spatial-resampling"
		"--enable-vp8"
		"--disable-vp9"
		"--enable-libs"
		"--disable-install-docs"
		"--disable-debug-libs"
		"--disable-examples"
		"--disable-unit-tests"
		"--as=yasm"
	)
62
	string(FIND "${CMAKE_C_COMPILER_LAUNCHER}" "ccache" CCACHE_ENABLED)
63
	if (NOT "${CCACHE_ENABLED}" STREQUAL "-1")
64
		lcb_configure_options("--enable-ccache")
65
	endif()
66 67

	if(WIN32)
68
		if(CMAKE_GENERATOR MATCHES "^Visual Studio")
69
			lcb_build_method("custom")
70
			lcb_build_in_source_tree(TRUE)
71 72
			string(REPLACE " " ";" GENERATOR_LIST "${CMAKE_GENERATOR}")
			list(GET GENERATOR_LIST 2 VS_VERSION)
73
			set(VPX_TARGET "x86-win32-vs${VS_VERSION}")
74 75 76
			execute_process(COMMAND "cmd.exe" "/c" "${CMAKE_CURRENT_SOURCE_DIR}/builders/vpx/windows_env.bat" "${VS_VERSION}"
				WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
			)
77 78 79
			file(READ "${CMAKE_CURRENT_BINARY_DIR}/windowsenv_path.txt" VPX_ENV_PATH_LIST)
			set(VPX_ENV_PATH "")
			foreach(P ${VPX_ENV_PATH_LIST})
80
				string(REGEX REPLACE "^([a-zA-Z]):(.*)$" "/\\1\\2" P ${P})
81
				string(REPLACE "\\" "/" P ${P})
82
				set(VPX_ENV_PATH "${VPX_ENV_PATH}:${P}")
83
			endforeach()
84 85 86 87 88 89
			set(VPX_ENV_PATH "${VPX_ENV_PATH}:${AUTOTOOLS_PROGRAM_PATH}")
			string(SUBSTRING ${VPX_ENV_PATH} 1 -1 VPX_ENV_PATH)
			string(STRIP ${VPX_ENV_PATH} VPX_ENV_PATH)
			file(READ "${CMAKE_CURRENT_BINARY_DIR}/windowsenv_include.txt" VPX_ENV_INCLUDE)
			file(READ "${CMAKE_CURRENT_BINARY_DIR}/windowsenv_lib.txt" VPX_ENV_LIB)
			file(READ "${CMAKE_CURRENT_BINARY_DIR}/windowsenv_libpath.txt" VPX_ENV_LIBPATH)
90
		else()
91
			set(VPX_TARGET "x86-win32-gcc")
92 93 94 95 96
		endif()
		set(EP_vpx_CONFIGURE_OPTIONS_STR "")
		foreach(OPTION ${EP_vpx_CONFIGURE_OPTIONS})
			set(EP_vpx_CONFIGURE_OPTIONS_STR "${EP_vpx_CONFIGURE_OPTIONS_STR} \"${OPTION}\"")
		endforeach()
97 98 99
		lcb_configure_command_source("${CMAKE_CURRENT_SOURCE_DIR}/builders/vpx/windows_configure.sh.cmake")
		lcb_build_command_source("${CMAKE_CURRENT_SOURCE_DIR}/builders/vpx/windows_build.sh.cmake")
		lcb_install_command_source("${CMAKE_CURRENT_SOURCE_DIR}/builders/vpx/windows_install.sh.cmake")
100
	elseif(APPLE)
101 102
		if(IOS)
			if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
103
				set(VPX_TARGET "arm64-darwin-gcc")
104
			elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7")
105
				set(VPX_TARGET "armv7-darwin-gcc")
106
			elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
107
				set(VPX_TARGET "x86_64-iphonesimulator-gcc")
108
			else()
109
				set(VPX_TARGET "x86-iphonesimulator-gcc")
110
			endif()
111
		else()
112
			if(CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64")
113
				set(VPX_TARGET "x86_64-darwin10-gcc")
114
			else()
115
				set(VPX_TARGET "x86-darwin10-gcc")
116
			endif()
117 118 119
		endif()
		if(CMAKE_GENERATOR STREQUAL "Xcode")
			# It appears that the build occurs in the cmake directory instead of the Build/vpx one with Xcode, so these flags are needed for include files to be found...
120 121
			lcb_extra_cflags("-I${LINPHONE_BUILDER_WORK_DIR}/Build/vpx")
			lcb_extra_asflags("-I${LINPHONE_BUILDER_WORK_DIR}/Build/vpx")
122
		endif()
123
		lcb_linking_type("--enable-static" "--disable-shared" "--enable-pic")
124
	elseif(ANDROID)
125
		if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv5te")
126
			message(FATAL_ERROR "VPX cannot be built on arm.")
127
		elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7-a")
128
			set(VPX_TARGET "armv7-android-gcc")
129 130
		elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
			set(VPX_TARGET "arm64-android-gcc")
131 132
		elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" )
			set(VPX_TARGET "x86_64-android-gcc")
133
		else()
134
			set(VPX_TARGET "x86-android-gcc")
135
		endif()
136
		lcb_configure_options("--sdk-path=${CMAKE_ANDROID_NDK}/" )
137
		lcb_linking_type("--enable-static" "--disable-shared" "--enable-pic")
138
	elseif(QNX)
139 140
		set(VPX_TARGET "armv7-qnx-gcc")
		lcb_configure_options(
141 142 143 144
			"--libc=${QNX_TARGET}/${ROOT_PATH_SUFFIX}"
			"--force-target=armv7-qnx-gcc"
			"--disable-runtime-cpu-detect"
		)
145
		list(REMOVE_ITEM EP_vpx_CONFIGURE_OPTIONS "--enable-multithread")
146
	else()
147
		if(CMAKE_SIZEOF_VOID_P EQUAL 8)
148
			set(VPX_TARGET "x86_64-linux-gcc")
149
		else()
150
			set(VPX_TARGET "x86-linux-gcc")
151
		endif()
152
		lcb_linking_type("--disable-static" "--enable-shared")
153
	endif()
154

155
	lcb_cross_compilation_options(
156
		"--prefix=${CMAKE_INSTALL_PREFIX}"
157
		"--target=${VPX_TARGET}"
158
	)
159
	lcb_configure_env("CC=$CC_NO_LAUNCHER LD=$CC_NO_LAUNCHER ASFLAGS=$ASFLAGS CFLAGS=$CFLAGS LDFLAGS=$LDFLAGS")
160
endif()