diff options
Diffstat (limited to 'CMakeLists.txt')
| -rw-r--r-- | CMakeLists.txt | 224 |
1 files changed, 5 insertions, 219 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a7b1d85a..707d514c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
| @@ -231,7 +231,7 @@ elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR YUZU_USE_BUNDLED_BOOST) | |||
| 231 | include_directories(SYSTEM "${Boost_INCLUDE_DIRS}") | 231 | include_directories(SYSTEM "${Boost_INCLUDE_DIRS}") |
| 232 | else() | 232 | else() |
| 233 | message(STATUS "Boost 1.73.0 or newer not found, falling back to Conan") | 233 | message(STATUS "Boost 1.73.0 or newer not found, falling back to Conan") |
| 234 | list(APPEND CONAN_REQUIRED_LIBS "boost/1.73.0") | 234 | list(APPEND CONAN_REQUIRED_LIBS "boost/1.78.0") |
| 235 | endif() | 235 | endif() |
| 236 | 236 | ||
| 237 | # Attempt to locate any packages that are required and report the missing ones in CONAN_REQUIRED_LIBS | 237 | # Attempt to locate any packages that are required and report the missing ones in CONAN_REQUIRED_LIBS |
| @@ -251,7 +251,7 @@ if(ENABLE_QT) | |||
| 251 | # Check for system Qt on Linux, fallback to bundled Qt | 251 | # Check for system Qt on Linux, fallback to bundled Qt |
| 252 | if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") | 252 | if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") |
| 253 | if (NOT YUZU_USE_BUNDLED_QT) | 253 | if (NOT YUZU_USE_BUNDLED_QT) |
| 254 | find_package(Qt5 ${QT_VERSION} COMPONENTS Widgets) | 254 | find_package(Qt5 ${QT_VERSION} COMPONENTS Widgets DBus) |
| 255 | endif() | 255 | endif() |
| 256 | if (NOT Qt5_FOUND OR YUZU_USE_BUNDLED_QT) | 256 | if (NOT Qt5_FOUND OR YUZU_USE_BUNDLED_QT) |
| 257 | # Check for dependencies, then enable bundled Qt download | 257 | # Check for dependencies, then enable bundled Qt download |
| @@ -510,13 +510,13 @@ set(FFmpeg_COMPONENTS | |||
| 510 | avutil | 510 | avutil |
| 511 | swscale) | 511 | swscale) |
| 512 | 512 | ||
| 513 | if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") | 513 | if (UNIX AND NOT APPLE) |
| 514 | Include(FindPkgConfig REQUIRED) | 514 | Include(FindPkgConfig REQUIRED) |
| 515 | pkg_check_modules(LIBVA libva) | 515 | pkg_check_modules(LIBVA libva) |
| 516 | endif() | 516 | endif() |
| 517 | if (NOT YUZU_USE_BUNDLED_FFMPEG) | 517 | if (NOT YUZU_USE_BUNDLED_FFMPEG) |
| 518 | # Use system installed FFmpeg | 518 | # Use system installed FFmpeg |
| 519 | find_package(FFmpeg QUIET COMPONENTS ${FFmpeg_COMPONENTS}) | 519 | find_package(FFmpeg 4.3 QUIET COMPONENTS ${FFmpeg_COMPONENTS}) |
| 520 | 520 | ||
| 521 | if (FFmpeg_FOUND) | 521 | if (FFmpeg_FOUND) |
| 522 | # Overwrite aggregate defines from FFmpeg module to avoid over-linking libraries. | 522 | # Overwrite aggregate defines from FFmpeg module to avoid over-linking libraries. |
| @@ -529,225 +529,11 @@ if (NOT YUZU_USE_BUNDLED_FFMPEG) | |||
| 529 | set(FFmpeg_INCLUDE_DIR ${FFmpeg_INCLUDE_DIR} ${FFmpeg_INCLUDE_${COMPONENT}} CACHE PATH "Path to FFmpeg headers" FORCE) | 529 | set(FFmpeg_INCLUDE_DIR ${FFmpeg_INCLUDE_DIR} ${FFmpeg_INCLUDE_${COMPONENT}} CACHE PATH "Path to FFmpeg headers" FORCE) |
| 530 | endforeach() | 530 | endforeach() |
| 531 | else() | 531 | else() |
| 532 | message(WARNING "FFmpeg not found, falling back to externals") | 532 | message(WARNING "FFmpeg not found or too old, falling back to externals") |
| 533 | set(YUZU_USE_BUNDLED_FFMPEG ON) | 533 | set(YUZU_USE_BUNDLED_FFMPEG ON) |
| 534 | endif() | 534 | endif() |
| 535 | endif() | 535 | endif() |
| 536 | 536 | ||
| 537 | if (YUZU_USE_BUNDLED_FFMPEG) | ||
| 538 | if (NOT WIN32) | ||
| 539 | # TODO(lat9nq): Move this to externals/ffmpeg/CMakeLists.txt (and move externals/ffmpeg to | ||
| 540 | # externals/ffmpeg/ffmpeg) | ||
| 541 | |||
| 542 | # Build FFmpeg from externals | ||
| 543 | message(STATUS "Using FFmpeg from externals") | ||
| 544 | |||
| 545 | # FFmpeg has source that requires one of nasm or yasm to assemble it. | ||
| 546 | # REQUIRED throws an error if not found here during configuration rather than during compilation. | ||
| 547 | find_program(ASSEMBLER NAMES nasm yasm) | ||
| 548 | if ("${ASSEMBLER}" STREQUAL "ASSEMBLER-NOTFOUND") | ||
| 549 | message(FATAL_ERROR "One of either `nasm` or `yasm` not found but is required.") | ||
| 550 | endif() | ||
| 551 | |||
| 552 | find_program(AUTOCONF autoconf) | ||
| 553 | if ("${AUTOCONF}" STREQUAL "AUTOCONF-NOTFOUND") | ||
| 554 | message(FATAL_ERROR "Required program `autoconf` not found.") | ||
| 555 | endif() | ||
| 556 | |||
| 557 | set(FFmpeg_PREFIX ${PROJECT_SOURCE_DIR}/externals/ffmpeg) | ||
| 558 | set(FFmpeg_BUILD_DIR ${PROJECT_BINARY_DIR}/externals/ffmpeg) | ||
| 559 | set(FFmpeg_MAKEFILE ${FFmpeg_BUILD_DIR}/Makefile) | ||
| 560 | make_directory(${FFmpeg_BUILD_DIR}) | ||
| 561 | |||
| 562 | # Read version string from external | ||
| 563 | file(READ ${FFmpeg_PREFIX}/RELEASE FFmpeg_VERSION) | ||
| 564 | set(FFmpeg_FOUND NO) | ||
| 565 | if (NOT FFmpeg_VERSION STREQUAL "") | ||
| 566 | set(FFmpeg_FOUND YES) | ||
| 567 | endif() | ||
| 568 | |||
| 569 | unset(FFmpeg_LIBRARIES CACHE) | ||
| 570 | foreach(COMPONENT ${FFmpeg_COMPONENTS}) | ||
| 571 | set(FFmpeg_${COMPONENT}_PREFIX "${FFmpeg_BUILD_DIR}/lib${COMPONENT}") | ||
| 572 | set(FFmpeg_${COMPONENT}_LIB_NAME "lib${COMPONENT}.a") | ||
| 573 | set(FFmpeg_${COMPONENT}_LIBRARY "${FFmpeg_${COMPONENT}_PREFIX}/${FFmpeg_${COMPONENT}_LIB_NAME}") | ||
| 574 | |||
| 575 | set(FFmpeg_LIBRARIES | ||
| 576 | ${FFmpeg_LIBRARIES} | ||
| 577 | ${FFmpeg_${COMPONENT}_LIBRARY} | ||
| 578 | CACHE PATH "Paths to FFmpeg libraries" FORCE) | ||
| 579 | endforeach() | ||
| 580 | |||
| 581 | Include(FindPkgConfig REQUIRED) | ||
| 582 | pkg_check_modules(LIBVA libva) | ||
| 583 | pkg_check_modules(CUDA cuda) | ||
| 584 | pkg_check_modules(FFNVCODEC ffnvcodec) | ||
| 585 | pkg_check_modules(VDPAU vdpau) | ||
| 586 | |||
| 587 | set(FFmpeg_HWACCEL_LIBRARIES) | ||
| 588 | set(FFmpeg_HWACCEL_FLAGS) | ||
| 589 | set(FFmpeg_HWACCEL_INCLUDE_DIRS) | ||
| 590 | set(FFmpeg_HWACCEL_LDFLAGS) | ||
| 591 | |||
| 592 | if(LIBVA_FOUND) | ||
| 593 | pkg_check_modules(LIBDRM libdrm REQUIRED) | ||
| 594 | find_package(X11 REQUIRED) | ||
| 595 | pkg_check_modules(LIBVA-DRM libva-drm REQUIRED) | ||
| 596 | pkg_check_modules(LIBVA-X11 libva-x11 REQUIRED) | ||
| 597 | list(APPEND FFmpeg_HWACCEL_LIBRARIES | ||
| 598 | ${LIBDRM_LIBRARIES} | ||
| 599 | ${X11_LIBRARIES} | ||
| 600 | ${LIBVA-DRM_LIBRARIES} | ||
| 601 | ${LIBVA-X11_LIBRARIES} | ||
| 602 | ${LIBVA_LIBRARIES}) | ||
| 603 | set(FFmpeg_HWACCEL_FLAGS | ||
| 604 | --enable-hwaccel=h264_vaapi | ||
| 605 | --enable-hwaccel=vp8_vaapi | ||
| 606 | --enable-hwaccel=vp9_vaapi | ||
| 607 | --enable-libdrm) | ||
| 608 | list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS | ||
| 609 | ${LIBDRM_INCLUDE_DIRS} | ||
| 610 | ${X11_INCLUDE_DIRS} | ||
| 611 | ${LIBVA-DRM_INCLUDE_DIRS} | ||
| 612 | ${LIBVA-X11_INCLUDE_DIRS} | ||
| 613 | ${LIBVA_INCLUDE_DIRS} | ||
| 614 | ) | ||
| 615 | message(STATUS "VA-API found") | ||
| 616 | else() | ||
| 617 | set(FFmpeg_HWACCEL_FLAGS --disable-vaapi) | ||
| 618 | endif() | ||
| 619 | |||
| 620 | if (FFNVCODEC_FOUND AND CUDA_FOUND) | ||
| 621 | list(APPEND FFmpeg_HWACCEL_FLAGS | ||
| 622 | --enable-cuvid | ||
| 623 | --enable-ffnvcodec | ||
| 624 | --enable-nvdec | ||
| 625 | --enable-hwaccel=h264_nvdec | ||
| 626 | --enable-hwaccel=vp8_nvdec | ||
| 627 | --enable-hwaccel=vp9_nvdec | ||
| 628 | --extra-cflags=-I${CUDA_INCLUDE_DIRS} | ||
| 629 | ) | ||
| 630 | list(APPEND FFmpeg_HWACCEL_LIBRARIES | ||
| 631 | ${FFNVCODEC_LIBRARIES} | ||
| 632 | ${CUDA_LIBRARIES} | ||
| 633 | ) | ||
| 634 | list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS | ||
| 635 | ${FFNVCODEC_INCLUDE_DIRS} | ||
| 636 | ${CUDA_INCLUDE_DIRS} | ||
| 637 | ) | ||
| 638 | list(APPEND FFmpeg_HWACCEL_LDFLAGS | ||
| 639 | ${FFNVCODEC_LDFLAGS} | ||
| 640 | ${CUDA_LDFLAGS} | ||
| 641 | ) | ||
| 642 | message(STATUS "ffnvcodec libraries version ${FFNVCODEC_VERSION} found") | ||
| 643 | endif() | ||
| 644 | |||
| 645 | if (VDPAU_FOUND) | ||
| 646 | list(APPEND FFmpeg_HWACCEL_FLAGS | ||
| 647 | --enable-vdpau | ||
| 648 | --enable-hwaccel=h264_vdpau | ||
| 649 | --enable-hwaccel=vp9_vdpau | ||
| 650 | ) | ||
| 651 | list(APPEND FFmpeg_HWACCEL_LIBRARIES ${VDPAU_LIBRARIES}) | ||
| 652 | list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS ${VDPAU_INCLUDE_DIRS}) | ||
| 653 | list(APPEND FFmpeg_HWACCEL_LDFLAGS ${VDPAU_LDFLAGS}) | ||
| 654 | message(STATUS "vdpau libraries version ${VDPAU_VERSION} found") | ||
| 655 | else() | ||
| 656 | list(APPEND FFmpeg_HWACCEL_FLAGS --disable-vdpau) | ||
| 657 | endif() | ||
| 658 | |||
| 659 | # `configure` parameters builds only exactly what yuzu needs from FFmpeg | ||
| 660 | # `--disable-vdpau` is needed to avoid linking issues | ||
| 661 | add_custom_command( | ||
| 662 | OUTPUT | ||
| 663 | ${FFmpeg_MAKEFILE} | ||
| 664 | COMMAND | ||
| 665 | /bin/bash ${FFmpeg_PREFIX}/configure | ||
| 666 | --disable-avdevice | ||
| 667 | --disable-avfilter | ||
| 668 | --disable-avformat | ||
| 669 | --disable-doc | ||
| 670 | --disable-everything | ||
| 671 | --disable-ffmpeg | ||
| 672 | --disable-ffprobe | ||
| 673 | --disable-network | ||
| 674 | --disable-postproc | ||
| 675 | --disable-swresample | ||
| 676 | --enable-decoder=h264 | ||
| 677 | --enable-decoder=vp8 | ||
| 678 | --enable-decoder=vp9 | ||
| 679 | --cc="${CMAKE_C_COMPILER}" | ||
| 680 | --cxx="${CMAKE_CXX_COMPILER}" | ||
| 681 | ${FFmpeg_HWACCEL_FLAGS} | ||
| 682 | WORKING_DIRECTORY | ||
| 683 | ${FFmpeg_BUILD_DIR} | ||
| 684 | ) | ||
| 685 | unset(FFmpeg_HWACCEL_FLAGS) | ||
| 686 | |||
| 687 | # Workaround for Ubuntu 18.04's older version of make not being able to call make as a child | ||
| 688 | # with context of the jobserver. Also helps ninja users. | ||
| 689 | execute_process( | ||
| 690 | COMMAND | ||
| 691 | nproc | ||
| 692 | OUTPUT_VARIABLE | ||
| 693 | SYSTEM_THREADS) | ||
| 694 | |||
| 695 | set(FFmpeg_BUILD_LIBRARIES ${FFmpeg_LIBRARIES}) | ||
| 696 | add_custom_command( | ||
| 697 | OUTPUT | ||
| 698 | ${FFmpeg_BUILD_LIBRARIES} | ||
| 699 | COMMAND | ||
| 700 | make -j${SYSTEM_THREADS} | ||
| 701 | WORKING_DIRECTORY | ||
| 702 | ${FFmpeg_BUILD_DIR} | ||
| 703 | ) | ||
| 704 | |||
| 705 | set(FFmpeg_INCLUDE_DIR | ||
| 706 | "${FFmpeg_PREFIX};${FFmpeg_BUILD_DIR};${FFmpeg_HWACCEL_INCLUDE_DIRS}" | ||
| 707 | CACHE PATH "Path to FFmpeg headers" FORCE) | ||
| 708 | |||
| 709 | set(FFmpeg_LDFLAGS | ||
| 710 | "${FFmpeg_HWACCEL_LDFLAGS}" | ||
| 711 | CACHE STRING "FFmpeg linker flags" FORCE) | ||
| 712 | |||
| 713 | # ALL makes this custom target build every time | ||
| 714 | # but it won't actually build if the DEPENDS parameter is up to date | ||
| 715 | add_custom_target(ffmpeg-configure ALL DEPENDS ${FFmpeg_MAKEFILE}) | ||
| 716 | add_custom_target(ffmpeg-build ALL DEPENDS ${FFmpeg_BUILD_LIBRARIES} ffmpeg-configure) | ||
| 717 | link_libraries(${FFmpeg_LIBVA_LIBRARIES}) | ||
| 718 | set(FFmpeg_LIBRARIES ${FFmpeg_BUILD_LIBRARIES} ${FFmpeg_HWACCEL_LIBRARIES} | ||
| 719 | CACHE PATH "Paths to FFmpeg libraries" FORCE) | ||
| 720 | unset(FFmpeg_BUILD_LIBRARIES) | ||
| 721 | unset(FFmpeg_HWACCEL_FLAGS) | ||
| 722 | unset(FFmpeg_HWACCEL_INCLUDE_DIRS) | ||
| 723 | unset(FFmpeg_HWACCEL_LDFLAGS) | ||
| 724 | unset(FFmpeg_HWACCEL_LIBRARIES) | ||
| 725 | |||
| 726 | if (FFmpeg_FOUND) | ||
| 727 | message(STATUS "Found FFmpeg version ${FFmpeg_VERSION}") | ||
| 728 | else() | ||
| 729 | message(FATAL_ERROR "FFmpeg not found") | ||
| 730 | endif() | ||
| 731 | else() # WIN32 | ||
| 732 | # Use yuzu FFmpeg binaries | ||
| 733 | set(FFmpeg_EXT_NAME "ffmpeg-4.4") | ||
| 734 | set(FFmpeg_PATH "${CMAKE_BINARY_DIR}/externals/${FFmpeg_EXT_NAME}") | ||
| 735 | download_bundled_external("ffmpeg/" ${FFmpeg_EXT_NAME} "") | ||
| 736 | set(FFmpeg_FOUND YES) | ||
| 737 | set(FFmpeg_INCLUDE_DIR "${FFmpeg_PATH}/include" CACHE PATH "Path to FFmpeg headers" FORCE) | ||
| 738 | set(FFmpeg_LIBRARY_DIR "${FFmpeg_PATH}/bin" CACHE PATH "Path to FFmpeg library directory" FORCE) | ||
| 739 | set(FFmpeg_LDFLAGS "" CACHE STRING "FFmpeg linker flags" FORCE) | ||
| 740 | set(FFmpeg_DLL_DIR "${FFmpeg_PATH}/bin" CACHE PATH "Path to FFmpeg dll's" FORCE) | ||
| 741 | set(FFmpeg_LIBRARIES | ||
| 742 | ${FFmpeg_LIBRARY_DIR}/swscale.lib | ||
| 743 | ${FFmpeg_LIBRARY_DIR}/avcodec.lib | ||
| 744 | ${FFmpeg_LIBRARY_DIR}/avutil.lib | ||
| 745 | CACHE PATH "Paths to FFmpeg libraries" FORCE) | ||
| 746 | endif() | ||
| 747 | endif() | ||
| 748 | |||
| 749 | unset(FFmpeg_COMPONENTS) | ||
| 750 | |||
| 751 | # Prefer the -pthread flag on Linux. | 537 | # Prefer the -pthread flag on Linux. |
| 752 | set(THREADS_PREFER_PTHREAD_FLAG ON) | 538 | set(THREADS_PREFER_PTHREAD_FLAG ON) |
| 753 | find_package(Threads REQUIRED) | 539 | find_package(Threads REQUIRED) |