summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt112
-rw-r--r--src/video_core/CMakeLists.txt11
-rw-r--r--src/video_core/command_classes/codecs/codec.cpp2
3 files changed, 108 insertions, 17 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 27aa56780..aafe73c44 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,6 +18,8 @@ CMAKE_DEPENDENT_OPTION(YUZU_USE_BUNDLED_QT "Download bundled Qt binaries" ON "EN
18 18
19option(ENABLE_WEB_SERVICE "Enable web services (telemetry, etc.)" ON) 19option(ENABLE_WEB_SERVICE "Enable web services (telemetry, etc.)" ON)
20 20
21option(YUZU_USE_BUNDLED_FFMPEG "Download/Build bundled yuzu" ON)
22
21option(YUZU_USE_QT_WEB_ENGINE "Use QtWebEngine for web applet implementation" OFF) 23option(YUZU_USE_QT_WEB_ENGINE "Use QtWebEngine for web applet implementation" OFF)
22 24
23option(YUZU_ENABLE_BOXCAT "Enable the Boxcat service, a yuzu high-level implementation of BCAT" ON) 25option(YUZU_ENABLE_BOXCAT "Enable the Boxcat service, a yuzu high-level implementation of BCAT" ON)
@@ -384,17 +386,107 @@ if (NOT LIBUSB_FOUND)
384 set(LIBUSB_LIBRARIES usb) 386 set(LIBUSB_LIBRARIES usb)
385endif() 387endif()
386 388
387# Use system installed ffmpeg. 389if (YUZU_USE_BUNDLED_FFMPEG)
388if (NOT MSVC) 390 if (NOT WIN32)
389 find_package(FFmpeg REQUIRED) 391 # Build FFmpeg from externals
392 message(STATUS "Using FFmpeg from externals")
393
394 set(FFMPEG_PREFIX ${PROJECT_SOURCE_DIR}/externals/ffmpeg)
395 set(FFMPEG_BUILD_DIR ${PROJECT_BINARY_DIR}/externals/ffmpeg)
396 set(FFMPEG_MAKEFILE ${FFMPEG_BUILD_DIR}/Makefile)
397 make_directory(${FFMPEG_BUILD_DIR})
398
399 # Read version string from external
400 file(READ ${FFMPEG_PREFIX}/RELEASE FFMPEG_VERSION)
401 set(FFMPEG_FOUND NO)
402 if (NOT FFMPEG_VERSION STREQUAL "")
403 set(FFMPEG_FOUND YES)
404 endif()
405
406 set(FFMPEG_COMPONENTS
407 avcodec
408 avutil
409 swscale)
410
411 foreach(COMPONENT ${FFMPEG_COMPONENTS})
412 set(FFMPEG_${COMPONENT}_PREFIX "${FFMPEG_BUILD_DIR}/lib${COMPONENT}")
413 set(FFMPEG_${COMPONENT}_LIB_NAME "lib${COMPONENT}.a")
414 set(FFMPEG_${COMPONENT}_LIBRARY "${FFMPEG_${COMPONENT}_PREFIX}/${FFMPEG_${COMPONENT}_LIB_NAME}")
415
416 set(FFMPEG_LIBRARIES
417 ${FFMPEG_LIBRARIES}
418 ${FFMPEG_${COMPONENT}_LIBRARY}
419 CACHE PATH "Paths to FFmpeg libraries" FORCE)
420 endforeach()
421
422 set(FFMPEG_INCLUDE_DIR
423 ${FFMPEG_PREFIX}
424 CACHE PATH "Path to FFmpeg headers" FORCE)
425
426 # `configure` parameters builds only exactly what yuzu needs from FFmpeg
427 # `--disable-{vaapi,vdpau}` is needed to avoid linking issues
428 add_custom_command(
429 OUTPUT
430 ${FFMPEG_MAKEFILE}
431 COMMAND
432 /bin/bash ${FFMPEG_PREFIX}/configure
433 --disable-avdevice
434 --disable-avfilter
435 --disable-avformat
436 --disable-doc
437 --disable-everything
438 --disable-ffmpeg
439 --disable-ffprobe
440 --disable-network
441 --disable-postproc
442 --disable-swresample
443 --disable-vaapi
444 --disable-vdpau
445 --enable-decoder=h264
446 --enable-decoder=vp9
447 WORKING_DIRECTORY
448 ${FFMPEG_BUILD_DIR}
449 )
450
451 add_custom_command(
452 OUTPUT
453 ${FFMPEG_LIBRARIES}
454 COMMAND
455 make
456 WORKING_DIRECTORY
457 ${FFMPEG_BUILD_DIR}
458 )
459
460 # ALL makes this custom target build every time
461 # but it won't actually build if the DEPENDS parameter is up to date
462 add_custom_target(ffmpeg-build ALL DEPENDS ${FFMPEG_LIBRARIES})
463 add_custom_target(ffmpeg-configure ALL DEPENDS ${FFMPEG_MAKEFILE})
464
465 if (FFMPEG_FOUND)
466 message(STATUS "Found FFmpeg version ${FFMPEG_VERSION}")
467
468 add_dependencies(ffmpeg-build ffmpeg-configure)
469 else()
470 message(FATAL_ERROR "FFmpeg not found")
471 endif()
472 else() # WIN32
473 # Use yuzu FFmpeg binaries
474 set(FFMPEG_EXT_NAME "ffmpeg-4.2.1")
475 set(FFMPEG_PATH "${CMAKE_BINARY_DIR}/externals/${FFMPEG_EXT_NAME}")
476 download_bundled_external("ffmpeg/" ${FFMPEG_EXT_NAME} "")
477 set(FFMPEG_FOUND YES)
478 set(FFMPEG_INCLUDE_DIR "${FFMPEG_PATH}/include" CACHE PATH "Path to FFmpeg headers" FORCE)
479 set(FFMPEG_LIBRARY_DIR "${FFMPEG_PATH}/bin" CACHE PATH "Path to FFmpeg library directory" FORCE)
480 set(FFMPEG_DLL_DIR "${FFMPEG_PATH}/bin" CACHE PATH "Path to FFmpeg dll's" FORCE)
481 set(FFMPEG_LIBRARIES
482 ${FFMPEG_LIBRARY_DIR}/swscale.lib
483 ${FFMPEG_LIBRARY_DIR}/avcodec.lib
484 ${FFMPEG_LIBRARY_DIR}/avutil.lib
485 CACHE PATH "Paths to FFmpeg libraries" FORCE)
486 endif()
390else() 487else()
391 set(FFMPEG_EXT_NAME "ffmpeg-4.2.1") 488 # Use system installed FFmpeg
392 set(FFMPEG_PATH "${CMAKE_BINARY_DIR}/externals/${FFMPEG_EXT_NAME}") 489 find_package(FFmpeg REQUIRED VERSION 4.0)
393 download_bundled_external("ffmpeg/" ${FFMPEG_EXT_NAME} "")
394 set(FFMPEG_FOUND YES)
395 set(FFMPEG_INCLUDE_DIR "${FFMPEG_PATH}/include" CACHE PATH "Path to FFmpeg headers" FORCE)
396 set(FFMPEG_LIBRARY_DIR "${FFMPEG_PATH}/bin" CACHE PATH "Path to FFmpeg library" FORCE)
397 set(FFMPEG_DLL_DIR "${FFMPEG_PATH}/bin" CACHE PATH "Path to FFmpeg dll's" FORCE)
398endif() 490endif()
399 491
400# Prefer the -pthread flag on Linux. 492# Prefer the -pthread flag on Linux.
diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt
index bb1f8491f..01e284d8c 100644
--- a/src/video_core/CMakeLists.txt
+++ b/src/video_core/CMakeLists.txt
@@ -273,14 +273,13 @@ create_target_directory_groups(video_core)
273target_link_libraries(video_core PUBLIC common core) 273target_link_libraries(video_core PUBLIC common core)
274target_link_libraries(video_core PRIVATE glad xbyak) 274target_link_libraries(video_core PRIVATE glad xbyak)
275 275
276if (MSVC) 276if (YUZU_USE_BUNDLED_FFMPEG AND NOT WIN32)
277 target_include_directories(video_core PRIVATE ${FFMPEG_INCLUDE_DIR}) 277 add_dependencies(video_core ffmpeg-build)
278 target_link_libraries(video_core PUBLIC ${FFMPEG_LIBRARY_DIR}/swscale.lib ${FFMPEG_LIBRARY_DIR}/avcodec.lib ${FFMPEG_LIBRARY_DIR}/avutil.lib)
279else()
280 target_include_directories(video_core PRIVATE ${FFMPEG_INCLUDE_DIR})
281 target_link_libraries(video_core PRIVATE ${FFMPEG_LIBRARIES})
282endif() 278endif()
283 279
280target_include_directories(video_core PRIVATE ${FFMPEG_INCLUDE_DIR})
281target_link_libraries(video_core PRIVATE ${FFMPEG_LIBRARIES})
282
284add_dependencies(video_core host_shaders) 283add_dependencies(video_core host_shaders)
285target_include_directories(video_core PRIVATE ${HOST_SHADERS_INCLUDE}) 284target_include_directories(video_core PRIVATE ${HOST_SHADERS_INCLUDE})
286target_include_directories(video_core PRIVATE sirit ../../externals/Vulkan-Headers/include) 285target_include_directories(video_core PRIVATE sirit ../../externals/Vulkan-Headers/include)
diff --git a/src/video_core/command_classes/codecs/codec.cpp b/src/video_core/command_classes/codecs/codec.cpp
index 39bc923a5..c25d2ad2c 100644
--- a/src/video_core/command_classes/codecs/codec.cpp
+++ b/src/video_core/command_classes/codecs/codec.cpp
@@ -13,7 +13,7 @@
13#include "video_core/memory_manager.h" 13#include "video_core/memory_manager.h"
14 14
15extern "C" { 15extern "C" {
16#include <libavutil/opt.h> 16#include "libavutil/opt.h"
17} 17}
18 18
19namespace Tegra { 19namespace Tegra {