2017-01-17 20:32:55 +00:00
|
|
|
find_package(PkgConfig)
|
2010-12-10 02:00:05 +00:00
|
|
|
|
2010-12-13 05:29:13 +00:00
|
|
|
macro(_internal_message msg)
|
|
|
|
if(NOT ${_is_quiet})
|
2017-01-17 20:47:24 +00:00
|
|
|
message(STATUS "${msg}")
|
2010-12-10 02:00:05 +00:00
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2015-06-02 22:00:50 +00:00
|
|
|
macro(check_lib var pc lib)
|
2010-12-10 02:00:05 +00:00
|
|
|
set(_is_required 0)
|
|
|
|
set(_is_quiet 0)
|
2010-12-13 05:29:13 +00:00
|
|
|
set(_arg_list ${ARGN})
|
2010-12-10 02:00:05 +00:00
|
|
|
foreach(_arg ${ARGN})
|
|
|
|
if(_arg STREQUAL "REQUIRED")
|
2010-12-13 05:29:13 +00:00
|
|
|
list(REMOVE_ITEM _arg_list "REQUIRED")
|
2010-12-10 02:00:05 +00:00
|
|
|
set(_is_required 1)
|
|
|
|
endif()
|
|
|
|
if(_arg STREQUAL "QUIET")
|
2010-12-13 05:29:13 +00:00
|
|
|
list(REMOVE_ITEM _arg_list "QUIET")
|
2010-12-10 02:00:05 +00:00
|
|
|
set(_is_quiet 1)
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
if(PKG_CONFIG_FOUND AND NOT ${var}_FOUND)
|
2015-06-02 22:00:50 +00:00
|
|
|
pkg_search_module(${var} QUIET ${pc})
|
2010-12-10 02:00:05 +00:00
|
|
|
endif()
|
|
|
|
|
2010-11-12 05:05:27 +00:00
|
|
|
if(${var}_FOUND)
|
2017-01-17 16:47:19 +00:00
|
|
|
if(${var}_INCLUDE_DIRS)
|
|
|
|
include_directories(${${var}_INCLUDE_DIRS})
|
|
|
|
endif()
|
2010-12-13 05:29:13 +00:00
|
|
|
# Make sure include directories for headers found using find_path below
|
|
|
|
# are re-added when reconfiguring
|
2017-01-17 16:47:19 +00:00
|
|
|
if(${var}_INCLUDE)
|
|
|
|
include_directories(${${var}_INCLUDE})
|
|
|
|
endif()
|
2010-12-13 05:29:13 +00:00
|
|
|
_internal_message("${lib} found")
|
2010-11-12 05:05:27 +00:00
|
|
|
else()
|
|
|
|
find_library(${var} ${lib})
|
2010-12-14 23:19:34 +00:00
|
|
|
if(_arg_list)
|
|
|
|
find_path(${var}_INCLUDE ${_arg_list})
|
|
|
|
else()
|
|
|
|
set(${var}_INCLUDE FALSE)
|
|
|
|
endif()
|
2010-12-10 02:00:05 +00:00
|
|
|
if(${var} AND ${var}_INCLUDE)
|
2010-12-13 05:29:13 +00:00
|
|
|
include_directories(${${var}_INCLUDE})
|
|
|
|
_internal_message("${lib} found")
|
2010-11-12 05:05:27 +00:00
|
|
|
set(${var}_FOUND 1 CACHE INTERNAL "")
|
|
|
|
else()
|
2010-12-10 02:00:05 +00:00
|
|
|
if(_is_required)
|
2010-11-12 05:05:27 +00:00
|
|
|
message(FATAL_ERROR "${lib} is required but not found")
|
|
|
|
else()
|
2010-12-13 05:29:13 +00:00
|
|
|
_internal_message("${lib} not found")
|
2010-11-12 05:05:27 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2010-12-10 02:00:05 +00:00
|
|
|
macro(check_libav)
|
|
|
|
if(PKG_CONFIG_FOUND)
|
2014-07-13 21:06:20 +00:00
|
|
|
pkg_check_modules(LIBAV libavcodec>=54.35.0 libavformat>=54.20.4
|
|
|
|
libswscale>=2.1.1 libavutil>=52.3.0)
|
2010-11-18 23:27:27 +00:00
|
|
|
else()
|
2017-01-21 01:36:06 +00:00
|
|
|
if(WIN32)
|
|
|
|
add_library(avcodec STATIC IMPORTED)
|
|
|
|
set_target_properties(avcodec PROPERTIES
|
|
|
|
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/Externals/ffmpeg/include
|
|
|
|
IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/Externals/ffmpeg/lib/avcodec.lib
|
|
|
|
)
|
|
|
|
|
|
|
|
add_library(avformat STATIC IMPORTED)
|
|
|
|
set_target_properties(avformat PROPERTIES
|
|
|
|
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/Externals/ffmpeg/include
|
|
|
|
IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/Externals/ffmpeg/lib/avformat.lib
|
|
|
|
)
|
|
|
|
|
|
|
|
add_library(avutil STATIC IMPORTED)
|
|
|
|
set_target_properties(avutil PROPERTIES
|
|
|
|
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/Externals/ffmpeg/include
|
|
|
|
IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/Externals/ffmpeg/lib/avutil.lib
|
|
|
|
)
|
|
|
|
|
|
|
|
add_library(swresample STATIC IMPORTED)
|
|
|
|
set_target_properties(swresample PROPERTIES
|
|
|
|
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/Externals/ffmpeg/include
|
|
|
|
IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/Externals/ffmpeg/lib/swresample.lib
|
|
|
|
)
|
|
|
|
|
|
|
|
add_library(swscale STATIC IMPORTED)
|
|
|
|
set_target_properties(swscale PROPERTIES
|
|
|
|
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/Externals/ffmpeg/include
|
|
|
|
IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/Externals/ffmpeg/lib/swscale.lib
|
|
|
|
)
|
|
|
|
|
|
|
|
set(LIBAV_FOUND ON)
|
|
|
|
set(LIBAV_LIBRARIES avcodec avformat avutil swresample swscale)
|
|
|
|
else()
|
|
|
|
# Attempt to find it through static means
|
|
|
|
set(LIBAV_LDFLAGS avformat avcodec swscale avutil)
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES ${LIBAV_LDFLAGS})
|
|
|
|
CHECK_CXX_SOURCE_COMPILES(
|
|
|
|
"extern \"C\" {
|
|
|
|
#include <libavcodec/avcodec.h>
|
|
|
|
#include <libavformat/avformat.h>
|
|
|
|
#include <libavutil/mathematics.h>
|
|
|
|
#include <libswscale/swscale.h>
|
|
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
av_register_all();
|
|
|
|
return 0;
|
|
|
|
}"
|
|
|
|
LIBAV_FOUND)
|
|
|
|
unset(CMAKE_REQUIRED_LIBRARIES)
|
|
|
|
endif()
|
2010-12-10 02:00:05 +00:00
|
|
|
endif()
|
|
|
|
if(LIBAV_FOUND)
|
2017-01-17 20:47:24 +00:00
|
|
|
message(STATUS "libav/ffmpeg found, enabling AVI frame dumps")
|
2010-12-10 02:00:05 +00:00
|
|
|
add_definitions(-DHAVE_LIBAV)
|
2017-01-21 01:36:06 +00:00
|
|
|
if(LIBAV_INCLUDE_DIRS)
|
|
|
|
include_directories(${LIBAV_INCLUDE_DIRS})
|
|
|
|
endif()
|
2010-12-10 02:00:05 +00:00
|
|
|
else()
|
2017-01-17 20:47:24 +00:00
|
|
|
message(STATUS "libav/ffmpeg not found, disabling AVI frame dumps")
|
2010-11-18 23:27:27 +00:00
|
|
|
endif()
|
|
|
|
endmacro()
|