From 8108946993664e86d25ca6ab188091d13bf76ed5 Mon Sep 17 00:00:00 2001 From: Sean McGovern Date: Mon, 11 Aug 2025 18:50:46 +0000 Subject: [PATCH 1/2] generalize ffmpeg cmake for linux distros --- third_party/ffmpeg/single/CMakeLists.txt | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/third_party/ffmpeg/single/CMakeLists.txt b/third_party/ffmpeg/single/CMakeLists.txt index b3246c0828..82ebc6ebf4 100644 --- a/third_party/ffmpeg/single/CMakeLists.txt +++ b/third_party/ffmpeg/single/CMakeLists.txt @@ -3,12 +3,21 @@ 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}") @@ -18,14 +27,12 @@ function (_find_ffmpeg_lib component) NAMES "lib${component}/${component}.h" 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 From 0ec7ae4697fdc98cb642ac2e519a78b26e5cce92 Mon Sep 17 00:00:00 2001 From: Sean McGovern Date: Mon, 11 Aug 2025 18:57:19 +0000 Subject: [PATCH 2/2] fix: use list instead of string --- third_party/ffmpeg/single/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/third_party/ffmpeg/single/CMakeLists.txt b/third_party/ffmpeg/single/CMakeLists.txt index 82ebc6ebf4..316f19d35e 100644 --- a/third_party/ffmpeg/single/CMakeLists.txt +++ b/third_party/ffmpeg/single/CMakeLists.txt @@ -20,12 +20,12 @@ if(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) find_library("lib${component}"