From b8f0f7e35a73f038dacd8338251c6c6aa54808be Mon Sep 17 00:00:00 2001 From: Florent Castelli Date: Sun, 18 Dec 2016 23:10:45 +0100 Subject: [PATCH 1/3] Update ffmpeg submodule --- ffmpeg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ffmpeg b/ffmpeg index 0813d5ebb6..2f6023d14a 160000 --- a/ffmpeg +++ b/ffmpeg @@ -1 +1 @@ -Subproject commit 0813d5ebb6a08902d7394eb09f13cc082061a722 +Subproject commit 2f6023d14a09e6fc1babbb8b31231249719e9240 From 2149d3db7fb960d140bdee31a9f0f4837934127b Mon Sep 17 00:00:00 2001 From: Florent Castelli Date: Mon, 5 Dec 2016 10:37:51 +0100 Subject: [PATCH 2/3] cmake: New FindFFmpeg module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This new module should be able to handle both libraries in the regular paths and fallback to pkg-config. It is also able to find dynamic libraries, not just static libraries. It will generate imported targets with the name FFmpeg:: that you can use in your scripts. The way it’s used in our main build script has been updated to match. We also won’t link external libraries used by ffmpeg automatically since it is not reliable and depend on custom options. You should use a proper static build with no external dependencies or a shared build that will have the proper dependencies listed. --- CMakeLists.txt | 216 +++++++++------------------------ cmake/Modules/FindFFMPEG.cmake | 198 ------------------------------ cmake/Modules/FindFFmpeg.cmake | 163 +++++++++++++++++++++++++ 3 files changed, 217 insertions(+), 360 deletions(-) delete mode 100644 cmake/Modules/FindFFMPEG.cmake create mode 100644 cmake/Modules/FindFFmpeg.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index ec8a780429..299681cf29 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -384,171 +384,52 @@ add_library(rg_etc1 STATIC include_directories(ext/native/ext/rg_etc1) if(USE_FFMPEG) - if(USE_SYSTEM_FFMPEG) - find_package(FFMPEG) - else() - set(FFMPEG_FOUND OFF) - endif() - if(NOT FFMPEG_FOUND) - if(NOT DEFINED FFMPEG_BUILDDIR) - if(ANDROID) - if(ARMV7) - set(PLATFORM_ARCH "android/armv7") - elseif(ARM) - set(PLATFORM_ARCH "android/arm") - elseif(X86_64) # Before X86 since both may be defined... gah - set(PLATFORM_ARCH "android/x86_64") - elseif(X86) - set(PLATFORM_ARCH "android/x86") - elseif(ARM64) - set(PLATFORM_ARCH "android/arm64") - endif() - elseif(IOS) - set(PLATFORM_ARCH "ios/universal") - elseif(MACOSX) - set(PLATFORM_ARCH "macosx/x86_64") - elseif(LINUX) - if(ARMV7) - set(PLATFORM_ARCH "linux/armv7") - elseif(ARM) - set(PLATFORM_ARCH "linux/arm") - elseif(MIPS) - set(PLATFORM_ARCH "linux/mips32") - elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(PLATFORM_ARCH "linux/x86_64") - else() - set(PLATFORM_ARCH "linux/x86") - endif() - elseif(WIN32) - if(X86_64) - set(PLATFORM_ARCH "Windows/x86_64") - elseif(X86) - set(PLATFORM_ARCH "Windows/x86") - endif() - endif() - # Using static libraries - if (DEFINED PLATFORM_ARCH) - include_directories(ffmpeg/${PLATFORM_ARCH}/include) - link_directories(ffmpeg/${PLATFORM_ARCH}/lib) - if(WIN32) - set(FFMPEG_LIBRARIES avformat avcodec avutil swresample swscale) - else() - set(FFMPEG_LIBRARIES libavformat.a libavcodec.a libavutil.a libswresample.a libswscale.a) - endif() - else() - # Manual definition of system library locations by the user. - if (DEFINED FFMPEG_INCLUDE_PATH) - include_directories(ffmpeg ${FFMPEG_INCLUDE_PATH}) - endif() - if (DEFINED AVFORMAT_PATH) - add_library(libavformat STATIC IMPORTED) - set_target_properties(libavformat PROPERTIES IMPORTED_LOCATION ${AVFORMAT_PATH}) - SET (FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} libavformat) - endif() - if (DEFINED AVCODEC_PATH) - add_library(libavcodec STATIC IMPORTED) - set_target_properties(libavcodec PROPERTIES IMPORTED_LOCATION ${AVCODEC_PATH}) - SET (FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} libavcodec) - endif() - if (DEFINED AVUTIL_PATH) - add_library(libavutil STATIC IMPORTED) - set_target_properties(libavutil PROPERTIES IMPORTED_LOCATION ${AVUTIL_PATH}) - SET (FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} libavutil) - endif() - if (DEFINED SWRESAMPLE_PATH) - add_library(libswresample STATIC IMPORTED) - set_target_properties(libswresample PROPERTIES IMPORTED_LOCATION ${SWRESAMPLE_PATH}) - SET (FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} libswresample) - endif() - if (DEFINED SWSCALE_PATH) - add_library(libswscale STATIC IMPORTED) - set_target_properties(libswscale PROPERTIES IMPORTED_LOCATION ${SWSCALE_PATH}) - SET (FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} libswscale) - endif() - endif(DEFINED PLATFORM_ARCH) - else(NOT DEFINED FFMPEG_BUILDDIR) - # Using shared libraries - include_directories(ffmpeg ${FFMPEG_BUILDDIR}) + if(NOT FFMPEG_DIR) + if(NOT USE_SYSTEM_FFMPEG) + if(ANDROID) + if(ARMV7) + set(PLATFORM_ARCH "android/armv7") + elseif(ARM) + set(PLATFORM_ARCH "android/arm") + elseif(X86) + set(PLATFORM_ARCH "android/x86") + else() + set(PLATFORM_ARCH "android/x86_64") + endif() + elseif(IOS) + set(PLATFORM_ARCH "ios/universal") + elseif(MACOSX) + set(PLATFORM_ARCH "macosx/x86_64") + elseif(LINUX) + if(ARMV7) + set(PLATFORM_ARCH "linux/armv7") + elseif(ARM) + set(PLATFORM_ARCH "linux/arm") + elseif(MIPS) + set(PLATFORM_ARCH "linux/mips32") + elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(PLATFORM_ARCH "linux/x86_64") + else() + set(PLATFORM_ARCH "linux/x86") + endif() + elseif(WIN32) + if(X86_64) + set(PLATFORM_ARCH "Windows/x86_64") + elseif(X86) + set(PLATFORM_ARCH "Windows/x86") + endif() + endif() + if(PLATFORM_ARCH) + set(FFMPEG_DIR "ffmpeg/${PLATFORM_ARCH}") + else() + message("Couldn't find an internal FFmpeg build, using system FFmpeg instead") + endif() + endif() + endif() - add_library(libavformat STATIC IMPORTED) - set_target_properties(libavformat PROPERTIES IMPORTED_LOCATION ${FFMPEG_BUILDDIR}/libavformat/libavformat.a) - add_library(libavcodec STATIC IMPORTED) - set_target_properties(libavcodec PROPERTIES IMPORTED_LOCATION ${FFMPEG_BUILDDIR}/libavcodec/libavcodec.a) - add_library(libavutil STATIC IMPORTED) - set_target_properties(libavutil PROPERTIES IMPORTED_LOCATION ${FFMPEG_BUILDDIR}/libavutil/libavutil.a) - add_library(libswresample STATIC IMPORTED) - set_target_properties(libswresample PROPERTIES IMPORTED_LOCATION ${FFMPEG_BUILDDIR}/libswresample/libswresample.a) - add_library(libswscale STATIC IMPORTED) - set_target_properties(libswscale PROPERTIES IMPORTED_LOCATION ${FFMPEG_BUILDDIR}/libswscale/libswscale.a) - - SET (FFMPEG_LIBRARIES - libavformat - libavcodec - libavutil - libswresample - libswscale - ) - endif(NOT DEFINED FFMPEG_BUILDDIR) - endif(NOT FFMPEG_FOUND) - - find_library(ICONV_LIBRARY NAMES iconv) - if (ICONV_LIBRARY) - set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${ICONV_LIBRARY}) - endif() - - if(APPLE) - set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} bz2 "-framework CoreVideo") - if (NOT IOS) - set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} "-framework VideoDecodeAcceleration") - endif() - endif(APPLE) - - if(FFMPEG_FOUND) - set(nativeExtraLibs ${nativeExtraLibs} ${FFMPEG_LIBRARIES}) - else() - set(LinkCommon ${LinkCommon} ${FFMPEG_LIBRARIES}) - endif() - target_link_libraries(Common ${FFMPEG_LIBRARIES}) - add_definitions(-DUSE_FFMPEG) + find_package(FFmpeg REQUIRED avcodec avformat avutil swresample swscale) endif(USE_FFMPEG) -# Modification to show where we are pulling the ffmpeg libraries from. -if(USE_FFMPEG AND DEFINED FFMPEG_LIBRARIES) - message(STATUS "FFMPEG library locations:") - if(FFMPEG_FOUND) - message(STATUS " libavcodec location: ${FFMPEG_avcodec_LIBRARY}") - message(STATUS " libavformat location: ${FFMPEG_avformat_LIBRARY}") - message(STATUS " libavutil location: ${FFMPEG_avutil_LIBRARY}") - message(STATUS " libswresample location: ${FFMPEG_swresample_LIBRARY}") - message(STATUS " libswscale location: ${FFMPEG_swscale_LIBRARY}") - elseif(DEFINED PLATFORM_ARCH) - set(TEMP ${CMAKE_SOURCE_DIR}/ffmpeg/${PLATFORM_ARCH}/lib) - message(STATUS " libavcodec location: ${TEMP}/libavcodec.a") - message(STATUS " libavformat location: ${TEMP}/libavformat.a") - message(STATUS " libavutil location: ${TEMP}/libavutil.a") - message(STATUS " libswresample location: ${TEMP}/libswresample.a") - message(STATUS " libswscale location: ${TEMP}/libswscale.a") - else() - get_target_property(TEMP libavcodec IMPORTED_LOCATION) - message(STATUS " libavcodec location: ${TEMP}") - get_target_property(TEMP libavformat IMPORTED_LOCATION) - message(STATUS " libavformat location: ${TEMP}") - get_target_property(TEMP libavutil IMPORTED_LOCATION) - message(STATUS " libavutil location: ${TEMP}") - get_target_property(TEMP libswresample IMPORTED_LOCATION) - message(STATUS " libswresample location: ${TEMP}") - get_target_property(TEMP libswscale IMPORTED_LOCATION) - message(STATUS " libswscale location: ${TEMP}") - endif() -else() - message(STATUS "ERROR: No FFMPEG library locations") -endif() - -if(USE_FFMPEG AND NOT DEFINED FFMPEG_LIBRARIES) - message(WARNING "FFMPEG_BUILDDIR variable or manual path definition is required to enable FFmpeg. Disabling it.") - unset(USE_FFMPEG) -endif() - find_package(ZLIB) if(ZLIB_FOUND) include_directories(${ZLIB_INCLUDE_DIR}) @@ -1647,6 +1528,17 @@ endif() target_link_libraries(${CoreLibName} Common native kirk cityhash sfmt19937 xbrz xxhash glslang ${CoreExtraLibs} ${OPENGL_LIBRARIES} ${X11_LIBRARIES} ${CMAKE_DL_LIBS}) +if(FFmpeg_FOUND) + target_compile_definitions(${CoreLibName} PRIVATE USE_FFMPEG=1) + target_link_libraries(${CoreLibName} + FFmpeg::avcodec + FFmpeg::avformat + FFmpeg::avutil + FFmpeg::swresample + FFmpeg::swscale + ) +endif() + setup_target_project(${CoreLibName} Core) # Generate git-version.cpp at build time. diff --git a/cmake/Modules/FindFFMPEG.cmake b/cmake/Modules/FindFFMPEG.cmake deleted file mode 100644 index 7b791cdf9a..0000000000 --- a/cmake/Modules/FindFFMPEG.cmake +++ /dev/null @@ -1,198 +0,0 @@ -# FindFFMPEG -# ---------- -# -# Find the native FFMPEG includes and libraries -# -# This module defines: -# -# FFMPEG_INCLUDE_DIR, where to find avformat.h, avcodec.h... -# FFMPEG_LIBRARIES, the libraries to link against to use FFMPEG. -# FFMPEG_FOUND, If false, do not try to use FFMPEG. -# -# also defined, but not for general use are: -# -# FFMPEG_avformat_LIBRARY, where to find the FFMPEG avformat library. -# FFMPEG_avcodec_LIBRARY, where to find the FFMPEG avcodec library. -# -# This is useful to do it this way so that we can always add more libraries -# if needed to ``FFMPEG_LIBRARIES`` if ffmpeg ever changes... - -#============================================================================= -# Copyright: 1993-2008 Ken Martin, Will Schroeder, Bill Lorensen -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of ppsspp, substitute the full -# License text for the above reference.) - -if(EXISTS "/etc/debian_version") - set (PLATFORM "Debian") -endif() - -if(${PLATFORM} MATCHES "Debian") - find_path(FFMPEG_INCLUDE_DIR1 libavformat/avformat.h) - find_path(FFMPEG_INCLUDE_DIR2 libavcodec/avcodec.h) - find_path(FFMPEG_INCLUDE_DIR3 libavutil/avutil.h) - find_path(FFMPEG_INCLUDE_DIR4 libswresample/swresample.h) - find_path(FFMPEG_INCLUDE_DIR5 libswscale/swscale.h) -else() - find_path(FFMPEG_INCLUDE_DIR1 avformat.h - $ENV{FFMPEG_DIR} - $ENV{FFMPEG_DIR}/ffmpeg - $ENV{FFMPEG_DIR}/libavformat - $ENV{FFMPEG_DIR}/include/libavformat - $ENV{FFMPEG_DIR}/include/ffmpeg - /usr/local/include/ffmpeg - /usr/include/ffmpeg - /usr/include/libavformat - /usr/include/ffmpeg/libavformat - /usr/local/include/libavformat - ) - - find_path(FFMPEG_INCLUDE_DIR2 avcodec.h - $ENV{FFMPEG_DIR} - $ENV{FFMPEG_DIR}/ffmpeg - $ENV{FFMPEG_DIR}/libavcodec - $ENV{FFMPEG_DIR}/include/libavcodec - $ENV{FFMPEG_DIR}/include/ffmpeg - /usr/local/include/ffmpeg - /usr/include/ffmpeg - /usr/include/libavcodec - /usr/include/ffmpeg/libavcodec - /usr/local/include/libavcodec - ) - - find_path(FFMPEG_INCLUDE_DIR3 avutil.h - $ENV{FFMPEG_DIR} - $ENV{FFMPEG_DIR}/ffmpeg - $ENV{FFMPEG_DIR}/libavutil - $ENV{FFMPEG_DIR}/include/libavutil - $ENV{FFMPEG_DIR}/include/ffmpeg - /usr/local/include/ffmpeg - /usr/include/ffmpeg - /usr/include/libavutil - /usr/include/ffmpeg/libavutil - /usr/local/include/libavutil - ) - - find_path(FFMPEG_INCLUDE_DIR4 swresample.h - $ENV{FFMPEG_DIR} - $ENV{FFMPEG_DIR}/ffmpeg - $ENV{FFMPEG_DIR}/libswresample - $ENV{FFMPEG_DIR}/include/libswresample - $ENV{FFMPEG_DIR}/include/ffmpeg - /usr/local/include/ffmpeg - /usr/include/ffmpeg - /usr/include/libswresample - /usr/include/ffmpeg/libswresample - /usr/local/include/libswresample - ) - - find_path(FFMPEG_INCLUDE_DIR5 swscale.h - $ENV{FFMPEG_DIR} - $ENV{FFMPEG_DIR}/ffmpeg - $ENV{FFMPEG_DIR}/libswscale - $ENV{FFMPEG_DIR}/include/libswscale - $ENV{FFMPEG_DIR}/include/ffmpeg - /usr/local/include/ffmpeg - /usr/include/ffmpeg - /usr/include/libswscale - /usr/include/ffmpeg/libswscale - /usr/local/include/libswscale - ) -endif() - -if(FFMPEG_INCLUDE_DIR1 AND - FFMPEG_INCLUDE_DIR2 AND - FFMPEG_INCLUDE_DIR3 AND - FFMPEG_INCLUDE_DIR4 AND - FFMPEG_INCLUDE_DIR5 -) - set(FFMPEG_INCLUDE_DIR ${FFMPEG_INCLUDE_DIR1} - ${FFMPEG_INCLUDE_DIR2} - ${FFMPEG_INCLUDE_DIR3} - ${FFMPEG_INCLUDE_DIR4} - ${FFMPEG_INCLUDE_DIR5} - ) -endif() - -if(${PLATFORM} MATCHES "Debian") - find_library(FFMPEG_avformat_LIBRARY avformat-ffmpeg) - find_library(FFMPEG_avcodec_LIBRARY avcodec-ffmpeg) - find_library(FFMPEG_avutil_LIBRARY avutil-ffmpeg) - find_library(FFMPEG_swresample_LIBRARY swresample-ffmpeg) - find_library(FFMPEG_swscale_LIBRARY swscale-ffmpeg) -else() - find_library(FFMPEG_avformat_LIBRARY avformat - $ENV{FFMPEG_DIR} - $ENV{FFMPEG_DIR}/lib - $ENV{FFMPEG_DIR}/libavformat - /usr/local/lib - /usr/lib - ) - - find_library(FFMPEG_avcodec_LIBRARY avcodec - $ENV{FFMPEG_DIR} - $ENV{FFMPEG_DIR}/lib - $ENV{FFMPEG_DIR}/libavcodec - /usr/local/lib - /usr/lib - ) - - find_library(FFMPEG_avutil_LIBRARY avutil - $ENV{FFMPEG_DIR} - $ENV{FFMPEG_DIR}/lib - $ENV{FFMPEG_DIR}/libavutil - /usr/local/lib - /usr/lib - ) - - find_library(FFMPEG_swresample_LIBRARY swresample - $ENV{FFMPEG_DIR} - $ENV{FFMPEG_DIR}/lib - $ENV{FFMPEG_DIR}/libswresample - /usr/local/lib - /usr/lib - ) - - find_library(FFMPEG_swscale_LIBRARY swscale - $ENV{FFMPEG_DIR} - $ENV{FFMPEG_DIR}/lib - $ENV{FFMPEG_DIR}/libswscale - /usr/local/lib - /usr/lib - ) -endif() - -if(FFMPEG_INCLUDE_DIR) - if(FFMPEG_avformat_LIBRARY AND - FFMPEG_avcodec_LIBRARY AND - FFMPEG_avutil_LIBRARY AND - FFMPEG_swresample_LIBRARY AND - FFMPEG_swscale_LIBRARY - ) - set(FFMPEG_FOUND "YES") - if(${PLATFORM} MATCHES "Debian") - set(FFMPEG_LIBRARIES avformat-ffmpeg - avcodec-ffmpeg - avutil-ffmpeg - swresample-ffmpeg - swscale-ffmpeg - ) - else() - set(FFMPEG_LIBRARIES ${FFMPEG_avformat_LIBRARY} - ${FFMPEG_avcodec_LIBRARY} - ${FFMPEG_avutil_LIBRARY} - ${FFMPEG_swresample_LIBRARY} - ${FFMPEG_swscale_LIBRARY} - ) - endif() - endif() -endif() - -unset (PLATFORM) diff --git a/cmake/Modules/FindFFmpeg.cmake b/cmake/Modules/FindFFmpeg.cmake new file mode 100644 index 0000000000..a8c482dc21 --- /dev/null +++ b/cmake/Modules/FindFFmpeg.cmake @@ -0,0 +1,163 @@ +# FindFFmpeg +# ---------- +# +# Find the native FFmpeg includes and libraries +# +# This module defines the following variables: +# +# FFmpeg_INCLUDE_: where to find .h +# FFmpeg_LIBRARY_: where to find the library +# FFmpeg_INCLUDES: aggregate all the include paths +# FFmpeg_LIBRARIES: aggregate all the paths to the libraries +# FFmpeg_FOUND: True if all components have been found +# +# This module defines the following targets, which are prefered over variables: +# +# FFmpeg::: Target to use directly, with include path, +# library and dependencies set up. If you are using a static build, you are +# responsible for adding any external dependencies (such as zlib, bzlib...). +# +# can be one of: +# avcodec +# avdevice +# avfilter +# avformat +# postproc +# swresample +# swscale +# + +set(_FFmpeg_ALL_COMPONENTS + avcodec + avdevice + avfilter + avformat + avutil + postproc + swresample + swscale +) + +set(_FFmpeg_DEPS_avcodec avutil) +set(_FFmpeg_DEPS_avdevice avcodec avformat avutil) +set(_FFmpeg_DEPS_avfilter avutil) +set(_FFmpeg_DEPS_avformat avcodec avutil) +set(_FFmpeg_DEPS_postproc avutil) +set(_FFmpeg_DEPS_swresample avutil) +set(_FFmpeg_DEPS_swscale avutil) + +function(find_ffmpeg LIBNAME) + if(DEFINED ENV{FFMPEG_DIR}) + set(FFMPEG_DIR $ENV{FFMPEG_DIR}) + endif() + + if(FFMPEG_DIR) + list(APPEND INCLUDE_PATHS + ${FFMPEG_DIR} + ${FFMPEG_DIR}/ffmpeg + ${FFMPEG_DIR}/lib${LIBNAME} + ${FFMPEG_DIR}/include/lib${LIBNAME} + ${FFMPEG_DIR}/include/ffmpeg + ${FFMPEG_DIR}/include + NO_DEFAULT_PATH + NO_CMAKE_FIND_ROOT_PATH + ) + list(APPEND LIB_PATHS + ${FFMPEG_DIR} + ${FFMPEG_DIR}/lib + ${FFMPEG_DIR}/lib${LIBNAME} + NO_DEFAULT_PATH + NO_CMAKE_FIND_ROOT_PATH + ) + else() + list(APPEND INCLUDE_PATHS + /usr/local/include/ffmpeg + /usr/local/include/lib${LIBNAME} + /usr/include/ffmpeg + /usr/include/lib${LIBNAME} + /usr/include/ffmpeg/lib${LIBNAME} + ) + + list(APPEND LIB_PATHS + /usr/local/lib + /usr/lib + ) + endif() + + find_path(FFmpeg_INCLUDE_${LIBNAME} lib${LIBNAME}/${LIBNAME}.h + HINTS ${INCLUDE_PATHS} + ) + + find_library(FFmpeg_LIBRARY_${LIBNAME} ${LIBNAME} + HINTS ${LIB_PATHS} + ) + + if(NOT FFMPEG_DIR AND (NOT FFmpeg_LIBRARY_${LIBNAME} OR NOT FFmpeg_INCLUDE_${LIBNAME})) + # Didn't find it in the usual paths, try pkg-config + find_package(PkgConfig QUIET) + pkg_check_modules(FFmpeg_PKGCONFIG_${LIBNAME} REQUIRED QUIET lib${LIBNAME}) + + find_path(FFmpeg_INCLUDE_${LIBNAME} lib${LIBNAME}/${LIBNAME}.h + ${FFmpeg_PKGCONFIG_${LIBNAME}_INCLUDE_DIRS} + ) + + find_library(FFmpeg_LIBRARY_${LIBNAME} ${LIBNAME} + ${FFmpeg_PKGCONFIG_${LIBNAME}_LIBRARY_DIRS} + ) + endif() + + if(FFmpeg_INCLUDE_${LIBNAME} AND FFmpeg_LIBRARY_${LIBNAME}) + set(FFmpeg_INCLUDE_${LIBNAME} "${FFmpeg_INCLUDE_${LIBNAME}}" PARENT_SCOPE) + set(FFmpeg_LIBRARY_${LIBNAME} "${FFmpeg_LIBRARY_${LIBNAME}}" PARENT_SCOPE) + set(FFmpeg_${c}_FOUND TRUE PARENT_SCOPE) + if(NOT FFmpeg_FIND_QUIETLY) + message("-- Found ${LIBNAME}: ${FFmpeg_INCLUDE_${LIBNAME}} ${FFmpeg_LIBRARY_${LIBNAME}}") + endif() + endif() +endfunction() + +foreach(c ${_FFmpeg_ALL_COMPONENTS}) + find_ffmpeg(${c}) +endforeach() + +foreach(c ${_FFmpeg_ALL_COMPONENTS}) + if(FFmpeg_${c}_FOUND) + list(APPEND FFmpeg_INCLUDES ${FFmpeg_INCLUDE_${c}}) + list(APPEND FFmpeg_LIBRARIES ${FFmpeg_LIBRARY_${c}}) + + add_library(FFmpeg::${c} IMPORTED UNKNOWN) + set_target_properties(FFmpeg::${c} PROPERTIES + IMPORTED_LOCATION ${FFmpeg_LIBRARY_${c}} + INTERFACE_INCLUDE_DIRECTORIES ${FFmpeg_INCLUDE_${c}} + ) + if(_FFmpeg_DEPS_${c}) + set(deps) + foreach(dep ${_FFmpeg_DEPS_${c}}) + list(APPEND deps FFmpeg::${dep}) + endforeach() + + set_target_properties(FFmpeg::${c} PROPERTIES + INTERFACE_LINK_LIBRARIES "${deps}" + ) + unset(deps) + endif() + endif() +endforeach() + +list(REMOVE_DUPLICATES FFmpeg_INCLUDES) + +foreach(c ${FFmpeg_FIND_COMPONENTS}) + list(APPEND _FFmpeg_REQUIRED_VARS FFmpeg_INCLUDE_${c} FFmpeg_LIBRARY_${c}) +endforeach() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(FFmpeg + REQUIRED_VARS ${_FFmpeg_REQUIRED_VARS} + HANDLE_COMPONENTS +) + +foreach(c ${_FFmpeg_ALL_COMPONENTS}) + unset(_FFmpeg_DEPS_${c}) +endforeach() +unset(_FFmpeg_ALL_COMPONENTS) +unset(_FFmpeg_REQUIRED_VARS) From 2ba04f3bcd029481e5afbf5246cdda55a2ce1447 Mon Sep 17 00:00:00 2001 From: Florent Castelli Date: Sun, 18 Dec 2016 10:02:23 +0100 Subject: [PATCH 3/3] ios: Enable building for arm64 and simulator --- cmake/Toolchains/ios.cmake | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cmake/Toolchains/ios.cmake b/cmake/Toolchains/ios.cmake index aec662343b..718e270561 100644 --- a/cmake/Toolchains/ios.cmake +++ b/cmake/Toolchains/ios.cmake @@ -41,12 +41,12 @@ endif() set(IOS_PLATFORM ${IOS_PLATFORM} CACHE STRING "Type of iOS Platform") # Check the platform selection and setup for developer root -if(${IOS_PLATFORM} STREQUAL "OS") +if(IOS_PLATFORM STREQUAL "OS") set(IOS_SDK_NAME "iphoneos") -elseif(${IOS_PLATFORM} STREQUAL "SIMULATOR") +elseif(IOS_PLATFORM STREQUAL "SIMULATOR") set(IOS_SDK_NAME "iphonesimulator") else() - message (FATAL_ERROR "Unsupported IOS_PLATFORM value selected. Please choose OS or leave default") + message (FATAL_ERROR "Unsupported IOS_PLATFORM value selected '${IOS_PLATFORM}'. Please choose OS or leave default") endif() # Setup iOS developer location unless specified manually with CMAKE_IOS_DEVELOPER_ROOT @@ -64,12 +64,12 @@ set(CMAKE_IOS_SDK_ROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Location of the selecte set(CMAKE_OSX_SYSROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Sysroot used for iOS support") # set the architecture for iOS -if(${IOS_PLATFORM} STREQUAL "OS") +if(IOS_PLATFORM STREQUAL "OS") # When ffmpeg has been rebuilt for arm64 use: - #set(IOS_ARCH "armv7;arm64") - set(IOS_ARCH "armv7") + set(IOS_ARCH "armv7;arm64") + #set(IOS_ARCH "armv7") else() - set(IOS_ARCH i386) + set(IOS_ARCH "i386;x86_64") endif() set(CMAKE_OSX_ARCHITECTURES "${IOS_ARCH}" CACHE string "Build architecture for iOS")