microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
22.98k stars 6.34k forks source link

[zlib] warning: Broken installation of vcpkg port zlib (Android) #20057

Closed Luiz-Monad closed 2 years ago

Luiz-Monad commented 3 years ago

Describe the bug Is there a reason why I get "Broken installation of vcpkg port zlib" after updating my vcpkg ports.

Environment

    -- Custom Android NDK Toolchain
    -- root:    C:/Microsoft/AndroidSDK/25
    -- ndk:     C:/Microsoft/AndroidSDK/25/ndk
    -- ndk_ver: 22.1.7171670
    -- sys_ver: 29
    -- ninja:   C:/Microsoft/AndroidSDK/25/cmake/3.10.2.4988404/bin/ninja.exe
    -- Android: Targeting API '21' with architecture 'arm64', ABI 'arm64-v8a', and processor 'aarch64'
    -- Custom Android NDK Toolchain
    -- root:    C:/Microsoft/AndroidSDK/25
    -- ndk:     C:/Microsoft/AndroidSDK/25/ndk
    -- ndk_ver: 22.1.7171670
    -- sys_ver: 29
    -- ninja:   C:/Microsoft/AndroidSDK/25/cmake/3.10.2.4988404/bin/ninja.exe
    -- Android: Selected unified Clang toolchain
    -- The C compiler identification is Clang 11.0.5
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Check for working C compiler: C:/Microsoft/AndroidSDK/25/ndk/22.1.7171670/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe - skipped
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- The CXX compiler identification is Clang 11.0.5
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Check for working CXX compiler: C:/Microsoft/AndroidSDK/25/ndk/22.1.7171670/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe - skipped
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    #COMPILER_HASH#4cd580d23fc13bc8374d090d9f853424e245f5ad
    #COMPILER_C_HASH#363c3ee7d32c9d699f2db05451e67a8b4b09faa9
    #COMPILER_C_VERSION#11.0.5
    #COMPILER_C_ID#Clang
    #COMPILER_CXX_HASH#363c3ee7d32c9d699f2db05451e67a8b4b09faa9
    #COMPILER_CXX_VERSION#11.0.5
    #COMPILER_CXX_ID#Clang

To Reproduce Steps to reproduce the behavior:

  1. ./vcpkg install zlib
  2. Try to build anythging statically that uses zlib on Android.

Expected behavior No warnings.

Failure logs

