cmake: Find prebuilt ffmpeg on Windows

This commit is contained in:
Florent Castelli 2017-01-21 02:36:06 +01:00
parent 6c197a8f6a
commit e03690f1f0
1 changed files with 55 additions and 19 deletions

View File

@ -60,6 +60,40 @@ macro(check_libav)
if(PKG_CONFIG_FOUND)
pkg_check_modules(LIBAV libavcodec>=54.35.0 libavformat>=54.20.4
libswscale>=2.1.1 libavutil>=52.3.0)
else()
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)
@ -79,12 +113,14 @@ macro(check_libav)
LIBAV_FOUND)
unset(CMAKE_REQUIRED_LIBRARIES)
endif()
endif()
if(LIBAV_FOUND)
message(STATUS "libav/ffmpeg found, enabling AVI frame dumps")
add_definitions(-DHAVE_LIBAV)
if(LIBAV_INCLUDE_DIRS)
include_directories(${LIBAV_INCLUDE_DIRS})
endif()
else()
message(STATUS "libav/ffmpeg not found, disabling AVI frame dumps")
endif()
endmacro()