cmake: Find prebuilt ffmpeg on Windows
This commit is contained in:
parent
6c197a8f6a
commit
e03690f1f0
|
@ -61,30 +61,66 @@ macro(check_libav)
|
|||
pkg_check_modules(LIBAV libavcodec>=54.35.0 libavformat>=54.20.4
|
||||
libswscale>=2.1.1 libavutil>=52.3.0)
|
||||
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)
|
||||
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()
|
||||
endif()
|
||||
if(LIBAV_FOUND)
|
||||
message(STATUS "libav/ffmpeg found, enabling AVI frame dumps")
|
||||
add_definitions(-DHAVE_LIBAV)
|
||||
include_directories(${LIBAV_INCLUDE_DIRS})
|
||||
if(LIBAV_INCLUDE_DIRS)
|
||||
include_directories(${LIBAV_INCLUDE_DIRS})
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "libav/ffmpeg not found, disabling AVI frame dumps")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
|
Loading…
Reference in New Issue