Bloody logs! ```cmake -- OpenCV disables pkg-config to avoid using of host libraries. Consider using PKG_CONFIG_LIBDIR to specify target SYSROOT CMake Warning at C:/extern/workbench/test/build/outputs/opencv/ndk-android-aarch64-debug/vcpkg_installed/ndk-android-aarch64/share/zlib/vcpkg-cmake-wrapper.cmake:6 (message): ZLIB_ROOT: C:/extern/workbench/test/build/outputs/opencv/ndk-android-aarch64-debug/vcpkg_installed/ndk-android-aarch64 Call Stack (most recent call first): C:/extern/workbench/test-app/thirdparty/vcpkg/scripts/buildsystems/vcpkg.cmake:738 (include) cmake/OpenCVFindLibsGrfmt.cmake:14 (find_package) CMakeLists.txt:710 (include) CMake Warning at C:/extern/workbench/test/build/outputs/opencv/ndk-android-aarch64-debug/vcpkg_installed/ndk-android-aarch64/share/zlib/vcpkg-cmake-wrapper.cmake:7 (message): ZLIB_INCLUDE_DIR: C:/extern/workbench/test/build/outputs/opencv/ndk-android-aarch64-debug/vcpkg_installed/ndk-android-aarch64/include Call Stack (most recent call first): C:/extern/workbench/test-app/thirdparty/vcpkg/scripts/buildsystems/vcpkg.cmake:738 (include) cmake/OpenCVFindLibsGrfmt.cmake:14 (find_package) CMakeLists.txt:710 (include) CMake Warning at C:/extern/workbench/test/build/outputs/opencv/ndk-android-aarch64-debug/vcpkg_installed/ndk-android-aarch64/share/zlib/vcpkg-cmake-wrapper.cmake:8 (message): ZLIB_LIBRARY_RELEASE: C:/Microsoft/AndroidSDK/25/ndk/22.1.7171670/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/lib/aarch64-linux-android/29/libz.so Call Stack (most recent call first): C:/extern/workbench/test-app/thirdparty/vcpkg/scripts/buildsystems/vcpkg.cmake:738 (include) cmake/OpenCVFindLibsGrfmt.cmake:14 (find_package) CMakeLists.txt:710 (include) CMake Warning at C:/extern/workbench/test/build/outputs/opencv/ndk-android-aarch64-debug/vcpkg_installed/ndk-android-aarch64/share/zlib/vcpkg-cmake-wrapper.cmake:9 (message): ZLIB_LIBRARY_DEBUG: ZLIB_LIBRARY_DEBUG-NOTFOUND Call Stack (most recent call first): C:/extern/workbench/test-app/thirdparty/vcpkg/scripts/buildsystems/vcpkg.cmake:738 (include) cmake/OpenCVFindLibsGrfmt.cmake:14 (find_package) CMakeLists.txt:710 (include) CMake Warning at C:/extern/workbench/test/build/outputs/opencv/ndk-android-aarch64-debug/vcpkg_installed/ndk-android-aarch64/share/zlib/vcpkg-cmake-wrapper.cmake:10 (message): Broken installation of vcpkg port zlib Call Stack (most recent call first): C:/extern/workbench/test-app/thirdparty/vcpkg/scripts/buildsystems/vcpkg.cmake:738 (include) cmake/OpenCVFindLibsGrfmt.cmake:14 (find_package) CMakeLists.txt:710 (include) -- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) -- Consider adding OPENCV_ALLOCATOR_STATS_COUNTER_TYPE=int/int64_t according to your build configuration -- Excluding from source files list: modules/imgproc/src/corner.avx.cpp -- Excluding from source files list: modules/imgproc/src/imgwarp.avx2.cpp -- Excluding from source files list: modules/imgproc/src/imgwarp.sse4_1.cpp ```

Additional context The bisect change that was made, I guess there's a good reason for that warning.

https://github.com/microsoft/vcpkg/blob/7dbc05515b44bf54d2a42b4da9d1e1f910868b86/ports/zlib/portfile.cmake#L34

https://github.com/microsoft/vcpkg/blob/7dbc05515b44bf54d2a42b4da9d1e1f910868b86/ports/zlib/vcpkg-cmake-wrapper.cmake#L6

dg0yt commented 3 years ago

You use the wrapper: C:/extern/workbench/test/build/outputs/opencv/ndk-android-aarch64-debug/vcpkg_installed/ndk-android-aarch64/share/zlib/vcpkg-cmake-wrapper.cmake so your root is: C:/extern/workbench/test/build/outputs/opencv/ndk-android-aarch64-debug/vcpkg_installed/ndk-android-aarch64 ZLIB_INCLUDE_DIR is okay: C:/extern/workbench/test/build/outputs/opencv/ndk-android-aarch64-debug/vcpkg_installed/ndk-android-aarch64/include ZLIB_LIBRARY_RELEASE is not from vcpkg, so it may be a different version than the headers: C:/Microsoft/AndroidSDK/25/ndk/22.1.7171670/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/lib/aarch64-linux-android/29/libz.so ZLIB_LIBRARY_DEBUG is not found at all: ZLIB_LIBRARY_DEBUG: ZLIB_LIBRARY_DEBUG-NOTFOUND

I guess there is an issue with the library search path in you project. The vcpkg path should be searched before the NDK path. Vcpkg had a change to support this. zlib in the NDK was an old version when I needed it, so it really matters to use vcpkg's version for some ports.

dg0yt commented 3 years ago

ZLIB_LIBRARY_DEBUG is not found at all: ZLIB_LIBRARY_DEBUG: ZLIB_LIBRARY_DEBUG-NOTFOUND

