diff options
| author | 2021-12-10 21:04:18 -0700 | |
|---|---|---|
| committer | 2021-12-13 17:48:05 -0700 | |
| commit | ccc0a1e621b32827dc6ebf9c0b54a58778cbab52 (patch) | |
| tree | 3ccf518ad24765cb2d9a0e81629883e528971510 | |
| parent | Merge pull request #7576 from lioncash/tasenum (diff) | |
| download | yuzu-ccc0a1e621b32827dc6ebf9c0b54a58778cbab52.tar.gz yuzu-ccc0a1e621b32827dc6ebf9c0b54a58778cbab52.tar.xz yuzu-ccc0a1e621b32827dc6ebf9c0b54a58778cbab52.zip | |
cmake: refactor ffmpeg searching and handling logic on Linux
| -rw-r--r-- | CMakeLists.txt | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index a810e11c2..34ba67993 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
| @@ -514,7 +514,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") | |||
| 514 | endif() | 514 | endif() |
| 515 | if (NOT YUZU_USE_BUNDLED_FFMPEG) | 515 | if (NOT YUZU_USE_BUNDLED_FFMPEG) |
| 516 | # Use system installed FFmpeg | 516 | # Use system installed FFmpeg |
| 517 | find_package(FFmpeg QUIET COMPONENTS ${FFmpeg_COMPONENTS}) | 517 | find_package(FFmpeg 4.3 QUIET COMPONENTS ${FFmpeg_COMPONENTS}) |
| 518 | 518 | ||
| 519 | if (FFmpeg_FOUND) | 519 | if (FFmpeg_FOUND) |
| 520 | # Overwrite aggregate defines from FFmpeg module to avoid over-linking libraries. | 520 | # Overwrite aggregate defines from FFmpeg module to avoid over-linking libraries. |
| @@ -527,7 +527,7 @@ if (NOT YUZU_USE_BUNDLED_FFMPEG) | |||
| 527 | set(FFmpeg_INCLUDE_DIR ${FFmpeg_INCLUDE_DIR} ${FFmpeg_INCLUDE_${COMPONENT}} CACHE PATH "Path to FFmpeg headers" FORCE) | 527 | set(FFmpeg_INCLUDE_DIR ${FFmpeg_INCLUDE_DIR} ${FFmpeg_INCLUDE_${COMPONENT}} CACHE PATH "Path to FFmpeg headers" FORCE) |
| 528 | endforeach() | 528 | endforeach() |
| 529 | else() | 529 | else() |
| 530 | message(WARNING "FFmpeg not found, falling back to externals") | 530 | message(WARNING "FFmpeg not found or too old, falling back to externals") |
| 531 | set(YUZU_USE_BUNDLED_FFMPEG ON) | 531 | set(YUZU_USE_BUNDLED_FFMPEG ON) |
| 532 | endif() | 532 | endif() |
| 533 | endif() | 533 | endif() |
| @@ -615,7 +615,7 @@ if (YUZU_USE_BUNDLED_FFMPEG) | |||
| 615 | set(FFmpeg_HWACCEL_FLAGS --disable-vaapi) | 615 | set(FFmpeg_HWACCEL_FLAGS --disable-vaapi) |
| 616 | endif() | 616 | endif() |
| 617 | 617 | ||
| 618 | if (FFNVCODEC_FOUND AND CUDA_FOUND) | 618 | if (FFNVCODEC_FOUND) |
| 619 | list(APPEND FFmpeg_HWACCEL_FLAGS | 619 | list(APPEND FFmpeg_HWACCEL_FLAGS |
| 620 | --enable-cuvid | 620 | --enable-cuvid |
| 621 | --enable-ffnvcodec | 621 | --enable-ffnvcodec |
| @@ -623,21 +623,20 @@ if (YUZU_USE_BUNDLED_FFMPEG) | |||
| 623 | --enable-hwaccel=h264_nvdec | 623 | --enable-hwaccel=h264_nvdec |
| 624 | --enable-hwaccel=vp8_nvdec | 624 | --enable-hwaccel=vp8_nvdec |
| 625 | --enable-hwaccel=vp9_nvdec | 625 | --enable-hwaccel=vp9_nvdec |
| 626 | --extra-cflags=-I${CUDA_INCLUDE_DIRS} | ||
| 627 | ) | ||
| 628 | list(APPEND FFmpeg_HWACCEL_LIBRARIES | ||
| 629 | ${FFNVCODEC_LIBRARIES} | ||
| 630 | ${CUDA_LIBRARIES} | ||
| 631 | ) | ||
| 632 | list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS | ||
| 633 | ${FFNVCODEC_INCLUDE_DIRS} | ||
| 634 | ${CUDA_INCLUDE_DIRS} | ||
| 635 | ) | ||
| 636 | list(APPEND FFmpeg_HWACCEL_LDFLAGS | ||
| 637 | ${FFNVCODEC_LDFLAGS} | ||
| 638 | ${CUDA_LDFLAGS} | ||
| 639 | ) | 626 | ) |
| 627 | list(APPEND FFmpeg_HWACCEL_LIBRARIES ${FFNVCODEC_LIBRARIES}) | ||
| 628 | list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS ${FFNVCODEC_INCLUDE_DIRS}) | ||
| 629 | list(APPEND FFmpeg_HWACCEL_LDFLAGS ${FFNVCODEC_LDFLAGS}) | ||
| 640 | message(STATUS "ffnvcodec libraries version ${FFNVCODEC_VERSION} found") | 630 | message(STATUS "ffnvcodec libraries version ${FFNVCODEC_VERSION} found") |
| 631 | # ffnvenc could load CUDA libraries at the runtime using dlopen/dlsym or LoadLibrary/GetProcAddress | ||
| 632 | # here we handle the hard-linking senario where CUDA is linked during compilation | ||
| 633 | if (CUDA_FOUND) | ||
| 634 | list(APPEND FFmpeg_HWACCEL_FLAGS --extra-cflags=-I${CUDA_INCLUDE_DIRS}) | ||
| 635 | list(APPEND FFmpeg_HWACCEL_LIBRARIES ${CUDA_LIBRARIES}) | ||
| 636 | list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS ${CUDA_INCLUDE_DIRS}) | ||
| 637 | list(APPEND FFmpeg_HWACCEL_LDFLAGS ${CUDA_LDFLAGS}) | ||
| 638 | message(STATUS "CUDA libraries found, hard-linking will be performed") | ||
| 639 | endif(CUDA_FOUND) | ||
| 641 | endif() | 640 | endif() |
| 642 | 641 | ||
| 643 | if (VDPAU_FOUND) | 642 | if (VDPAU_FOUND) |