xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
9.82k stars 774 forks source link

unable to use vcpkg package even though it has been found by xmake #1490

Closed PucklaJ closed 3 years ago

PucklaJ commented 3 years ago

Describe the bug

I want to use azure-kinect-sensor-sdk from vcpkg with xmake. I installed azure-kinect-sensor-sdk:x64-windows and azure-kinect-sensor-sdk:x64-windows-static from vcpkg, but when trying to use it via add_requires("vcpkg:azure-kinect-sensor-sdk") xmake finds the correct vcpkg package, but then immediatly after fails to find it again.

Expected behavior

xmake should find the x64-windows-static version

Error output

checking for platform ... windows
checking for architecture ... x64
checking for vswhere.exe ... C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe
checking for cl.exe ... C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\bin\HostX64\x64\cl.exe
checking for Microsoft Visual Studio (x64) version ... 2019
checkinfo: cannot runv(dmd.exe --version), No such file or directory
checking for dmd ... no
checkinfo: cannot runv(ldc2.exe --version), No such file or directory
checking for ldc2 ... no
checking for gdc ... ok
checkinfo: cannot runv(zig.exe version), No such file or directory
checking for zig ... no
checkinfo: cannot runv(zig.exe version), No such file or directory
checking for zig ... no
checkinfo: cannot runv(unzip.exe -v), No such file or directory
checking for unzip ... no
checking for 7z ... C:\Users\jopu0\xmake\winenv\bin\7z
checking for git ... ok
checkinfo: cannot runv(gzip.exe --version), No such file or directory
checking for gzip ... no
vs_runtime MT MD
vs_runtime MT MD
vs_runtime MT MD
finding libsdl from xmake ..
checking for xmake::libsdl ... no
finding libsdl from vcpkg ..
finding libsdl from conan ..
finding libsdl from pkgconfig ..
checkinfo: cannot runv(pkg-config.exe --version), No such file or directory
checking for pkg-config ... no
finding libsdl from system ..
checking for libsdl ... no
finding libsdl_gfx from xmake ..
checking for xmake::libsdl_gfx ... libsdl_gfx 1.0.4
finding libsdl_image from xmake ..
checking for xmake::libsdl_image ... libsdl_image 2.0.5
finding brynet from xmake ..
checking for xmake::brynet ... brynet 1.0.9
checking for cmake ... no
checking for cmake ... C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake
checkinfo: cannot runv(cmake.exe --version), No such file or directory
checking for cmake ... no
checking for cmake ... C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake
finding nana from xmake ..
checking for xmake::nana ... nana 1.7.4
finding azure-kinect-sensor-sdk from vcpkg ..
checking for vcpkg::azure-kinect-sensor-sdk ... no
installing azure-kinect-sensor-sdk from vcpkg ..
checking for vcpkg ... C:\Users\jopu0\vcpkg\vcpkg
C:\Users\jopu0\vcpkg\vcpkg install azure-kinect-sensor-sdk:x64-windows-static --debug
[DEBUG] Feature flag 'binarycaching' unset
[DEBUG] Feature flag 'manifests' unset
[DEBUG] Feature flag 'compilertracking' unset
[DEBUG] Feature flag 'registries' unset
[DEBUG] Feature flag 'versions' unset
[DEBUG] BuiltinRegistry initialized with: ""
[DEBUG] Using vcpkg-root: C:\Users\jopu0\vcpkg
[DEBUG] Using installed-root: C:\Users\jopu0\vcpkg\installed
[DEBUG] BuiltinRegistry initialized with: ""
[DEBUG] Using buildtrees-root: C:\Users\jopu0\vcpkg\buildtrees
[DEBUG] Using downloads-root: C:\Users\jopu0\vcpkg\downloads
[DEBUG] Using packages-root: C:\Users\jopu0\vcpkg\packages
[DEBUG] Using scripts-root: C:\Users\jopu0\vcpkg\scripts
[DEBUG] Using ports-root: C:\Users\jopu0\vcpkg\ports
[DEBUG] Using versions-root: C:\Users\jopu0\vcpkg\versions
[DEBUG] Default binary cache path is: C:\Users\jopu0\AppData\Local\vcpkg\archives
Computing installation plan...
The following packages are already installed:
    azure-kinect-sensor-sdk[core]:x64-windows-static -> 1.4.1