Actually it should be found despite the path issues. Do you really have libz in C:/extern/workbench/test/build/outputs/opencv/ndk-android-aarch64-debug/vcpkg_installed/ndk-android-aarch64/lib and C:/extern/workbench/test/build/outputs/opencv/ndk-android-aarch64-debug/vcpkg_installed/ndk-android-aarch64/debug/lib ?

Luiz-Monad commented 3 years ago

You use the wrapper: C:/extern/workbench/test/build/outputs/opencv/ndk-android-aarch64-debug/vcpkg_installed/ndk-android-aarch64/share/zlib/vcpkg-cmake-wrapper.cmake so your root is: C:/extern/workbench/test/build/outputs/opencv/ndk-android-aarch64-debug/vcpkg_installed/ndk-android-aarch64 ZLIB_INCLUDE_DIR is okay: C:/extern/workbench/test/build/outputs/opencv/ndk-android-aarch64-debug/vcpkg_installed/ndk-android-aarch64/include ZLIB_LIBRARY_RELEASE is not from vcpkg, so it may be a different version than the headers: C:/Microsoft/AndroidSDK/25/ndk/22.1.7171670/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/lib/aarch64-linux-android/29/libz.so ZLIB_LIBRARY_DEBUG is not found at all: ZLIB_LIBRARY_DEBUG: ZLIB_LIBRARY_DEBUG-NOTFOUND

I guess there is an issue with the library search path in you project. The vcpkg path should be searched before the NDK path. Vcpkg had a change to support this. zlib in the NDK was an old version when I needed it, so it really matters to use vcpkg's version for some ports.

I understood it, I must have done some mixup by mistake.

Luiz-Monad commented 3 years ago

Are we STILL having issues with zlib? zlib is such a tiny and simple project that takes a minute to be built from source. So far we haven't experienced any issues on Windows 10 x64 (no idea about Android, sorry).

It does indeed work when I build against MSVC and target Windows, it builds from the source. But when I build against Android, I prefer to use the library from the system. (I'm using a custom modified target for Android on vcpkg, and I may have made some mistake)

My problem is that I used headers from vcpkg and the library from Android. I got confused, but dgoyt clarified it for me. Its not really a problem to me, to mix the headers and the binaries, they are compatible anyway, I just wanted to know why the warning, as I wasn't understanding why.

The program builds and works fine anyway, its just that I don't like to not know the reason for warning, so I had to investigate before turning it off and marking the reason why I ignored it (by copying the zlib port and commenting out the check)

ndk-android-x86.cmake

set(VCPKG_TARGET_ARCHITECTURE x86)
set(VCPKG_CRT_LINKAGE static)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_CMAKE_SYSTEM_NAME Android)
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/ndk-android.cmake)

ndk-android.cmake

message(STATUS "Custom Android NDK Toolchain")

set (ANDROID_SDK_ROOT "C:/Microsoft/AndroidSDK/25")
set (ANDROID_NDK_ROOT "C:/Microsoft/AndroidSDK/25/ndk")
set (ANDROID_NDK_VERSION "22.1.7171670")
set (ANDROID_NDK_SYSTEM_VERSION 29)
set (ANDROID_NDK_NINJA "C:/Microsoft/AndroidSDK/25/cmake/3.10.2.4988404/bin/ninja.exe")

# 3. Set VCPKG_TARGET_TRIPLET according to ANDROID_ABI
# 
# There are four different Android ABI, each of which maps to 
# a vcpkg triplet. The following table outlines the mapping from vcpkg architectures to android architectures
#
# |VCPKG_TARGET_TRIPLET       | ANDROID_ABI          |
# |---------------------------|----------------------|
# |arm64-android              | arm64-v8a            |
# |arm-android                | armeabi-v7a          |
# |x64-android                | x86_64               |
# |x86-android                | x86                  |
#

