From 9fcc0ad7a87978b078a0db9e0a91968e9809294b Mon Sep 17 00:00:00 2001 From: Rafael Kitover Date: Sat, 13 Sep 2025 20:59:08 -0700 Subject: [PATCH] build: fix finding static vcpkg x265 for FFmpeg Fix finding static vcpkg x265 when it is named `x265-static.lib` as it is right now. Fix finding vcpkg host pkgconf on ARM64 Windows, which uses x64 host binaries. Remove build environment architecture check, which fails building x64 on ARM64. That whole file needs to be rewritten to use the compiler target architecture. Signed-off-by: Rafael Kitover --- cmake/Architecture.cmake | 10 ++-------- cmake/FindFFmpeg.cmake | 7 ++++++- cmake/Options.cmake | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/cmake/Architecture.cmake b/cmake/Architecture.cmake index cd0a24de..c1695da5 100644 --- a/cmake/Architecture.cmake +++ b/cmake/Architecture.cmake @@ -2,6 +2,8 @@ if(TRANSLATIONS_ONLY) return() endif() +# TODO: Use compiler CPU not CMake. + if(NOT CMAKE_SYSTEM_PROCESSOR) if(NOT CMAKE_TOOLCHAIN_FILE AND CMAKE_HOST_SYSTEM_PROCESSOR) set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_HOST_SYSTEM_PROCESSOR}) @@ -71,14 +73,6 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "[aA][aA][rR][cC][hH]|[aA][rR][mM]") endif() endif() -if(DEFINED VCPKG_TARGET_TRIPLET) - string(REGEX MATCH "^[^-]+" target_arch ${VCPKG_TARGET_TRIPLET}) - - if(NOT WINARCH STREQUAL target_arch) - message(FATAL_ERROR "Wrong build environment architecture for VCPKG_TARGET_TRIPLET, you specified ${target_arch} but your compiler is for ${WINARCH}") - endif() -endif() - # We do not support amd64 asm yet if(X86_64 AND (ENABLE_ASM_CORE OR ENABLE_ASM_SCALERS OR ENABLE_MMX)) message(FATAL_ERROR "The options ASM_CORE, ASM_SCALERS and MMX are not supported on X86_64 yet.") diff --git a/cmake/FindFFmpeg.cmake b/cmake/FindFFmpeg.cmake index 412e46e4..d9057062 100644 --- a/cmake/FindFFmpeg.cmake +++ b/cmake/FindFFmpeg.cmake @@ -97,6 +97,11 @@ endmacro() # Check for cached results. If there are skip the costly part. if (NOT FFMPEG_LIBRARIES) + set(x265_lib "x265") + + if(CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg" AND FFMPEG_STATIC) + set(x265_lib "x265-static") + endif() # Check for all possible component. find_component(AVFORMAT libavformat avformat libavformat/avformat.h) @@ -108,7 +113,7 @@ if (NOT FFMPEG_LIBRARIES) find_component(POSTPROC libpostproc postproc libpostproc/postprocess.h) find_component(SWRESAMPLE libswresample swresample libswresample/swresample.h) find_component(X264 x264 x264 x264.h) - find_component(X265 x265 x265 x265.h) + find_component(X265 x265 "${x265_lib}" x265.h) # Check if the required components were found and add their stuff to the FFMPEG_* vars. foreach (_component ${FFmpeg_FIND_COMPONENTS}) diff --git a/cmake/Options.cmake b/cmake/Options.cmake index bbe08e6d..f366f9f8 100644 --- a/cmake/Options.cmake +++ b/cmake/Options.cmake @@ -40,7 +40,7 @@ if(VBAM_STATIC) endif() endif() -if(CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg" AND CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "^([xX]86_64|[aA][mM][dD]64)$") +if(CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg") set(PKG_CONFIG_EXECUTABLE "$ENV{VCPKG_ROOT}/installed/x64-windows/tools/pkgconf/pkgconf.exe") endif()