Package azure-kinect-sensor-sdk:x64-windows-static is already installed

Total elapsed time: 1.016 ms

The package azure-kinect-sensor-sdk:x64-windows-static provides CMake targets:

    find_package(k4a CONFIG REQUIRED)
    target_link_libraries(main PRIVATE k4a::k4a)

    find_package(k4arecord CONFIG REQUIRED)
    target_link_libraries(main PRIVATE k4a::k4arecord)

[DEBUG] C:\A\1\70\s\src\vcpkg\install.cpp(1081)
[DEBUG] Exiting after 54759 us (49302 us)
finding azure-kinect-sensor-sdk from vcpkg ..
checking for vcpkg::azure-kinect-sensor-sdk ... no

error: ...\modules\private\action\require\impl\actions\install.lua:194: fetch vcpkg::azure-kinect-sensor-sdk-latest failed!
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:796]: in function 'raiselevel'
    [@programdir\core\sandbox\modules\utils.lua:181]: in function 'assert'
    [...\modules\private\action\require\impl\actions\install.lua:194]:
    [C]: in function 'trycall'
    [@programdir\core\sandbox\modules\try.lua:121]: in function 'try'
    [...\modules\private\action\require\impl\actions\install.lua:137]: in function 'action_install'
    [...modules\private\action\require\impl\install_packages.lua:350]: in function 'jobfunc'
    [@programdir\modules\private\async\runjobs.lua:201]:
    [C]: in function 'trycall'
    [@programdir\core\sandbox\modules\try.lua:121]: in function 'try'
    [@programdir\modules\private\async\runjobs.lua:194]: in function 'cotask'
    [@programdir\core\base\scheduler.lua:365]:

  => install vcpkg::azure-kinect-sensor-sdk latest .. failed
error: @programdir\modules\private\async\runjobs.lua:225: ...\modules\private\action\require\impl\actions\install.lua:253: install failed!
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:796]: in function 'raise'
    [...\modules\private\action\require\impl\actions\install.lua:253]: in function 'catch'
    [@programdir\core\sandbox\modules\try.lua:127]: in function 'try'
    [...\modules\private\action\require\impl\actions\install.lua:137]: in function 'action_install'
    [...modules\private\action\require\impl\install_packages.lua:350]: in function 'jobfunc'
    [@programdir\modules\private\async\runjobs.lua:201]:
    [C]: in function 'trycall'
    [@programdir\core\sandbox\modules\try.lua:121]: in function 'try'
    [@programdir\modules\private\async\runjobs.lua:194]: in function 'cotask'
    [@programdir\core\base\scheduler.lua:365]:

stack traceback:
        [C]: in function 'error'
        @programdir\core\base\os.lua:796: in function 'raise'
        @programdir\modules\private\async\runjobs.lua:225: in function 'catch'
        @programdir\core\sandbox\modules\try.lua:127: in function 'try'
        @programdir\modules\private\async\runjobs.lua:194: in function 'cotask'
        @programdir\core\base\scheduler.lua:365: in function <@programdir\core\base\scheduler.lua:362>

Related Environment

Please provide compiling and running environment information:

Additional context

vcpkg list output:

