From 655b28ee0c88afcc50bb70c9b3ff00d72aa6214d Mon Sep 17 00:00:00 2001 From: Mansour Moufid Date: Sun, 1 Feb 2015 15:51:33 -0500 Subject: [PATCH] Use the CMake find_library command to find the FFmpeg libraries. Conflicts: cmake/OpenCVFindLibsVideo.cmake --- cmake/OpenCVFindLibsVideo.cmake | 70 +++++++++++++++------------------ 1 file changed, 32 insertions(+), 38 deletions(-) diff --git a/cmake/OpenCVFindLibsVideo.cmake b/cmake/OpenCVFindLibsVideo.cmake index af46ac5086..b2d927957f 100644 --- a/cmake/OpenCVFindLibsVideo.cmake +++ b/cmake/OpenCVFindLibsVideo.cmake @@ -216,49 +216,43 @@ if(WITH_FFMPEG) # Do an other trial FIND_FILE(BZIP2_LIBRARIES NAMES libbz2.so.1 PATHS /lib) endif() - endif(HAVE_FFMPEG) - endif() - - if(APPLE) - find_path(FFMPEG_INCLUDE_DIR "libavformat/avformat.h" - PATHS /usr/local /usr /opt - PATH_SUFFIXES include - DOC "The path to FFMPEG headers") - if(FFMPEG_INCLUDE_DIR) - set(HAVE_GENTOO_FFMPEG TRUE) - set(FFMPEG_LIB_DIR "${FFMPEG_INCLUDE_DIR}/../lib" CACHE PATH "Full path of FFMPEG library directory") - if(EXISTS "${FFMPEG_LIB_DIR}/libavcodec.a") - set(HAVE_FFMPEG_CODEC 1) - set(ALIASOF_libavcodec_VERSION "Unknown") - if(EXISTS "${FFMPEG_LIB_DIR}/libavformat.a") - set(HAVE_FFMPEG_FORMAT 1) + else() + find_path(FFMPEG_INCLUDE_DIR "libavformat/avformat.h" + PATHS /usr/local /usr /opt + PATH_SUFFIXES include + DOC "The path to FFMPEG headers") + if(FFMPEG_INCLUDE_DIR) + set(HAVE_GENTOO_FFMPEG TRUE) + set(FFMPEG_LIB_DIR "${FFMPEG_INCLUDE_DIR}/../lib" CACHE PATH "Full path of FFMPEG library directory") + find_library(FFMPEG_CODEC_LIB "avcodec" HINTS "${FFMPEG_LIB_DIR}") + find_library(FFMPEG_FORMAT_LIB "avformat" HINTS "${FFMPEG_LIB_DIR}") + find_library(FFMPEG_UTIL_LIB "avutil" HINTS "${FFMPEG_LIB_DIR}") + find_library(FFMPEG_SWSCALE_LIB "swscale" HINTS "${FFMPEG_LIB_DIR}") + find_library(FFMPEG_RESAMPLE_LIB "avresample" HINTS "${FFMPEG_LIB_DIR}") + if(FFMPEG_CODEC_LIB AND FFMPEG_FORMAT_LIB AND + FFMPEG_UTIL_LIB AND FFMPEG_SWSCALE_LIB) + set(ALIASOF_libavcodec_VERSION "Unknown") set(ALIASOF_libavformat_VERSION "Unknown") - if(EXISTS "${FFMPEG_LIB_DIR}/libavutil.a") - set(HAVE_FFMPEG_UTIL 1) - set(ALIASOF_libavutil_VERSION "Unknown") - if(EXISTS "${FFMPEG_LIB_DIR}/libswscale.a") - set(HAVE_FFMPEG_SWSCALE 1) - set(ALIASOF_libswscale_VERSION "Unknown") - set(HAVE_FFMPEG 1) - if(EXISTS "${FFMPEG_LIB_DIR}/libavresample.a") - set(HAVE_FFMPEG_RESAMPLE 1) - set(ALIASOF_libavresample_VERSION "Unknown") - endif() - endif() + set(ALIASOF_libavutil_VERSION "Unknown") + set(ALIASOF_libswscale_VERSION "Unknown") + set(HAVE_FFMPEG 1) + if(FFMPEG_RESAMPLE_LIB) + set(HAVE_FFMPEG_RESAMPLE 1) + set(ALIASOF_libavresample_VERSION "Unknown") endif() endif() - endif() - endif(FFMPEG_INCLUDE_DIR) - if(HAVE_FFMPEG) - set(VIDEOIO_LIBRARIES ${VIDEOIO_LIBRARIES} "${FFMPEG_LIB_DIR}/libavcodec.a" - "${FFMPEG_LIB_DIR}/libavformat.a" "${FFMPEG_LIB_DIR}/libavutil.a" - "${FFMPEG_LIB_DIR}/libswscale.a") - if(HAVE_FFMPEG_RESAMPLE) + endif(FFMPEG_INCLUDE_DIR) + if(HAVE_FFMPEG) + set(VIDEOIO_LIBRARIES ${VIDEOIO_LIBRARIES} "${FFMPEG_LIB_DIR}/libavcodec.a" + "${FFMPEG_LIB_DIR}/libavformat.a" "${FFMPEG_LIB_DIR}/libavutil.a" + "${FFMPEG_LIB_DIR}/libswscale.a") + if(HAVE_FFMPEG_RESAMPLE) set(VIDEOIO_LIBRARIES ${VIDEOIO_LIBRARIES} "${FFMPEG_LIB_DIR}/libavresample.a") - endif() - ocv_include_directories(${FFMPEG_INCLUDE_DIR}) + endif() + ocv_include_directories(${FFMPEG_INCLUDE_DIR}) + endif(HAVE_FFMPEG) endif() - endif(APPLE) + endif() endif(WITH_FFMPEG) # --- VideoInput/DirectShow ---