106 lines
2.5 KiB
CMake
106 lines
2.5 KiB
CMake
# FindFFmpeg.cmake
|
|
# CMake module to find FFmpeg installation
|
|
#
|
|
# This module defines:
|
|
# FFMPEG_FOUND - True if FFmpeg was found
|
|
# FFMPEG_VERSION - FFmpeg version
|
|
# FFMPEG_INCLUDE_DIR - FFmpeg include directory
|
|
# FFMPEG_LIBRARIES - List of FFmpeg libraries to link
|
|
# FFMPEG_DLL_DIR - Directory containing FFmpeg DLLs
|
|
|
|
# Use environment variable or default path
|
|
if(NOT DEFINED FFMPEG_ROOT)
|
|
if(DEFINED ENV{FFMPEG_ROOT})
|
|
set(FFMPEG_ROOT $ENV{FFMPEG_ROOT})
|
|
else()
|
|
# Default: look in third_party/ffmpeg relative to project root
|
|
set(FFMPEG_ROOT "${CMAKE_SOURCE_DIR}/third_party/ffmpeg")
|
|
endif()
|
|
endif()
|
|
|
|
# Find FFmpeg include directory
|
|
find_path(FFMPEG_INCLUDE_DIR
|
|
NAMES libavcodec/avcodec.h
|
|
PATHS ${FFMPEG_ROOT}/include
|
|
NO_DEFAULT_PATH
|
|
DOC "FFmpeg include directory"
|
|
)
|
|
|
|
# Find FFmpeg libraries
|
|
find_library(AVCODEC_LIBRARY
|
|
NAMES avcodec
|
|
PATHS ${FFMPEG_ROOT}/lib
|
|
NO_DEFAULT_PATH
|
|
DOC "FFmpeg avcodec library"
|
|
)
|
|
|
|
find_library(AVFORMAT_LIBRARY
|
|
NAMES avformat
|
|
PATHS ${FFMPEG_ROOT}/lib
|
|
NO_DEFAULT_PATH
|
|
DOC "FFmpeg avformat library"
|
|
)
|
|
|
|
find_library(AVUTIL_LIBRARY
|
|
NAMES avutil
|
|
PATHS ${FFMPEG_ROOT}/lib
|
|
NO_DEFAULT_PATH
|
|
DOC "FFmpeg avutil library"
|
|
)
|
|
|
|
find_library(SWSCALE_LIBRARY
|
|
NAMES swscale
|
|
PATHS ${FFMPEG_ROOT}/lib
|
|
NO_DEFAULT_PATH
|
|
DOC "FFmpeg swscale library"
|
|
)
|
|
|
|
find_library(SWRESAMPLE_LIBRARY
|
|
NAMES swresample
|
|
PATHS ${FFMPEG_ROOT}/lib
|
|
NO_DEFAULT_PATH
|
|
DOC "FFmpeg swresample library"
|
|
)
|
|
|
|
# Collect libraries
|
|
set(FFMPEG_LIBRARIES)
|
|
foreach(LIB AVCODEC AVFORMAT AVUTIL SWSCALE SWRESAMPLE)
|
|
if(${LIB}_LIBRARY)
|
|
list(APPEND FFMPEG_LIBRARIES "${${LIB}_LIBRARY}")
|
|
endif()
|
|
endforeach()
|
|
|
|
# Set DLL directory
|
|
set(FFMPEG_DLL_DIR "${FFMPEG_ROOT}/bin" CACHE PATH "FFmpeg DLL directory")
|
|
|
|
# Handle QUIET and REQUIRED arguments
|
|
include(FindPackageHandleStandardArgs)
|
|
find_package_handle_standard_args(FFmpeg
|
|
REQUIRED_VARS
|
|
FFMPEG_INCLUDE_DIR
|
|
AVCODEC_LIBRARY
|
|
AVFORMAT_LIBRARY
|
|
AVUTIL_LIBRARY
|
|
SWSCALE_LIBRARY
|
|
)
|
|
|
|
# Mark as advanced
|
|
mark_as_advanced(
|
|
FFMPEG_INCLUDE_DIR
|
|
AVCODEC_LIBRARY
|
|
AVFORMAT_LIBRARY
|
|
AVUTIL_LIBRARY
|
|
SWSCALE_LIBRARY
|
|
SWRESAMPLE_LIBRARY
|
|
FFMPEG_DLL_DIR
|
|
)
|
|
|
|
# Print status message
|
|
if(NOT FFmpeg_FIND_QUIETLY)
|
|
if(FFMPEG_FOUND)
|
|
message(STATUS "Found FFmpeg: ${FFMPEG_ROOT}")
|
|
else()
|
|
message(STATUS "FFmpeg not found. Set FFMPEG_ROOT environment variable.")
|
|
endif()
|
|
endif()
|