if (VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
    set(ANDROID_ABI arm64-v8a CACHE STRING "")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "armv6")
    set(ANDROID_ABI armeabi CACHE STRING "")
    set(ANDROID_ARM_MODE arm CACHE STRING "")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm")
    set(ANDROID_ABI armeabi-v7a CACHE STRING "")
    set(ANDROID_ARM_NEON ON CACHE BOOL "")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "armv7")
    set(ANDROID_ABI armeabi-v7a CACHE STRING "")
    set(ANDROID_ARM_NEON OFF CACHE BOOL "")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
    set(ANDROID_ABI x86_64 CACHE STRING "")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
    set(ANDROID_ABI x86 CACHE STRING "")
else()
    message(FATAL_ERROR "Unknown ABI for target triplet ${VCPKG_TARGET_TRIPLET}")
endif()
if (VCPKG_CRT_LINKAGE STREQUAL "dynamic")
    set(ANDROID_STL_TYPE c++_shared CACHE STRING "")
else()
    set(ANDROID_STL_TYPE c++_static CACHE STRING "")
endif()
set(ANDROID_SDK ${ANDROID_SDK_ROOT} CACHE STRING "")
set(ANDROID_NDK ${ANDROID_NDK_ROOT}/${ANDROID_NDK_VERSION} CACHE STRING "")
set(ANDROID_NATIVE_API_LEVEL ${ANDROID_NDK_SYSTEM_VERSION} CACHE STRING "")
set(ANDROID_PLATFORM=android-${ANDROID_NATIVE_API_LEVEL} CACHE STRING "")

set(CMAKE_SYSTEM_NAME "Android" CACHE STRING "")
set(CMAKE_SYSTEM_VERSION ${ANDROID_NATIVE_API_LEVEL} CACHE STRING "")
set(CMAKE_MAKE_PROGRAM $ENV{ANDROID_NDK_NINJA} CACHE STRING "")
set(CMAKE_ANDROID_ARCH_ABI ${ANDROID_ABI} CACHE STRING "")
set(CMAKE_ANDROID_NDK ${ANDROID_NDK} CACHE STRING "")
set(CMAKE_ANDROID_STL_TYPE ${ANDROID_STL_TYPE} CACHE STRING "")

message(STATUS "root:    ${ANDROID_SDK_ROOT}")
message(STATUS "ndk:     ${ANDROID_NDK_ROOT}")
message(STATUS "ndk_ver: ${ANDROID_NDK_VERSION}")
message(STATUS "sys_ver: ${ANDROID_NDK_SYSTEM_VERSION}")
message(STATUS "ninja:   ${ANDROID_NDK_NINJA}")
message(STATUS "ndk-abi: ${ANDROID_ABI}")

if(NOT _VCPKG_ANDROID_TOOLCHAIN)
    set(_VCPKG_ANDROID_TOOLCHAIN 1)
    get_property( _CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE )
    if(NOT _CMAKE_IN_TRY_COMPILE)
        string(APPEND CMAKE_C_FLAGS " -fPIC ${VCPKG_C_FLAGS} ")
        string(APPEND CMAKE_CXX_FLAGS " -fPIC ${VCPKG_CXX_FLAGS} ")
        string(APPEND CMAKE_C_FLAGS_DEBUG " ${VCPKG_C_FLAGS_DEBUG} ")
        string(APPEND CMAKE_CXX_FLAGS_DEBUG " ${VCPKG_CXX_FLAGS_DEBUG} ")
        string(APPEND CMAKE_C_FLAGS_RELEASE " ${VCPKG_C_FLAGS_RELEASE} ")
        string(APPEND CMAKE_CXX_FLAGS_RELEASE " ${VCPKG_CXX_FLAGS_RELEASE} ")

        string(APPEND CMAKE_SHARED_LINKER_FLAGS " ${VCPKG_LINKER_FLAGS} ")
        string(APPEND CMAKE_EXE_LINKER_FLAGS " ${VCPKG_LINKER_FLAGS} ")
        string(APPEND CMAKE_SHARED_LINKER_FLAGS_DEBUG " ${VCPKG_LINKER_FLAGS_DEBUG} ")
        string(APPEND CMAKE_EXE_LINKER_FLAGS_DEBUG " ${VCPKG_LINKER_FLAGS_DEBUG} ")
        string(APPEND CMAKE_SHARED_LINKER_FLAGS_RELEASE " ${VCPKG_LINKER_FLAGS_RELEASE} ")
        string(APPEND CMAKE_EXE_LINKER_FLAGS_RELEASE " ${VCPKG_LINKER_FLAGS_RELEASE} ")
    endif()
