CMakeLists.txt 1.13 KB
Newer Older
mayp777's avatar
UPDATE  
mayp777 committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# CMake file for searching existing FFmpeg installation and defining ffmpeg TARGET

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.")
endif()

set(_root $ENV{FFMPEG_ROOT})
set(lib_dirs "${_root}/lib" "${_root}/bin")
set(include_dir "${_root}/include")

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

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

_find_ffmpeg_lib(avutil)
_find_ffmpeg_lib(avcodec)
_find_ffmpeg_lib(avformat)
_find_ffmpeg_lib(avdevice)
_find_ffmpeg_lib(avfilter)