]> git.sesse.net Git - kdenlive/blob - cmake/modules/FindLIBFFMPEG.cmake
Updated FFmpeg detection
[kdenlive] / cmake / modules / FindLIBFFMPEG.cmake
1 #
2 # Find the FFMPEG includes and library
3 #
4
5 FIND_PROGRAM(FFMPEG_CONFIG_EXECUTABLE pkg-config)
6 EXEC_PROGRAM(${FFMPEG_CONFIG_EXECUTABLE} ARGS --variable=includedir libavformat OUTPUT_VARIABLE FFMPEG_HEADER_PATH )
7 #MESSAGE(STATUS "Found FFmpeg header pkg-config: ${FFMPEG_CONFIG_EXECUTABLE} , ${FFMPEG_HEADER_PATH}")
8 EXEC_PROGRAM(${FFMPEG_CONFIG_EXECUTABLE} ARGS --variable=libdir libavformat OUTPUT_VARIABLE FFMPEG_LIBS_PATH )
9 #MESSAGE(STATUS "Found FFmpeg lib pkg-config: ${FFMPEG_CONFIG_EXECUTABLE} , ${FFMPEG_LIBS_PATH}")
10
11 FIND_PATH(LIBFFMPEG_INCLUDE_DIR 
12   NAMES avformat.h
13   PATHS ${FFMPEG_HEADER_PATH}/ffmpeg ${FFMPEG_HEADER_PATH}/libavformat ${FFMPEG_HEADER_PATH}/ffmpeg/libavformat
14   /usr/include/ffmpeg /usr/include/libavformat /usr/include/ffmpeg/libavformat
15   /usr/local/include/ffmpeg /usr/local/include/libavformat /usr/local/include/ffmpeg/libavformat
16   NO_DEFAULT_PATH
17 )
18
19 IF (LIBFFMPEG_INCLUDE_DIR)
20   MESSAGE(STATUS "Found FFmpeg Libavformat includes: ${LIBFFMPEG_INCLUDE_DIR}")
21 ELSE (LIBFFMPEG_INCLUDE_DIR)
22   MESSAGE(FATAL_ERROR "\n***************************\n"
23     "Could not find FFmpeg Libavformat includes\n"
24     "please install the libavformat-dev package or give the path manually using\n"
25     "-DLIBFFMPEG_INCLUDE_DIR=PATH_TO_YOUR_AVFORMAT_HEADERS"
26     "\n***************************\n")
27 ENDIF (LIBFFMPEG_INCLUDE_DIR)
28
29 FIND_LIBRARY(LIBFFMPEG_LIBRARY
30   NAMES avformat
31   PATHS ${FFMPEG_LIBS_PATH}
32   /usr/lib /usr/local/lib
33   NO_DEFAULT_PATH
34 )
35
36 IF (LIBFFMPEG_LIBRARY)
37   MESSAGE(STATUS "Found FFmpeg Libavformat library: ${LIBFFMPEG_LIBRARY}")
38 ELSE (LIBFFMPEG_LIBRARY)
39   MESSAGE(FATAL_ERROR "\n***************************\n"
40     "Could not find FFmpeg Libavformat library\n"
41     "please install the libavformat package or give the path manually using\n"
42     "-DLIBFFMPEG_LIBRARY=PATH_TO_YOUR_AVFORMAT_LIBRARY"
43     "\n***************************\n")
44 ENDIF (LIBFFMPEG_LIBRARY)
45
46 IF (LIBFFMPEG_LIBRARY AND LIBFFMPEG_INCLUDE_DIR)
47   SET( LIBFFMPEG_FOUND 1 )
48   SET( LIBFFMPEG_LIBRARIES ${LIBFFMPEG_LIBRARY} )
49 ELSE (LIBFFMPEG_LIBRARY AND LIBFFMPEG_INCLUDE_DIR)
50   SET( LIBFFMPEG_FOUND 0 )
51 ENDIF (LIBFFMPEG_LIBRARY AND LIBFFMPEG_INCLUDE_DIR)
52
53