microsoft / vcpkg

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

[libavif] Can't use static build after 1.1.1 update #42112

Open jdpurcell opened 6 days ago

jdpurcell commented 6 days ago

CMakeLists.txt:

cmake_minimum_required(VERSION 3.10)
project(HelloWorld)
find_package(libavif CONFIG REQUIRED)
add_executable(HelloWorld helloworld.cpp)
target_link_libraries(HelloWorld PRIVATE avif)

helloworld.cpp:

#include <avif/avif.h>
#include <iostream>

int main() {
    const char* version = avifVersion();
    std::cout << "libavif version: " << version << std::endl;
    return 0;
}

vcpkg.json:

{
  "builtin-baseline": "e60236ee051183f1122066bee8c54a0b47c43a60",
  "overrides": [
    {
      "name": "libavif",
      "version": "1.1.1"
    }
  ],
  "dependencies": [
    {
      "name": "libavif",
      "features": [
        "dav1d"
      ]
    }
  ]
}

When trying to build in macOS results in the following error: helloworld.cpp:1:10: fatal error: 'avif/avif.h' file not found. I believe the same would happen in Linux, but not Windows (didn't try w/ this minimal project but that's what I was seeing with a much larger project that uses libavif), with the difference presumably being that the library is static in macOS/Linux. If the override in vcpkg.json is set to version 1.0.4#2, it works fine.

Comparing the CMake files in vcpkg_installed/arm64-osx/share/libavif from version 1.0.4#2 to 1.1.1 reveals that the following section disappeared:

set_target_properties(avif PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
  INTERFACE_LINK_LIBRARIES "\$<\$<NOT:\$<CONFIG:DEBUG>>:${VCPKG_IMPORT_PREFIX}/lib/libdav1d.a>;\$<\$<CONFIG:DEBUG>:${VCPKG_IMPORT_PREFIX}/debug/lib/libdav1d.a>;\$<LINK_ONLY:yuv>;\$<LINK_ONLY:m>;\$<LINK_ONLY:Threads::Threads>"
)
dg0yt commented 5 days ago

This is easily verified. The last update dropped a cmake config patch, but upstream still doesn't export include dirs.