vpx.cmake 6.43 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
############################################################################
# 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
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
############################################################################

23 24 25 26 27 28
if(LINPHONE_BUILDER_PREBUILT_URL)
	set(EP_vpx_FILENAME "vpx-v1.3.0-${LINPHONE_BUILDER_ARCHITECTURE}.zip")
	file(DOWNLOAD "${LINPHONE_BUILDER_PREBUILT_URL}/${EP_vpx_FILENAME}" "${CMAKE_CURRENT_BINARY_DIR}/${EP_vpx_FILENAME}" STATUS EP_vpx_FILENAME_STATUS)
	list(GET EP_vpx_FILENAME_STATUS 0 EP_vpx_DOWNLOAD_STATUS)
	if(NOT EP_vpx_DOWNLOAD_STATUS)
		set(EP_vpx_PREBUILT 1)
29
	endif()
30 31 32 33 34
endif()

if(EP_vpx_PREBUILT)
	set(EP_vpx_URL "${CMAKE_CURRENT_BINARY_DIR}/${EP_vpx_FILENAME}")
	set(EP_vpx_BUILD_METHOD "prebuilt")
35 36 37
elseif(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
	# Use prebuilt library in the source tree for Windows 10
	set(EP_vpx_EXTERNAL_SOURCE_PATHS "build/libvpx")
38
else()
39 40
	set(EP_vpx_URL "http://storage.googleapis.com/downloads.webmproject.org/releases/webm/libvpx-1.5.0.tar.bz2")
	set(EP_vpx_URL_HASH "MD5=49e59dd184caa255886683facea56fca")
41
	set(EP_vpx_EXTERNAL_SOURCE_PATHS "externals/libvpx")
42
	set(EP_vpx_MAY_BE_FOUND_ON_SYSTEM TRUE)
43
	set(EP_vpx_IGNORE_WARNINGS TRUE)
44
	set(EP_vpx_BUILD_METHOD "autotools")
Ghislain MARY's avatar
Ghislain MARY committed
45
	set(EP_vpx_DO_NOT_USE_CMAKE_FLAGS TRUE)
46 47 48
	set(EP_vpx_CONFIG_H_FILE vpx_config.h)
	set(EP_vpx_CONFIGURE_OPTIONS
		"--enable-error-concealment"
49
		"--enable-multithread"
50 51 52 53 54 55 56 57 58 59 60
		"--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"
	)
61
	string(FIND "${CMAKE_C_COMPILER_LAUNCHER}" "ccache" CCACHE_ENABLED)
62
	if (NOT "${CCACHE_ENABLED}" STREQUAL "-1")
63 64
		list(APPEND EP_vpx_CONFIGURE_OPTIONS "--enable-ccache")
	endif()
65 66

	if(WIN32)
67 68 69 70 71 72
		if(CMAKE_GENERATOR MATCHES "^Visual Studio")
			set(EP_vpx_BUILD_METHOD "custom")
			set(EP_vpx_BUILD_IN_SOURCE TRUE)
			string(REPLACE " " ";" GENERATOR_LIST "${CMAKE_GENERATOR}")
			list(GET GENERATOR_LIST 2 VS_VERSION)
			set(EP_vpx_TARGET "x86-win32-vs${VS_VERSION}")
73 74 75
			execute_process(COMMAND "cmd.exe" "/c" "${CMAKE_CURRENT_SOURCE_DIR}/builders/vpx/windows_env.bat" "${VS_VERSION}"
				WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
			)
76 77 78
			file(READ "${CMAKE_CURRENT_BINARY_DIR}/windowsenv_path.txt" EP_vpx_ENV_PATH_LIST)
			set(EP_vpx_ENV_PATH "")
			foreach(P ${EP_vpx_ENV_PATH_LIST})
79
				string(REGEX REPLACE "^([a-zA-Z]):(.*)$" "/\\1\\2" P ${P})
80 81 82
				string(REPLACE "\\" "/" P ${P})
				set(EP_vpx_ENV_PATH "${EP_vpx_ENV_PATH}:${P}")
			endforeach()
83
			set(EP_vpx_ENV_PATH "${EP_vpx_ENV_PATH}:${AUTOTOOLS_PROGRAM_PATH}")
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
			string(SUBSTRING ${EP_vpx_ENV_PATH} 1 -1 EP_vpx_ENV_PATH)
			string(STRIP ${EP_vpx_ENV_PATH} EP_vpx_ENV_PATH)
			file(READ "${CMAKE_CURRENT_BINARY_DIR}/windowsenv_include.txt" EP_vpx_ENV_INCLUDE)
			file(READ "${CMAKE_CURRENT_BINARY_DIR}/windowsenv_lib.txt" EP_vpx_ENV_LIB)
			file(READ "${CMAKE_CURRENT_BINARY_DIR}/windowsenv_libpath.txt" EP_vpx_ENV_LIBPATH)
		else()
			set(EP_vpx_TARGET "x86-win32-gcc")
		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()
		set(EP_vpx_CONFIGURE_COMMAND_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/builders/vpx/windows_configure.sh.cmake)
		set(EP_vpx_BUILD_COMMAND_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/builders/vpx/windows_build.sh.cmake)
		set(EP_vpx_INSTALL_COMMAND_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/builders/vpx/windows_install.sh.cmake)
99
	elseif(APPLE)
100 101 102 103 104 105 106 107
		if(IOS)
			if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
				set(EP_vpx_TARGET "arm64-darwin-gcc")
			elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7")
				set(EP_vpx_TARGET "armv7-darwin-gcc")
			elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
				set(EP_vpx_TARGET "x86_64-iphonesimulator-gcc")
			else()
Ghislain MARY's avatar
Ghislain MARY committed
108
				set(EP_vpx_TARGET "x86-iphonesimulator-gcc")
109
			endif()
110
		else()
111 112 113 114 115
			if(CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64")
				set(EP_vpx_TARGET "x86_64-darwin10-gcc")
			else()
				set(EP_vpx_TARGET "x86-darwin10-gcc")
			endif()
116 117 118 119 120
		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...
			set(EP_vpx_EXTRA_CFLAGS "${EP_vpx_EXTRA_CFLAGS} -I${LINPHONE_BUILDER_WORK_DIR}/Build/vpx")
			set(EP_vpx_EXTRA_ASFLAGS "${EP_vpx_EXTRA_ASFLAGS} -I${LINPHONE_BUILDER_WORK_DIR}/Build/vpx")
121 122
		endif()
		set(EP_vpx_LINKING_TYPE "--enable-static" "--disable-shared" "--enable-pic")
123
	elseif(ANDROID)
124 125 126
		if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armeabi")
			message(FATAL_ERROR "VPX cannot be built on arm.")
		elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "armeabi-v7a")
127 128 129 130 131
			set(EP_vpx_TARGET "armv7-android-gcc")
		else()
			set(EP_vpx_TARGET "x86-android-gcc")
		endif()
		list(APPEND EP_vpx_CONFIGURE_OPTIONS
132
			"--sdk-path=${ANDROID_NDK_PATH}/"
133
			"--enable-pic"
134 135
		)
		set(EP_vpx_LINKING_TYPE "--enable-static" "--disable-shared" "--enable-pic")
136 137 138 139 140 141 142 143
	elseif(QNX)
		set(EP_vpx_TARGET "armv7-qnx-gcc")
		list(REMOVE_ITEM EP_vpx_CONFIGURE_OPTIONS "--enable-multithread")
		list(APPEND EP_vpx_CONFIGURE_OPTIONS
			"--libc=${QNX_TARGET}/${ROOT_PATH_SUFFIX}"
			"--force-target=armv7-qnx-gcc"
			"--disable-runtime-cpu-detect"
		)
144
	else()
145 146
		if(CMAKE_SIZEOF_VOID_P EQUAL 8)
			set(EP_vpx_TARGET "x86_64-linux-gcc")
147
		else()
148
			set(EP_vpx_TARGET "x86-linux-gcc")
149
		endif()
150
		set(EP_vpx_LINKING_TYPE "--disable-static" "--enable-shared")
151
	endif()
152

153 154 155 156
	set(EP_vpx_CROSS_COMPILATION_OPTIONS
		"--prefix=${CMAKE_INSTALL_PREFIX}"
		"--target=${EP_vpx_TARGET}"
	)
157
	set(EP_vpx_CONFIGURE_ENV "CC=$CC_NO_LAUNCHER LD=$CC_NO_LAUNCHER ASFLAGS=$ASFLAGS CFLAGS=$CFLAGS LDFLAGS=$LDFLAGS")
158
endif()