azure-c-shared-utility:x64-windows                 2020-12-09       Azure C SDKs common code
azure-c-shared-utility:x64-windows-static          2020-12-09       Azure C SDKs common code
azure-kinect-sensor-sdk:x64-windows                1.4.1            Azure Kinect SDK is a cross platform (Linux and ...
azure-kinect-sensor-sdk:x64-windows-static         1.4.1            Azure Kinect SDK is a cross platform (Linux and ...
azure-macro-utils-c:x64-windows                    2020-06-17#2     A library of macros for the Azure IoT SDK Suite
azure-macro-utils-c:x64-windows-static             2020-06-17#2     A library of macros for the Azure IoT SDK Suite
cjson:x64-windows                                  2019-11-30-1     Ultralightweight JSON parser in ANSI C
cjson:x64-windows-static                           2019-11-30-1     Ultralightweight JSON parser in ANSI C
ebml:x64-windows                                   1.4.0            a C++ library to parse EBML files
ebml:x64-windows-static                            1.4.0            a C++ library to parse EBML files
fmt:x64-windows                                    7.1.3#2          Formatting library for C++. It can be used as a ...
fmt:x64-windows-static                             7.1.3#2          Formatting library for C++. It can be used as a ...
glfw3:x64-windows                                  3.3.2#1          GLFW is a free, Open Source, multi-platform libr...
glfw3:x64-windows-static                           3.3.2#1          GLFW is a free, Open Source, multi-platform libr...
gtest:x64-windows                                  1.10.0#4         GoogleTest and GoogleMock testing frameworks.
gtest:x64-windows-static                           1.10.0#4         GoogleTest and GoogleMock testing frameworks.
imgui:x64-windows                                  1.82             Bloat-free Immediate Mode Graphical User interfa...
imgui:x64-windows-static                           1.82             Bloat-free Immediate Mode Graphical User interfa...
libjpeg-turbo:x64-windows                          2.0.6            libjpeg-turbo is a JPEG image codec that uses SI...
libjpeg-turbo:x64-windows-static                   2.0.6            libjpeg-turbo is a JPEG image codec that uses SI...
libsoundio:x64-windows                             2.0.0-3          libsoundio is C library providing cross-platform...
libsoundio:x64-windows-static                      2.0.0-3          libsoundio is C library providing cross-platform...
libusb:x64-windows                                 1.0.24#3         a cross-platform library to access USB devices
libusb:x64-windows-static                          1.0.24#3         a cross-platform library to access USB devices
libyuv:x64-windows                                 fec9121#3        libyuv is an open source project that includes Y...
libyuv:x64-windows-static                          fec9121#3        libyuv is an open source project that includes Y...
matroska:x64-windows                               1.6.2            a C++ library to parse Matroska files (.mkv and ...
matroska:x64-windows-static                        1.6.2            a C++ library to parse Matroska files (.mkv and ...
spdlog:x64-windows                                 1.8.0#2          Very fast, header only, C++ logging library
spdlog:x64-windows-static                          1.8.0#2          Very fast, header only, C++ logging library
umock-c:x64-windows                                2020-06-17-1     A pure C mocking library
umock-c:x64-windows-static                         2020-06-17-1     A pure C mocking library
vcpkg-cmake-config:x64-windows                     2021-02-26#1
vcpkg-cmake:x64-windows                            2021-02-28#1
SirLynix commented 3 years ago

In the meantime, I have a working kinect sensor sdk package here if you wish: https://github.com/SirLynix/obs-kinect/blob/master/xmake-repo/packages/k/k4a/xmake.lua

waruqi commented 3 years ago

you can add some print logs in your local script and debug it. https://github.com/xmake-io/xmake/blob/master/xmake/modules/package/manager/vcpkg/find_package.lua

then add -c to force to find package for each time.

xmake f -c
PucklaJ commented 3 years ago

This was unexpected @SirLynix . Thank you, I will try it out.

PucklaJ commented 3 years ago

When adding the VCPKG_ROOT environment variable I fixed the issue.

But I found another bug. When vcpkgdir is inserted into the detectcache and the directory has not been found, then the value in the cache is false. In this if clause false == nil will be false, which means that xmake will never look for the directory again.

PucklaJ commented 3 years ago

Maybe this line should be changed to this:

detectcache:set("detect.sdks.find_vcpkgdir", vcpkgdir or nil)
waruqi commented 3 years ago

Maybe this line should be changed to this:

detectcache:set("detect.sdks.find_vcpkgdir", vcpkgdir or nil)

This is not a bug. Even if it is not found, the failed result will be cached as false to avoid repeated finding. If you want to force to re-find it every time, you can pass the -c parameter to ignore the cache. xmake f -c

PucklaJ commented 3 years ago

Even if it is not found, the failed result will be cached as false to avoid repeated finding

Oh yes. This makes sense. So this issue can be closed now.