Skip to content

Commit

Permalink
[ffmpeg] fix cross builds on windows host (microsoft#34657)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
lemourin authored Oct 24, 2023
1 parent cf9fe90 commit 7a6f366
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
25 changes: 11 additions & 14 deletions ports/ffmpeg/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion ports/ffmpeg/vcpkg.json
Original file line number Diff line number Diff line change
@@ -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."
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -2566,7 +2566,7 @@
},
"ffmpeg": {
"baseline": "6.0",
"port-version": 1
"port-version": 2
},
"ffnvcodec": {
"baseline": "11.1.5.2",
Expand Down
5 changes: 5 additions & 0 deletions versions/f-/ffmpeg.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "9f33fe16e3a4e278bc2eb92b24483d00b90e9f3a",
"version": "6.0",
"port-version": 2
},
{
"git-tree": "70c25989395c92bd79faf0b136fb4636e96d541c",
"version": "6.0",
Expand Down

0 comments on commit 7a6f366

Please sign in to comment.