FindFFmpeg.cmake 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. # ==============================================
  2. # Try to find FFmpeg libraries:
  3. # - avcodec
  4. # - avformat
  5. # - avdevice
  6. # - avutil
  7. # - swscale
  8. # - avfilter
  9. #
  10. # FFMPEG_FOUND - system has FFmpeg
  11. # FFMPEG_INCLUDE_DIR - the FFmpeg inc directory
  12. # FFMPEG_LIBRARIES - Link these to use FFmpeg
  13. # ==============================================
  14. # Notice: this original script is from internet.
  15. if (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR)
  16. # in cache already
  17. set(FFMPEG_FOUND TRUE)
  18. else (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR)
  19. find_path(
  20. FFMPEG_AVCODEC_INCLUDE_DIR
  21. NAMES libavcodec/avcodec.h
  22. PATHS ${_FFMPEG_AVCODEC_INCLUDE_DIRS}
  23. /usr/include/ffmpeg
  24. /usr/local/include
  25. /usr/include/x86_64-linux-gnu
  26. )
  27. find_library(
  28. FFMPEG_LIBAVCODEC
  29. NAMES avcodec
  30. PATHS ${_FFMPEG_AVCODEC_LIBRARY_DIRS}
  31. /usr/lib64
  32. /usr/local/lib
  33. /usr/lib/x86_64-linux-gnu
  34. )
  35. find_library(
  36. FFMPEG_LIBAVFORMAT
  37. NAMES avformat
  38. PATHS ${_FFMPEG_AVFORMAT_LIBRARY_DIRS}
  39. /usr/lib64
  40. /usr/local/lib
  41. /usr/lib/x86_64-linux-gnu
  42. )
  43. find_library(
  44. FFMPEG_LIBSWRESAMPLE
  45. NAMES swresample
  46. PATHS ${_FFMPEG_SWRESAMPLE_LIBRARY_DIRS}
  47. /usr/lib64
  48. /usr/local/lib
  49. /usr/lib/x86_64-linux-gnu
  50. )
  51. find_library(
  52. FFMPEG_LIBAVUTIL
  53. NAMES avutil
  54. PATHS ${_FFMPEG_AVUTIL_LIBRARY_DIRS}
  55. /usr/lib64
  56. /usr/local/lib
  57. /usr/lib/x86_64-linux-gnu
  58. )
  59. find_library(
  60. FFMPEG_LIBSWSCALE
  61. NAMES swscale
  62. PATHS ${_FFMPEG_SWSCALE_LIBRARY_DIRS}
  63. /usr/lib64
  64. /usr/local/lib
  65. /usr/lib/x86_64-linux-gnu
  66. )
  67. find_library(
  68. FFMPEG_LIBAVFILTER
  69. NAMES avfilter
  70. PATHS ${_FFMPEG_AVFILTER_LIBRARY_DIRS}
  71. /usr/lib64
  72. /usr/local/lib
  73. /usr/lib/x86_64-linux-gnu
  74. )
  75. if (FFMPEG_LIBAVCODEC AND FFMPEG_LIBAVFORMAT AND FFMPEG_LIBAVUTIL)
  76. set(FFMPEG_FOUND TRUE)
  77. endif ()
  78. if (FFMPEG_FOUND)
  79. set(FFMPEG_INCLUDE_DIR ${FFMPEG_AVCODEC_INCLUDE_DIR})
  80. set(FFMPEG_LIBRARIES
  81. ${FFMPEG_LIBAVCODEC}
  82. ${FFMPEG_LIBAVFORMAT}
  83. ${FFMPEG_LIBAVUTIL})
  84. else (FFMPEG_FOUND)
  85. message(FATAL_ERROR "Could not find FFmpeg libraries!")
  86. endif (FFMPEG_FOUND)
  87. endif (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR)