Skip to content

Ffmpeg generalize cmake #4033

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions third_party/ffmpeg/single/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,36 @@
message(STATUS "Searching existing FFmpeg installation")
message(STATUS FFMPEG_ROOT=$ENV{FFMPEG_ROOT})
if (NOT DEFINED ENV{FFMPEG_ROOT})
message(FATAL_ERROR "Environment variable FFMPEG_ROOT is not set.")
message(STATUS "FFMPEG_ROOT not set, will search system paths")
endif()

# Maintain FFMPEG_ROOT approach and add common system paths
set(_root $ENV{FFMPEG_ROOT})
set(lib_dirs "${_root}/lib" "${_root}/bin")
set(include_dir "${_root}/include")
set(lib_dirs "${_root}/lib" "${_root}/bin" "/usr/lib64" "/usr/lib" "/usr/local/lib64" "/usr/local/lib")
set(include_dir "${_root}/include" "/usr/include/ffmpeg" "/usr/include" "/usr/local/include")

# Add multiarch paths for Debian/Ubuntu
execute_process(COMMAND gcc -print-multiarch OUTPUT_VARIABLE MULTIARCH_TRIPLET
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
if(MULTIARCH_TRIPLET)
list(APPEND lib_dirs "/usr/lib/${MULTIARCH_TRIPLET}")
list(APPEND include_dir "/usr/include/${MULTIARCH_TRIPLET}")
endif()

add_library(ffmpeg INTERFACE)
target_include_directories(ffmpeg INTERFACE "${include_dir}")
target_include_directories(ffmpeg INTERFACE ${include_dir})

function (_find_ffmpeg_lib component)
find_path("${component}_header"
NAMES "lib${component}/${component}.h"
PATHS "${include_dir}"
PATHS ${include_dir}
DOC "The include directory for ${component}"
REQUIRED
NO_DEFAULT_PATH)
REQUIRED)
find_library("lib${component}"
NAMES "${component}"
PATHS ${lib_dirs}
DOC "${component} library"
REQUIRED
NO_DEFAULT_PATH)
REQUIRED)
message(STATUS "Found ${component}: ${lib${component}}")
target_link_libraries(
ffmpeg
Expand Down