From 7a6f366cefd27210f6a8309aed10c31104436509 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Wegner?= Date: Tue, 24 Oct 2023 20:53:01 +0200 Subject: [PATCH] [ffmpeg] fix cross builds on windows host (#34657) Two issues: * we should get msys2 when building on windows, not targeting windows. * removed usage of LIBRARY_PATH since it is ignored when cross-compiling [1]. Tested building for android on windows and works fine. [1]: https://gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html#index-LIBRARY_005fPATH --- ports/ffmpeg/portfile.cmake | 25 +++++++++++-------------- ports/ffmpeg/vcpkg.json | 2 +- versions/baseline.json | 2 +- versions/f-/ffmpeg.json | 5 +++++ 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/ports/ffmpeg/portfile.cmake b/ports/ffmpeg/portfile.cmake index 1754fcbff6887a..b4f29767b61764 100644 --- a/ports/ffmpeg/portfile.cmake +++ b/ports/ffmpeg/portfile.cmake @@ -33,18 +33,9 @@ if(NOT VCPKG_TARGET_ARCHITECTURE STREQUAL "wasm32") vcpkg_add_to_path("${NASM_EXE_PATH}") endif() -if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW) - #We're assuming that if we're building for Windows we're using MSVC - set(INCLUDE_VAR "INCLUDE") - set(LIB_PATH_VAR "LIB") -else() - set(INCLUDE_VAR "CPATH") - set(LIB_PATH_VAR "LIBRARY_PATH") -endif() - set(OPTIONS "--enable-pic --disable-doc --enable-debug --enable-runtime-cpudetect --disable-autodetect") -if(VCPKG_TARGET_IS_WINDOWS) +if(VCPKG_HOST_IS_WINDOWS) vcpkg_acquire_msys(MSYS_ROOT PACKAGES automake1.16) set(SHELL "${MSYS_ROOT}/usr/bin/bash.exe") vcpkg_add_to_path("${MSYS_ROOT}/usr/share/automake-1.16") @@ -94,8 +85,6 @@ string(APPEND VCPKG_COMBINED_C_FLAGS_RELEASE " -I \"${CURRENT_INSTALLED_DIR}/inc ## Setup vcpkg toolchain -set(ENV_LIB_PATH "$ENV{${LIB_PATH_VAR}}") - set(prog_env "") if(VCPKG_DETECTED_CMAKE_C_COMPILER) @@ -574,8 +563,12 @@ message(STATUS "Building Options: ${OPTIONS}") # Release build if (NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") + if (VCPKG_DETECTED_MSVC) + set(OPTIONS_RELEASE "${OPTIONS_RELEASE} --extra-ldflags=-libpath:\"${CURRENT_INSTALLED_DIR}/lib\"") + else() + set(OPTIONS_RELEASE "${OPTIONS_RELEASE} --extra-ldflags=-L\"${CURRENT_INSTALLED_DIR}/lib\"") + endif() message(STATUS "Building Release Options: ${OPTIONS_RELEASE}") - set(ENV{${LIB_PATH_VAR}} "${CURRENT_INSTALLED_DIR}/lib${VCPKG_HOST_PATH_SEPARATOR}${ENV_LIB_PATH}") set(ENV{PKG_CONFIG_PATH} "${CURRENT_INSTALLED_DIR}/lib/pkgconfig") message(STATUS "Building ${PORT} for Release") file(MAKE_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel") @@ -611,8 +604,12 @@ endif() # Debug build if (NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + if (VCPKG_DETECTED_MSVC) + set(OPTIONS_DEBUG "${OPTIONS_DEBUG} --extra-ldflags=-libpath:\"${CURRENT_INSTALLED_DIR}/debug/lib\"") + else() + set(OPTIONS_DEBUG "${OPTIONS_DEBUG} --extra-ldflags=-L\"${CURRENT_INSTALLED_DIR}/debug/lib\"") + endif() message(STATUS "Building Debug Options: ${OPTIONS_DEBUG}") - set(ENV{${LIB_PATH_VAR}} "${CURRENT_INSTALLED_DIR}/debug/lib${VCPKG_HOST_PATH_SEPARATOR}${ENV_LIB_PATH}") set(ENV{LDFLAGS} "${VCPKG_COMBINED_SHARED_LINKER_FLAGS_DEBUG}") set(ENV{PKG_CONFIG_PATH} "${CURRENT_INSTALLED_DIR}/debug/lib/pkgconfig") message(STATUS "Building ${PORT} for Debug") diff --git a/ports/ffmpeg/vcpkg.json b/ports/ffmpeg/vcpkg.json index 8abac6cd6a8bb7..1afb1c802817dc 100644 --- a/ports/ffmpeg/vcpkg.json +++ b/ports/ffmpeg/vcpkg.json @@ -1,7 +1,7 @@ { "name": "ffmpeg", "version": "6.0", - "port-version": 1, + "port-version": 2, "description": [ "a library to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created.", "FFmpeg is the leading multimedia framework, able to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created. It supports the most obscure ancient formats up to the cutting edge. No matter if they were designed by some standards committee, the community or a corporation. It is also highly portable: FFmpeg compiles, runs, and passes our testing infrastructure FATE across Linux, Mac OS X, Microsoft Windows, the BSDs, Solaris, etc. under a wide variety of build environments, machine architectures, and configurations." diff --git a/versions/baseline.json b/versions/baseline.json index 68ff3da4a4f722..24b2f890ac7e68 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -2566,7 +2566,7 @@ }, "ffmpeg": { "baseline": "6.0", - "port-version": 1 + "port-version": 2 }, "ffnvcodec": { "baseline": "11.1.5.2", diff --git a/versions/f-/ffmpeg.json b/versions/f-/ffmpeg.json index 13c40e2ea0c825..c38dd4d6e2f3c1 100644 --- a/versions/f-/ffmpeg.json +++ b/versions/f-/ffmpeg.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "9f33fe16e3a4e278bc2eb92b24483d00b90e9f3a", + "version": "6.0", + "port-version": 2 + }, { "git-tree": "70c25989395c92bd79faf0b136fb4636e96d541c", "version": "6.0",