[Bf-blender-cvs] [e594f23a27f] master: Revert "CMake: use FFmpeg find module on Linux"

Brecht Van Lommel noreply at git.blender.org
Wed Jan 12 19:14:11 CET 2022


Commit: e594f23a27fe01a1b34345a25914ce7defe9c62a
Author: Brecht Van Lommel
Date:   Wed Jan 12 19:07:40 2022 +0100
Branches: master
https://developer.blender.org/rBe594f23a27fe01a1b34345a25914ce7defe9c62a

Revert "CMake: use FFmpeg find module on Linux"

This reverts commit 62a0de1673302fb7f15fe06efaf6f0f97d92d240. Linux buildbot
is giving link errors.

===================================================================

M	build_files/build_environment/install_deps.sh
M	build_files/cmake/Modules/FindFFmpeg.cmake
M	build_files/cmake/platform/platform_apple.cmake
M	build_files/cmake/platform/platform_unix.cmake

===================================================================

diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh
index bf24c3ef285..c38973b274f 100755
--- a/build_files/build_environment/install_deps.sh
+++ b/build_files/build_environment/install_deps.sh
@@ -3620,8 +3620,8 @@ compile_FFmpeg() {
     fi
 
     ./configure --cc="gcc -Wl,--as-needed" \
-        --extra-ldflags="-pthread" \
-        --prefix=$_inst --enable-shared \
+        --extra-ldflags="-pthread -static-libgcc" \
+        --prefix=$_inst --enable-static \
         --disable-ffplay --disable-doc \
         --enable-gray \
         --enable-avfilter --disable-vdpau \
@@ -5721,6 +5721,76 @@ install_OTHER() {
 # ----------------------------------------------------------------------------
 # Printing User Info
 
+print_info_ffmpeglink_DEB() {
+  dpkg -L $_packages | grep -e ".*\/lib[^\/]\+\.so" | gawk '{ printf(nlines ? "'"$_ffmpeg_list_sep"'%s" : "%s", gensub(/.*lib([^\/]+)\.so/, "\\1", "g", $0)); nlines++ }'
+}
+
+print_info_ffmpeglink_RPM() {
+  rpm -ql $_packages | grep -e ".*\/lib[^\/]\+\.so" | gawk '{ printf(nlines ? "'"$_ffmpeg_list_sep"'%s" : "%s", gensub(/.*lib([^\/]+)\.so/, "\\1", "g", $0)); nlines++ }'
+}
+
+print_info_ffmpeglink_ARCH() {
+  pacman -Ql $_packages | grep -e ".*\/lib[^\/]\+\.so$" | gawk '{ printf(nlines ? "'"$_ffmpeg_list_sep"'%s" : "%s", gensub(/.*lib([^\/]+)\.so/, "\\1", "g", $0)); nlines++ }'
+}
+
+print_info_ffmpeglink() {
+  # This func must only print a ';'-separated list of libs...
+  if [ -z "$DISTRO" ]; then
+    ERROR "Failed to detect distribution type"
+    exit 1
+  fi
+
+  # Create list of packages from which to get libs names...
+  _packages=""
+
+  if [ "$THEORA_USE" = true ]; then
+    _packages="$_packages $THEORA_DEV"
+  fi
+
+  if [ "$VORBIS_USE" = true ]; then
+    _packages="$_packages $VORBIS_DEV"
+  fi
+
+  if [ "$OGG_USE" = true ]; then
+    _packages="$_packages $OGG_DEV"
+  fi
+
+  if [ "$XVID_USE" = true ]; then
+    _packages="$_packages $XVID_DEV"
+  fi
+
+  if [ "$VPX_USE" = true ]; then
+    _packages="$_packages $VPX_DEV"
+  fi
+
+  if [ "$OPUS_USE" = true ]; then
+    _packages="$_packages $OPUS_DEV"
+  fi
+
+  if [ "$MP3LAME_USE" = true ]; then
+    _packages="$_packages $MP3LAME_DEV"
+  fi
+
+  if [ "$X264_USE" = true ]; then
+    _packages="$_packages $X264_DEV"
+  fi
+
+  if [ "$OPENJPEG_USE" = true ]; then
+    _packages="$_packages $OPENJPEG_DEV"
+  fi
+
+  if [ "$DISTRO" = "DEB" ]; then
+    print_info_ffmpeglink_DEB
+  elif [ "$DISTRO" = "RPM" ]; then
+    print_info_ffmpeglink_RPM
+  elif [ "$DISTRO" = "ARCH" ]; then
+    print_info_ffmpeglink_ARCH
+  # XXX TODO!
+  else
+    PRINT "<Could not determine additional link libraries needed for ffmpeg, replace this by valid list of libs...>"
+  fi
+}
+
 print_info() {
   PRINT ""
   PRINT ""
@@ -5932,10 +6002,12 @@ print_info() {
 
   if [ "$FFMPEG_SKIP" = false ]; then
     _1="-D WITH_CODEC_FFMPEG=ON"
+    _2="-D FFMPEG_LIBRARIES='avformat;avcodec;avutil;avdevice;swscale;swresample;lzma;rt;`print_info_ffmpeglink`'"
     PRINT "  $_1"
-    _buildargs="$_buildargs $_1"
+    PRINT "  $_2"
+    _buildargs="$_buildargs $_1 $_2"
     if [ -d $INST/ffmpeg ]; then
-      _1="-D FFMPEG_ROOT_DIR=$INST/ffmpeg"
+      _1="-D FFMPEG=$INST/ffmpeg"
       PRINT "  $_1"
       _buildargs="$_buildargs $_1"
     fi
diff --git a/build_files/cmake/Modules/FindFFmpeg.cmake b/build_files/cmake/Modules/FindFFmpeg.cmake
index 5f506a33e13..0765c1dc901 100644
--- a/build_files/cmake/Modules/FindFFmpeg.cmake
+++ b/build_files/cmake/Modules/FindFFmpeg.cmake
@@ -33,8 +33,6 @@ if(NOT FFMPEG_FIND_COMPONENTS)
     avfilter
     avformat
     avutil
-    swscale
-    swresample
   )
 endif()
 
@@ -52,9 +50,9 @@ foreach(_component ${FFMPEG_FIND_COMPONENTS})
   string(TOUPPER ${_component} _upper_COMPONENT)
   find_library(FFMPEG_${_upper_COMPONENT}_LIBRARY
     NAMES
-      ${_component}
+      ${_upper_COMPONENT}
     HINTS
-      ${_ffmpeg_SEARCH_DIRS}
+      ${LIBDIR}/ffmpeg
     PATH_SUFFIXES
       lib64 lib
   )
diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake
index 929be0c93f7..15bd02230c3 100644
--- a/build_files/cmake/platform/platform_apple.cmake
+++ b/build_files/cmake/platform/platform_apple.cmake
@@ -173,7 +173,6 @@ 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 dce78fb0c8e..0aaec3083a3 100644
--- a/build_files/cmake/platform/platform_unix.cmake
+++ b/build_files/cmake/platform/platform_unix.cmake
@@ -178,24 +178,26 @@ endif()
 
 if(WITH_CODEC_FFMPEG)
   if(EXISTS ${LIBDIR})
-    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")
+    # 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")
   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)



More information about the Bf-blender-cvs mailing list