Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for updated vcpkg #3

Merged
merged 17 commits into from
Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions docs/maintainers/internal/z_vcpkg_setup_pkgconfig_path.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# z_vcpkg_setup_pkgconfig_path

The latest version of this document lives in the [vcpkg repo](https://github.com/Microsoft/vcpkg/blob/master/docs/).

`z_vcpkg_setup_pkgconfig_path` sets up environment variables to use `pkgconfig`, such as `PKG_CONFIG` and `PKG_CONFIG_PATH`.
The original values are restored with `z_vcpkg_restore_pkgconfig_path`. `BASE_DIRS` indicates the base directories to find `.pc` files; typically `${CURRENT_INSTALLED_DIR}`, or `${CURRENT_INSTALLED_DIR}/debug`.

```cmake
z_vcpkg_setup_pkgconfig_path(BASE_DIRS <"${CURRENT_INSTALLED_DIR}" ...>)
# Build process that may transitively invoke pkgconfig
z_vcpkg_restore_pkgconfig_path()
```


## Source
[scripts/cmake/z\_vcpkg\_setup\_pkgconfig\_path.cmake](https://github.com/Microsoft/vcpkg/blob/master/scripts/cmake/z_vcpkg_setup_pkgconfig_path.cmake)
3 changes: 3 additions & 0 deletions docs/maintainers/ports/vcpkg-cmake-get-vars.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# vcpkg-cmake-get-vars

This port contains a helper function to extract CMake variables into the scope of the portfile or other scripts
196 changes: 55 additions & 141 deletions ports/ffmpeg/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,140 +1,11 @@
#Check for unsupported features

if("ffmpeg" IN_LIST FEATURES)
vcpkg_fail_port_install(ON_TARGET "UWP" MESSAGE "Feature 'ffmpeg' does not support 'uwp'")
endif()

if("ffplay" IN_LIST FEATURES)
vcpkg_fail_port_install(ON_TARGET "UWP" MESSAGE "Feature 'ffplay' does not support 'uwp'")
endif()

if("ffprobe" IN_LIST FEATURES)
vcpkg_fail_port_install(ON_TARGET "UWP" MESSAGE "Feature 'ffprobe' does not support 'uwp'")
endif()


if("ass" IN_LIST FEATURES)
if (VCPKG_TARGET_ARCHITECTURE STREQUAL "arm" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64" OR VCPKG_TARGET_IS_UWP)
message(FATAL_ERROR "Feature 'ass' does not support 'uwp | arm'")
endif()
endif()

if("avisynthplus" IN_LIST FEATURES)
if (VCPKG_TARGET_ARCHITECTURE STREQUAL "arm" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64" OR (NOT VCPKG_TARGET_IS_WINDOWS))
message(FATAL_ERROR "Feature 'avisynthplus' does not support '!windows | arm | uwp'")
endif()
endif()

if("dav1d" IN_LIST FEATURES)
if (VCPKG_TARGET_ARCHITECTURE STREQUAL "arm" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "x86" OR VCPKG_TARGET_IS_UWP OR VCPKG_TARGET_IS_OSX)
message(FATAL_ERROR "Feature 'dav1d' does not support 'uwp | arm | x86 | osx'")
endif()
endif()

if("fdk-aac" IN_LIST FEATURES)
if (VCPKG_TARGET_ARCHITECTURE STREQUAL "arm" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64" OR VCPKG_TARGET_IS_UWP)
message(FATAL_ERROR "Feature 'fdk-aac' does not support 'uwp | arm'")
endif()
endif()

if("fontconfig" IN_LIST FEATURES)
if (VCPKG_TARGET_ARCHITECTURE STREQUAL "arm" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64" OR VCPKG_TARGET_IS_UWP OR (VCPKG_TARGET_IS_WINDOWS AND VCPKG_LIBRARY_LINKAGE STREQUAL "static"))
message(FATAL_ERROR "Feature 'fontconfig' does not support 'uwp | arm | (windows & static)'")
endif()
endif()

if("fribidi" IN_LIST FEATURES)
if (VCPKG_TARGET_ARCHITECTURE STREQUAL "arm" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64" OR VCPKG_TARGET_IS_UWP)
message(FATAL_ERROR "Feature 'fribidi' does not support 'uwp | arm'")
endif()
endif()

if("ilbc" IN_LIST FEATURES)
if ((VCPKG_TARGET_ARCHITECTURE STREQUAL "arm" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64") AND VCPKG_TARGET_IS_UWP)
message(FATAL_ERROR "Feature 'ilbc' does not support 'uwp & arm'")
endif()
endif()

if("modplug" IN_LIST FEATURES)
if (VCPKG_TARGET_IS_UWP OR (VCPKG_TARGET_IS_WINDOWS AND VCPKG_LIBRARY_LINKAGE STREQUAL "static"))
message(FATAL_ERROR "Feature 'modplug' does not support 'uwp | (windows & static)'")
endif()
endif()

if("nvcodec" IN_LIST FEATURES)
if (VCPKG_TARGET_ARCHITECTURE STREQUAL "arm" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64" OR ((NOT VCPKG_TARGET_IS_WINDOWS) AND (NOT VCPKG_TARGET_IS_LINUX)))
message(FATAL_ERROR "Feature 'nvcodec' does not support '!(windows | linux) | uwp | arm'")
endif()
endif()

if("opencl" IN_LIST FEATURES)
vcpkg_fail_port_install(ON_TARGET "UWP" MESSAGE "Feature 'opencl' does not support 'uwp'")
endif()

if("opengl" IN_LIST FEATURES)
if (((VCPKG_TARGET_ARCHITECTURE STREQUAL "arm" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64") AND VCPKG_TARGET_IS_WINDOWS) OR VCPKG_TARGET_IS_UWP OR VCPKG_TARGET_IS_OSX)
message(FATAL_ERROR "Feature 'opengl' does not support 'uwp | (windows & arm) | osx'")
endif()
endif()

if("openh264" IN_LIST FEATURES)
vcpkg_fail_port_install(ON_TARGET "UWP" MESSAGE "Feature 'openh264' does not support 'uwp'")
endif()

if("sdl2" IN_LIST FEATURES)
vcpkg_fail_port_install(ON_TARGET "OSX" MESSAGE "Feature 'sdl2' does not support 'osx'")
endif()

if("ssh" IN_LIST FEATURES)
if (VCPKG_TARGET_ARCHITECTURE STREQUAL "arm" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64" OR VCPKG_TARGET_IS_UWP OR VCPKG_LIBRARY_LINKAGE STREQUAL "static")
message(FATAL_ERROR "Feature 'ssh' does not support 'uwp | arm | static'")
endif()
endif()

if("tensorflow" IN_LIST FEATURES)
if (VCPKG_TARGET_ARCHITECTURE STREQUAL "arm" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64" OR VCPKG_TARGET_IS_UWP OR VCPKG_LIBRARY_LINKAGE STREQUAL "static" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
message(FATAL_ERROR "Feature 'tensorflow' does not support 'x86 | arm | uwp | static'")
endif()
endif()

if("tesseract" IN_LIST FEATURES)
if (((VCPKG_TARGET_ARCHITECTURE STREQUAL "arm" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64") AND VCPKG_TARGET_IS_WINDOWS) OR VCPKG_TARGET_IS_UWP OR VCPKG_LIBRARY_LINKAGE STREQUAL "static")
message(FATAL_ERROR "Feature 'tesseract' does not support 'uwp | (windows & arm) | static'")
endif()
endif()

if("wavpack" IN_LIST FEATURES)
if (VCPKG_TARGET_ARCHITECTURE STREQUAL "arm" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
message(FATAL_ERROR "Feature 'wavpack' does not support 'arm'")
endif()
endif()

if("x264" IN_LIST FEATURES)
if (VCPKG_TARGET_ARCHITECTURE STREQUAL "arm" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
message(FATAL_ERROR "Feature 'x264' does not support 'arm'")
endif()
endif()

if("x265" IN_LIST FEATURES)
if (VCPKG_TARGET_ARCHITECTURE STREQUAL "arm" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64" OR VCPKG_TARGET_IS_UWP)
message(FATAL_ERROR "Feature 'x265' does not support 'uwp | arm'")
endif()
endif()

if("xml2" IN_LIST FEATURES)
if (VCPKG_LIBRARY_LINKAGE STREQUAL "static")
message(FATAL_ERROR "Feature 'xml2' does not support 'static'")
endif()
endif()

if(VCPKG_TARGET_IS_WINDOWS)
set(PATCHES 0017-Patch-for-ticket-9019-CUDA-Compile-Broken-Using-MSVC.patch) # https://trac.ffmpeg.org/ticket/9019
endif()
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO ffmpeg/ffmpeg
REF n4.4
SHA512 ae7426ca476df9fa9dba52cab06c38e484f835653fb2da57e7c06f5589d887c0854ee17df93a2f57191d498c1264cb1c69312cf0a8214b476800382e2d260c4b
REF n4.4.1
SHA512 a53e617937f9892c5cfddb00896be9ad8a3e398dc7cf3b6c893b52ff38aff6ff0cbc61a44cd5f93d9a28f775e71ae82996a5e2b699a769c1de8f882aab34c797
HEAD_REF master
PATCHES
0001-create-lib-libraries.patch
Expand All @@ -147,9 +18,9 @@ vcpkg_from_github(
0011-Fix-x265-detection.patch
0012-Fix-ssl-110-detection.patch
0013-define-WINVER.patch
0014-avfilter-dependency-fix.patch # http://ffmpeg.org/pipermail/ffmpeg-devel/2021-February/275819.html
0014-avfilter-dependency-fix.patch # https://ffmpeg.org/pipermail/ffmpeg-devel/2021-February/275819.html
0015-Fix-xml2-detection.patch
0016-configure-dnn-needs-avformat.patch # http://ffmpeg.org/pipermail/ffmpeg-devel/2021-May/279926.html
0016-configure-dnn-needs-avformat.patch # https://ffmpeg.org/pipermail/ffmpeg-devel/2021-May/279926.html
${PATCHES}
1000-resolume-small-memory-allocations.patch
1001-max_chunk_size-from-format-context-in-build_chunks.patch
Expand Down Expand Up @@ -237,7 +108,36 @@ if(VCPKG_TARGET_IS_OSX AND VCPKG_OSX_DEPLOYMENT_TARGET)
set(OPTIONS "--extra-ldflags=-mmacosx-version-min=${VCPKG_OSX_DEPLOYMENT_TARGET} ${OPTIONS}")
endif()

set(ENV{${INCLUDE_VAR}} "${CURRENT_INSTALLED_DIR}/include${VCPKG_HOST_PATH_SEPARATOR}$ENV{${INCLUDE_VAR}}")
if(VCPKG_TARGET_IS_MINGW)
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
string(APPEND OPTIONS " --target-os=mingw32")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
string(APPEND OPTIONS " --target-os=mingw64")
endif()
elseif(VCPKG_TARGET_IS_LINUX)
string(APPEND OPTIONS " --target-os=linux")
elseif(VCPKG_TARGET_IS_WINDOWS)
string(APPEND OPTIONS " --target-os=win32")
elseif(VCPKG_TARGET_IS_OSX)
string(APPEND OPTIONS " --target-os=darwin")
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Android")
string(APPEND OPTIONS " --target-os=android")
endif()

vcpkg_cmake_get_vars(cmake_vars_file)
include("${cmake_vars_file}")

if(VCPKG_DETECTED_MSVC)
set(OPTIONS "--toolchain=msvc ${OPTIONS}")
# This is required because ffmpeg depends upon optimizations to link correctly
string(APPEND VCPKG_COMBINED_C_FLAGS_DEBUG " -O2")
string(REGEX REPLACE "(^| )-RTC1( |$)" " " VCPKG_COMBINED_C_FLAGS_DEBUG "${VCPKG_COMBINED_C_FLAGS_DEBUG}")
string(REGEX REPLACE "(^| )-Od( |$)" " " VCPKG_COMBINED_C_FLAGS_DEBUG "${VCPKG_COMBINED_C_FLAGS_DEBUG}")
string(REGEX REPLACE "(^| )-Ob0( |$)" " " VCPKG_COMBINED_C_FLAGS_DEBUG "${VCPKG_COMBINED_C_FLAGS_DEBUG}")
endif()

string(APPEND VCPKG_COMBINED_C_FLAGS_DEBUG " -I \"${CURRENT_INSTALLED_DIR}/include\"")
string(APPEND VCPKG_COMBINED_C_FLAGS_RELEASE " -I \"${CURRENT_INSTALLED_DIR}/include\"")

set(_csc_PROJECT_PATH ffmpeg)

Expand Down Expand Up @@ -273,6 +173,10 @@ else()
set(OPTIONS "${OPTIONS} --disable-ffprobe")
endif()

if (NOT "alsa" IN_LIST FEATURES)
set(OPTIONS "${OPTIONS} --disable-alsa")
endif()

if("avcodec" IN_LIST FEATURES)
set(OPTIONS "${OPTIONS} --enable-avcodec")
set(ENABLE_AVCODEC ON)
Expand Down Expand Up @@ -613,10 +517,6 @@ else()
set(OPTIONS "${OPTIONS} --disable-zlib")
endif()

set(CMAKE_VARS_FILE "${CURRENT_BUILDTREES_DIR}/vars.cmake")
vcpkg_internal_get_cmake_vars(OUTPUT_FILE CMAKE_VARS_FILE)
include("${CMAKE_VARS_FILE}")

if (VCPKG_TARGET_IS_OSX)
# if the sysroot isn't set in the triplet we fall back to whatever CMake detected for us
if ("${VCPKG_OSX_SYSROOT}" STREQUAL "")
Expand All @@ -628,7 +528,18 @@ if (VCPKG_TARGET_IS_OSX)
set(OPTIONS "${OPTIONS} --extra-ldflags=\"-isysroot ${VCPKG_OSX_SYSROOT}\"")
endif()

set(OPTIONS_CROSS "")
set(OPTIONS_CROSS " --enable-cross-compile")

# ffmpeg needs --cross-prefix option to use appropriate tools for cross-compiling.
if(VCPKG_DETECTED_CMAKE_C_COMPILER MATCHES "(/.+)gcc$")
string(APPEND OPTIONS_CROSS " --cross-prefix=${CMAKE_MATCH_1}")
endif()

if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
string(APPEND OPTIONS_CROSS " --arch=x86_64")
else()
string(APPEND OPTIONS_CROSS " --arch=${VCPKG_TARGET_ARCHITECTURE}")
endif()

if (VCPKG_TARGET_ARCHITECTURE STREQUAL "arm" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
if(VCPKG_TARGET_IS_WINDOWS)
Expand All @@ -638,7 +549,7 @@ if (VCPKG_TARGET_ARCHITECTURE STREQUAL "arm" OR VCPKG_TARGET_ARCHITECTURE STREQU
get_filename_component(GAS_ITEM_PATH ${GAS_PATH} DIRECTORY)
set(ENV{PATH} "$ENV{PATH}${VCPKG_HOST_PATH_SEPARATOR}${GAS_ITEM_PATH}")
endforeach(GAS_PATH)
elseif(VCPKG_TARGET_IS_OSX AND NOT VCPKG_TARGET_ARCHITECTURE STREQUAL "${VCPKG_DETECTED_CMAKE_SYSTEM_PROCESSOR}") # VCPKG_TARGET_ARCHITECTURE = arm64
elseif(VCPKG_TARGET_IS_OSX AND NOT VCPKG_TARGET_ARCHITECTURE STREQUAL "${VCPKG_DETECTED_CMAKE_HOST_SYSTEM_PROCESSOR}")
# get the number of architectures requested
list(LENGTH VCPKG_OSX_ARCHITECTURES ARCHITECTURE_COUNT)

Expand All @@ -651,6 +562,9 @@ if (VCPKG_TARGET_ARCHITECTURE STREQUAL "arm" OR VCPKG_TARGET_ARCHITECTURE STREQU
endif()
endif()
elseif (VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
if(VCPKG_TARGET_IS_OSX)
set(OPTIONS_CROSS " --enable-cross-compile --target-os=darwin --arch=x86_64 --extra-ldflags=-arch --extra-ldflags=x86_64 --extra-cflags=-arch --extra-cflags=x86_64 --extra-cxxflags=-arch --extra-cxxflags=x86_64")
endif()
elseif (VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
else()
message(FATAL_ERROR "Unsupported architecture")
Expand All @@ -663,7 +577,7 @@ if(VCPKG_TARGET_IS_UWP)
set(OPTIONS_CROSS " --enable-cross-compile --target-os=win32 --arch=${VCPKG_TARGET_ARCHITECTURE}")
endif()

set(OPTIONS_DEBUG "--debug") # Note: --disable-optimizations can't be used due to http://ffmpeg.org/pipermail/libav-user/2013-March/003945.html
set(OPTIONS_DEBUG "--debug") # Note: --disable-optimizations can't be used due to https://ffmpeg.org/pipermail/libav-user/2013-March/003945.html
set(OPTIONS_RELEASE "")

set(OPTIONS "${OPTIONS} ${OPTIONS_CROSS}")
Expand Down
Loading