obs-studio/cmake/Modules/FindLibavcodec.cmake
jp9000 5fb149a48c Add more search directories for cmake modules
I actually did this because it makes it a bit easier to use with a
build from cross-compiled windows FFMpeg/x264 DLLs.  When compiling on
linux I just have it compile to a custom prefix directory for the
specific windows arch, then I just copy the arch dir back to my windows
HD when complete.  Adding this to the cmake allows me to use the compile
arch directories directly without modification.
2014-09-23 04:56:32 -07:00

60 lines
1.5 KiB
CMake

# Once done these will be defined:
#
# LIBAVCODEC_FOUND
# LIBAVCODEC_INCLUDE_DIRS
# LIBAVCODEC_LIBRARIES
#
# For use in OBS:
#
# FFMPEG_INCLUDE_DIR
find_package(PkgConfig QUIET)
if (PKG_CONFIG_FOUND)
pkg_check_modules(_AVCODEC QUIET libavcodec)
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(_lib_suffix 64)
else()
set(_lib_suffix 32)
endif()
set(FFMPEG_PATH_ARCH FFmpegPath${_lib_suffix})
find_path(FFMPEG_INCLUDE_DIR
NAMES libavcodec/avcodec.h
HINTS
${_AVCODEC_INCLUDE_DIRS}
"${CMAKE_SOURCE_DIR}/additional_install_files/include"
"$ENV{obsAdditionalInstallFiles}/include"
ENV FFmpegPath
ENV ${FFMPEG_PATH_ARCH}
PATHS
/usr/include /usr/local/include /opt/local/include /sw/include
PATH_SUFFIXES ffmpeg libav)
find_library(AVCODEC_LIB
NAMES ${_AVCODEC_LIBRARIES} avcodec-ffmpeg avcodec
HINTS
${_AVCODEC_LIBRARY_DIRS}
"${FFMPEG_INCLUDE_DIR}/../lib"
"${FFMPEG_INCLUDE_DIR}/../lib${_lib_suffix}"
"${FFMPEG_INCLUDE_DIR}/../libs${_lib_suffix}"
"${FFMPEG_INCLUDE_DIR}/lib"
"${FFMPEG_INCLUDE_DIR}/lib${_lib_suffix}"
"${FFMPEG_INCLUDE_DIR}/bin"
"${FFMPEG_INCLUDE_DIR}/bin${_lib_suffix}"
"${FFMPEG_INCLUDE_DIR}/../bin"
"${FFMPEG_INCLUDE_DIR}/../bin${_lib_suffix}"
PATHS
/usr/lib /usr/local/lib /opt/local/lib /sw/lib)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Libavcodec DEFAULT_MSG AVCODEC_LIB FFMPEG_INCLUDE_DIR)
mark_as_advanced(FFMPEG_INCLUDE_DIR AVCODEC_LIB)
if(LIBAVCODEC_FOUND)
set(LIBAVCODEC_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIR})
set(LIBAVCODEC_LIBRARIES ${AVCODEC_LIB})
endif()