diff options
author | Brecht Van Lommel <brecht> | 2022-01-12 20:21:43 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2022-01-13 12:27:11 +0300 |
commit | 75a1a578bd5da53fd59ff6bc939ac80b8c65cbc2 (patch) | |
tree | cee6127aefe9298e4bb5b041ea7131fd23396d9d /build_files/cmake | |
parent | f1a488d0f2d3736482d68b96d7b4edecdae2beda (diff) |
CMake: use FFmpeg find module on Linux
And change install_deps.sh to build shared (instead of static) FFMPEG
libraries, for consistency with other library dependencies and to simplify
the logic. This may require users of install_deps.sh to rebuild FFMPEG.
This is the last step that lets us get rid of LIBPATH variables and
link_directories() entirely, as recommended by the CMake docs.
Some fixes were needed in the find FFMPEG module to make it actually work,
this code was unused up to now.
Followup to D8855.
Differential Revision: https://developer.blender.org/D9177
Diffstat (limited to 'build_files/cmake')
-rw-r--r-- | build_files/cmake/Modules/FindFFmpeg.cmake | 6 | ||||
-rw-r--r-- | build_files/cmake/platform/platform_apple.cmake | 1 | ||||
-rw-r--r-- | build_files/cmake/platform/platform_unix.cmake | 36 |
3 files changed, 22 insertions, 21 deletions
diff --git a/build_files/cmake/Modules/FindFFmpeg.cmake b/build_files/cmake/Modules/FindFFmpeg.cmake index 0765c1dc901..5f506a33e13 100644 --- a/build_files/cmake/Modules/FindFFmpeg.cmake +++ b/build_files/cmake/Modules/FindFFmpeg.cmake @@ -33,6 +33,8 @@ if(NOT FFMPEG_FIND_COMPONENTS) avfilter avformat avutil + swscale + swresample ) endif() @@ -50,9 +52,9 @@ foreach(_component ${FFMPEG_FIND_COMPONENTS}) string(TOUPPER ${_component} _upper_COMPONENT) find_library(FFMPEG_${_upper_COMPONENT}_LIBRARY NAMES - ${_upper_COMPONENT} + ${_component} HINTS - ${LIBDIR}/ffmpeg + ${_ffmpeg_SEARCH_DIRS} PATH_SUFFIXES lib64 lib ) diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake index 15bd02230c3..929be0c93f7 100644 --- a/build_files/cmake/platform/platform_apple.cmake +++ b/build_files/cmake/platform/platform_apple.cmake @@ -173,6 +173,7 @@ if(WITH_IMAGE_OPENEXR) endif() if(WITH_CODEC_FFMPEG) + set(FFMPEG_ROOT_DIR ${LIBDIR}/ffmpeg) set(FFMPEG_FIND_COMPONENTS avcodec avdevice avformat avutil mp3lame ogg opus swresample swscale diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake index 0aaec3083a3..dce78fb0c8e 100644 --- a/build_files/cmake/platform/platform_unix.cmake +++ b/build_files/cmake/platform/platform_unix.cmake @@ -178,26 +178,24 @@ endif() if(WITH_CODEC_FFMPEG) if(EXISTS ${LIBDIR}) - # For precompiled lib directory, all ffmpeg dependencies are in the same folder - file(GLOB ffmpeg_libs ${LIBDIR}/ffmpeg/lib/*.a ${LIBDIR}/sndfile/lib/*.a) - set(FFMPEG ${LIBDIR}/ffmpeg CACHE PATH "FFMPEG Directory") - set(FFMPEG_LIBRARIES ${ffmpeg_libs} ${ffmpeg_libs} CACHE STRING "FFMPEG Libraries") - else() - set(FFMPEG /usr CACHE PATH "FFMPEG Directory") - set(FFMPEG_LIBRARIES avformat avcodec avutil avdevice swscale CACHE STRING "FFMPEG Libraries") + set(FFMPEG_ROOT_DIR ${LIBDIR}/ffmpeg) + # Override FFMPEG components to also include static library dependencies. + # included with precompiled libraries. + set(FFMPEG_FIND_COMPONENTS + avcodec avdevice avformat avutil + mp3lame ogg opus swresample swscale + theora theoradec theoraenc vorbis vorbisenc + vorbisfile vpx x264 xvidcore) + elseif(FFMPEG) + # Old cache variable used for root dir, convert to new standard. + set(FFMPEG_ROOT_DIR ${FFMPEG}) + endif() + find_package(FFmpeg) + + if(NOT FFMPEG_FOUND) + set(WITH_CODEC_FFMPEG OFF) + message(STATUS "FFmpeg not found, disabling it") endif() - - mark_as_advanced(FFMPEG) - - # lame, but until we have proper find module for ffmpeg - set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include) - if(EXISTS "${FFMPEG}/include/ffmpeg/") - list(APPEND FFMPEG_INCLUDE_DIRS "${FFMPEG}/include/ffmpeg") - endif() - # end lameness - - mark_as_advanced(FFMPEG_LIBRARIES) - set(FFMPEG_LIBPATH ${FFMPEG}/lib) endif() if(WITH_FFTW3) |