FindFFMPEG.cmake 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. # Filename: FindFFMPEG.cmake
  2. # Author: CFSworks (10 Apr, 2014)
  3. #
  4. # Usage:
  5. # find_package(FFMPEG [REQUIRED] [QUIET])
  6. #
  7. # Once done this will define:
  8. # FFMPEG_FOUND - system has ffmpeg
  9. # FFMPEG_INCLUDE_DIR - the ffmpeg include directory
  10. # FFMPEG_LIBRARIES - the path to the library binary
  11. #
  12. # FFMPEG_LIBAVCODEC - the path to the libavcodec library binary
  13. # FFMPEG_LIBAVFORMAT - the path to the libavformat library binary
  14. # FFMPEG_LIBAVUTIL - the path to the libavutil library binary
  15. #
  16. # Find the libffmpeg include files
  17. find_path(FFMPEG_INCLUDE_DIR
  18. NAMES "libavcodec/avcodec.h"
  19. PATHS "/usr/include"
  20. "/usr/local/include"
  21. "/sw/include"
  22. "/opt/include"
  23. "/opt/local/include"
  24. "/opt/csw/include"
  25. PATH_SUFFIXES "libav" "ffmpeg"
  26. )
  27. # Find the libavcodec library
  28. find_library(FFMPEG_LIBAVCODEC
  29. NAMES "avcodec"
  30. PATHS "/usr"
  31. "/usr/local"
  32. "/usr/freeware"
  33. "/sw"
  34. "/opt"
  35. "/opt/csw"
  36. PATH_SUFFIXES "lib" "lib32" "lib64"
  37. )
  38. # Find the libavformat library
  39. find_library(FFMPEG_LIBAVFORMAT
  40. NAMES "avformat"
  41. PATHS "/usr"
  42. "/usr/local"
  43. "/usr/freeware"
  44. "/sw"
  45. "/opt"
  46. "/opt/csw"
  47. PATH_SUFFIXES "lib" "lib32" "lib64"
  48. )
  49. # Find the libavutil library
  50. find_library(FFMPEG_LIBAVUTIL
  51. NAMES "avutil"
  52. PATHS "/usr"
  53. "/usr/local"
  54. "/usr/freeware"
  55. "/sw"
  56. "/opt"
  57. "/opt/csw"
  58. PATH_SUFFIXES "lib" "lib32" "lib64"
  59. )
  60. mark_as_advanced(FFMPEG_INCLUDE_DIR)
  61. mark_as_advanced(FFMPEG_LIBAVCODEC)
  62. mark_as_advanced(FFMPEG_LIBAVFORMAT)
  63. mark_as_advanced(FFMPEG_LIBAVUTIL)
  64. # Translate library into library directory
  65. if(FFMPEG_LIBAVCODEC)
  66. unset(FFMPEG_LIBRARY_DIR CACHE)
  67. get_filename_component(FFMPEG_LIBRARY_DIR "${FFMPEG_LIBAVCODEC}" PATH)
  68. set(FFMPEG_LIBRARY_DIR "${FFMPEG_LIBRARY_DIR}" CACHE PATH "The path to libffmpeg's library directory.") # Library path
  69. endif()
  70. set(FFMPEG_LIBRARIES)
  71. if(FFMPEG_LIBAVCODEC)
  72. list(APPEND FFMPEG_LIBRARIES "${FFMPEG_LIBAVCODEC}")
  73. endif()
  74. if(FFMPEG_LIBAVFORMAT)
  75. list(APPEND FFMPEG_LIBRARIES "${FFMPEG_LIBAVFORMAT}")
  76. endif()
  77. if(FFMPEG_LIBAVUTIL)
  78. list(APPEND FFMPEG_LIBRARIES "${FFMPEG_LIBAVUTIL}")
  79. endif()
  80. if(APPLE)
  81. # When statically built for Apple, FFMPEG may have dependencies on these
  82. # additional frameworks and libraries.
  83. find_library(APPLE_AUDIOTOOLBOX_LIBRARY AudioToolbox)
  84. if(APPLE_AUDIOTOOLBOX_LIBRARY)
  85. list(APPEND FFMPEG_LIBRARIES "${APPLE_AUDIOTOOLBOX_LIBRARY}")
  86. endif()
  87. find_library(APPLE_COREMEDIA_LIBRARY CoreMedia)
  88. if(APPLE_COREMEDIA_LIBRARY)
  89. list(APPEND FFMPEG_LIBRARIES "${APPLE_COREMEDIA_LIBRARY}")
  90. endif()
  91. find_library(APPLE_COREVIDEO_LIBRARY CoreVideo)
  92. if(APPLE_COREVIDEO_LIBRARY)
  93. list(APPEND FFMPEG_LIBRARIES "${APPLE_COREVIDEO_LIBRARY}")
  94. endif()
  95. find_library(APPLE_SECURITY_LIBRARY Security)
  96. if(APPLE_SECURITY_LIBRARY)
  97. list(APPEND FFMPEG_LIBRARIES "${APPLE_SECURITY_LIBRARY}")
  98. endif()
  99. find_library(APPLE_VDA_LIBRARY VideoDecodeAcceleration)
  100. if(APPLE_VDA_LIBRARY)
  101. list(APPEND FFMPEG_LIBRARIES "${APPLE_VDA_LIBRARY}")
  102. endif()
  103. find_library(APPLE_VIDEOTOOLBOX_LIBRARY VideoToolbox)
  104. if(APPLE_VIDEOTOOLBOX_LIBRARY)
  105. list(APPEND FFMPEG_LIBRARIES "${APPLE_VIDEOTOOLBOX_LIBRARY}")
  106. endif()
  107. find_library(APPLE_ICONV_LIBRARY iconv)
  108. if(APPLE_ICONV_LIBRARY)
  109. list(APPEND FFMPEG_LIBRARIES "${APPLE_ICONV_LIBRARY}")
  110. endif()
  111. find_library(APPLE_BZ2_LIBRARY bz2)
  112. if(APPLE_BZ2_LIBRARY)
  113. list(APPEND FFMPEG_LIBRARIES "${APPLE_BZ2_LIBRARY}")
  114. endif()
  115. mark_as_advanced(APPLE_AUDIOTOOLBOX_LIBRARY APPLE_COREMEDIA_LIBRARY
  116. APPLE_COREVIDEO_LIBRARY APPLE_SECURITY_LIBRARY APPLE_VDA_LIBRARY
  117. APPLE_VIDEOTOOLBOX_LIBRARY APPLE_ICONV_LIBRARY APPLE_BZ2_LIBRARY)
  118. endif()
  119. mark_as_advanced(FFMPEG_LIBRARY_DIR)
  120. include(FindPackageHandleStandardArgs)
  121. find_package_handle_standard_args(FFMPEG DEFAULT_MSG FFMPEG_LIBRARIES FFMPEG_LIBAVCODEC FFMPEG_LIBAVFORMAT FFMPEG_LIBAVUTIL FFMPEG_INCLUDE_DIR FFMPEG_LIBRARY_DIR)