openh264.cmake 3.82 KB
Newer Older
Ghislain MARY's avatar
Ghislain MARY committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
############################################################################
# openh264.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.
Ghislain MARY's avatar
Ghislain MARY committed
20 21 22
#
############################################################################

23 24
if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
	# Use prebuilt library in the source tree for Windows 10
25
	lcb_external_source_paths("build/openh264")
26 27 28 29 30 31 32 33 34 35 36
else()
	find_program(NASM_PROGRAM
		NAMES nasm nasm.exe
		HINTS "${LINPHONE_BUILDER_WORK_DIR}/windows_tools"
	)
	if(NOT NASM_PROGRAM)
		if(WIN32)
			message(FATAL_ERROR "Could not find the nasm.exe program. Please install it from http://www.nasm.us/")
		else()
			message(FATAL_ERROR "Could not find the nasm program.")
		endif()
Ghislain MARY's avatar
Ghislain MARY committed
37 38
	endif()

39
	set(OPENH264_VERSION "1.8.0")	# Keep this variable, it is used for packaging to know the version to download from Cisco
40
	lcb_git_repository("https://github.com/cisco/openh264")
41
	lcb_git_tag("openh264v${OPENH264_VERSION}")
42
	lcb_external_source_paths("externals/openh264" "external/openh264")
43
	lcb_ignore_warnings(YES)
44

45 46 47 48 49 50
	lcb_build_method("custom")
	lcb_linking_type("-static")
	set(OPENH264_BUILD_TYPE "Release")	# Always use Release build type, otherwise the codec is too slow...
	lcb_configure_command_source(${CMAKE_CURRENT_SOURCE_DIR}/builders/openh264/configure.sh.cmake)
	lcb_build_command_source(${CMAKE_CURRENT_SOURCE_DIR}/builders/openh264/build.sh.cmake)
	lcb_install_command_source(${CMAKE_CURRENT_SOURCE_DIR}/builders/openh264/install.sh.cmake)
51
	if(MSVC)
52
		lcb_additional_options("OS=\"msvc\"")
53
	elseif(ANDROID)
54
		set(ADDITIONAL_OPTIONS "TOOLCHAINPREFIX=\"${ANDROID_TOOLCHAIN_PREFIX}\" OS=\"android\" NDKROOT=\"${CMAKE_ANDROID_NDK}\" NDKLEVEL=${ANDROID_PLATFORM_LEVEL} TARGET=\"android-${CMAKE_ANDROID_API}\"")
55
		if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7-a")
56
			set(ADDITIONAL_OPTIONS "${ADDITIONAL_OPTIONS} ARCH=\"arm\" INCLUDE_PREFIX=\"arm-linux-androideabi\"")
57
		elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
58
			set(ADDITIONAL_OPTIONS "${ADDITIONAL_OPTIONS} ARCH=\"arm64\" INCLUDE_PREFIX=\"aarch64-linux-android\"")
59
		else()
60
			set(ADDITIONAL_OPTIONS "${ADDITIONAL_OPTIONS} ARCH=\"x86\" ENABLEPIC=\"Yes\" INCLUDE_PREFIX=\"i686-linux-android\"")
61
		endif()
62
		lcb_additional_options("${ADDITIONAL_OPTIONS}")
63
	elseif(APPLE)
64 65
		if(IOS)
			if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
66
				lcb_additional_options("OS=\"ios\" ARCH=\"arm64\"")
67 68
				#XCode7  allows bitcode
				if (NOT ${XCODE_VERSION} VERSION_LESS 7)
69
					lcb_extra_cflags("-fembed-bitcode")
70 71
				endif()
			elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7")
72
				lcb_additional_options("OS=\"ios\" ARCH=\"armv7\"")
73 74
				#XCode7  allows bitcode
				if (NOT ${XCODE_VERSION} VERSION_LESS 7)
75
					lcb_extra_cflags("-fembed-bitcode")
76 77
				endif()
			elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
78
				lcb_additional_options("OS=\"ios\" ARCH=\"x86_64\"")
79
			else()
80
				lcb_additional_options("OS=\"ios\" ARCH=\"i386\"")
jehan's avatar
jehan committed
81
			endif()
82
		else()
83
			if(CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64")
84
				lcb_additional_options("ARCH=\"x86_64\"")
85
			else()
86
				lcb_additional_options("ARCH=\"x86\"")
87
			endif()
88
		endif()
89 90
	endif()
endif()