endif()
Luiz-Monad commented 3 years ago

Are we STILL having issues with zlib? zlib is such a tiny and simple project that takes a minute to be built from source. So far we haven't experienced any issues on Windows 10 x64 (no idea about Android, sorry).

You may be right, there's no point in saving 3kb of binary code by using the library from Android, I should force it to always use the VCPKG.

I may be asking for problems, yet, I rely on loading resources directly from the APK by using compress STORE and the AResourceManager and seeking into the pkzip stream, and the application was already made using that before I migrated my insanity of powershell scripts, git, gradle and cmake to only cmake and vcpkg for building. (and the library was already dynamically loaded anyway, so why not use it instead of a static one?) This tool is very well made, it did solve my dependency management problems.

I hope I made clear what I wanted to do, my question was answered as well, we can close this now if no one has any else to add. Thanks for the help.

dg0yt commented 3 years ago

@Luiz-Monad Let me repeat my question: Do you have libz in C:/extern/workbench/test/build/outputs/opencv/ndk-android-aarch64-debug/vcpkg_installed/ndk-android-aarch64/lib and C:/extern/workbench/test/build/outputs/opencv/ndk-android-aarch64-debug/vcpkg_installed/ndk-android-aarch64/debug/lib? Even if yes, we may need to verify it is really for aarch-64.

Luiz-Monad commented 3 years ago

ZLIB_LIBRARY_DEBUG is not found at all: ZLIB_LIBRARY_DEBUG: ZLIB_LIBRARY_DEBUG-NOTFOUND

Actually it should be found despite the path issues. Do you really have libz in C:/extern/workbench/test/build/outputs/opencv/ndk-android-aarch64-debug/vcpkg_installed/ndk-android-aarch64/lib and C:/extern/workbench/test/build/outputs/opencv/ndk-android-aarch64-debug/vcpkg_installed/ndk-android-aarch64/debug/lib ?

I do have it, and it is indeed the right arch.

Maybe OpenCV did something stupid like this, changing the name of the library. (this has the vcpkg patch applied, I checked it)

# --- zlib (required) ---
if(BUILD_ZLIB)
ocv_clear_vars(ZLIB_FOUND)
else()
ocv_clear_internal_cache_vars(ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
if(ANDROID)
    set(_zlib_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
    set(CMAKE_FIND_LIBRARY_SUFFIXES .so)
endif()
find_package(ZLIB "${MIN_VER_ZLIB}" REQUIRED)
if(ANDROID)
    set(CMAKE_FIND_LIBRARY_SUFFIXES ${_zlib_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
    unset(_zlib_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES)
endif()
if(ZLIB_FOUND AND ANDROID)
    if(ZLIB_LIBRARIES MATCHES "/usr/lib.*/libz.so$")
    set(ZLIB_LIBRARIES z)
    endif()
endif()
endif()

if(NOT ZLIB_FOUND)
ocv_clear_vars(ZLIB_LIBRARY ZLIB_LIBRARIES ZLIB_INCLUDE_DIR)

set(ZLIB_LIBRARY zlib CACHE INTERNAL "")
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/zlib")
set(ZLIB_INCLUDE_DIR "${${ZLIB_LIBRARY}_SOURCE_DIR}" "${${ZLIB_LIBRARY}_BINARY_DIR}" CACHE INTERNAL "")
set(ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR})
set(ZLIB_LIBRARIES ${ZLIB_LIBRARY})

ocv_parse_header2(ZLIB "${${ZLIB_LIBRARY}_SOURCE_DIR}/zlib.h" ZLIB_VERSION)
endif()
Luiz-Monad commented 3 years ago

That was it

This makes sense now.

if(ZLIB_FOUND AND ANDROID)
    if(ZLIB_LIBRARIES MATCHES "/usr/lib.*/libz.so$")
    set(ZLIB_LIBRARIES z)
    endif()
endif()

OpenCV was messing with it. Let me check if I updated the ports to the new version.

dg0yt commented 3 years ago

What a "hack". I added the zlib wrapper not so long ago but I didn't know about that. Now I feel even more comfortable with the extra check and message in the zlib wrapper.

Luiz-Monad commented 3 years ago

The ports are on the updated version, nothing changed on OpenCVFindLibsGrfmt.cmake . We either add a patch on top of it on OpenCV to remove those lines, that will fix the problem and get rid of the warning and use the compiled version, and it makes more sense. Or we can ignore the warning and use the android dynamic library version, either way will work, but I'm starting to think it doesn't help much saving a few kilobytes.

Luiz-Monad commented 3 years ago

That really confused me, I wasn't suspecting it, because I have a lot of other libraries that use zlib and work fine on android, but this specific OpenCV one...

dg0yt commented 3 years ago

You have to stay with one version of zlib. As some ports need a more recent zlib this means you have to use vpkg's one.

(However, a no-op overlay-port for zlib could redirect the build to Android's zlib if this is desired.)

Luiz-Monad commented 3 years ago

This might be desired at some point by someone else. In my case I only made it by mistake, and because I was already doing it before. But this and sfhacker convinced me that its better to use the vcpkg static one anyway. So I opt to fix my OpenCV port meanwhile, I do customize a lot of things on my opencv, so its not a problem to hack off their "hack". (its already a custom overlay on top of the upstream anyway)

cenit commented 3 years ago

The ports are on the updated version, nothing changed on OpenCVFindLibsGrfmt.cmake . We either add a patch on top of it on OpenCV to remove those lines, that will fix the problem and get rid of the warning and use the compiled version, and it makes more sense. Or we can ignore the warning and use the android dynamic library version, either way will work, but I'm starting to think it doesn't help much saving a few kilobytes.

we can do a patch specific for android here in vcpkg. We already "undo" some workarounds that opencv has in its toolchain that break many things for windows (ffmpeg, protobuf, image libs), we can revert also this zlib one for android and put it back in the normal flow of checks

dg0yt commented 3 years ago

It needs to be patched in vcpkg. However, it needs a contributor with an Android toolchain, space and time.

JackBoosY commented 2 years ago

This issue hasn’t been updated in 3 month, if it is still an issue, please reopen this issue.

reynoldsbd commented 2 years ago

I was able to get a local repro of this issue pretty easily:

> $Env:ANDROID_NDK_HOME = "$HOME\AppData\Local\Android\Sdk\ndk\22.1.7171670\"
> .\vcpkg.exe install opencv --triplet=x64-android

<snip>

-- Configuring x64-android
CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:128 (message):
    Command failed: ninja -v
    Working Directory: D:/Source/vcpkg/buildtrees/opencv4/x64-android-rel/vcpkg-parallel-configure
    Error code: 1
    See logs for more information:
      D:\Source\vcpkg\buildtrees\opencv4\config-x64-android-out.log

Call Stack (most recent call first):
  installed/x64-windows/share/vcpkg-cmake/vcpkg_cmake_configure.cmake:415 (vcpkg_execute_required_process)
  ports/opencv4/portfile.cmake:390 (vcpkg_cmake_configure)
  scripts/ports.cmake:145 (include)

<snip>

Relevant error message from the configure log:

CMake Error at D:/Source/vcpkg/installed/x64-android/share/zlib/vcpkg-cmake-wrapper.cmake:5 (message):
  Broken installation of vcpkg port zlib
Call Stack (most recent call first):
  D:/Source/vcpkg/scripts/buildsystems/vcpkg.cmake:743 (include)
  cmake/OpenCVFindLibsGrfmt.cmake:14 (find_package)
  CMakeLists.txt:724 (include)

I was able to successfully build by simply removing the if(ANDROID) hacks from OpenCVFindLibsGrfmt.cmake. Opening a PR now...