xmake icon indicating copy to clipboard operation
xmake copied to clipboard

Bug: add_deps vcpkg dependencies are not propagated to cmake packages

Open ethindp opened this issue 9 months ago • 3 comments

Xmake Version

2.9.8+HEAD.13fc39238

Operating System Version and Architecture

Windows 10 21H2 (AMD64) build 19044.5487

Describe Bug

When you add a custom package that then depends on a package in vcpkg or some other package manager repo, other than the system one, that package is not propagated downstream to CMake. That, in turn, causes the package to not be found by CMake, even though it was specified in add_deps. Attempting to explicitly set the ROOT_DIR option (e.g., PKGNAME_ROOT_DIR) with package:dep("vcpkg::pkgname"):installdir() or similar doesn't work, but instead yields a non-existent path which is created upon calling that function. I have even gone as far as force-setting the cmake_toolchain_file option, and VCPKG_TARGET_TRIPLET, but CMake still can't find dependencies.

Expected Behavior

Ideally, packages (regardless of how they were installed) should be found by CMake or any other build system.

Project Configuration

This snippet:

add_rules("mode.debug", "mode.release")
package("tgui")
    set_description("Cross-platform modern c++ GUI")
    set_homepage("https://tgui.eu")
    set_license("zlib")
    add_urls("https://github.com/texus/TGUI.git")
    add_versions("1.7.0", "6d76a435fb649e0dc597c320a29d7f00f2525f32")
    add_deps("vcpkg::sdl3", "vcpkg::sdl3-ttf", "cmake")
    on_install(function(package)
        import("detect.sdks.find_vcpkgdir")
        local configs = {}
        table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
        table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
        table.insert(configs, "-DTGUI_BACKEND=SDL_RENDERER")
        table.insert(configs, "-DTGUI_CXX_STANDARD=20")
        import("package.tools.cmake").install(package, configs)
    end)
package_end()

Should work when you:

add_requires("tgui")
...
add_packages("tgui")

But it does not

Additional Information and Error Logs

checking for Microsoft Visual Studio (x64) version ... 2022 checking for Microsoft C/C++ Compiler (x64) version ... 19.43.34808 warning: .\xmake.lua:23: cannot match add_files("src*.c") in target(quakeng) checking for cl.exe ... C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.43.34808\bin\HostX64\x64\cl.exe checking for Microsoft Visual Studio (x64) version ... 2022 checking for Microsoft C/C++ Compiler (x64) version ... 19.43.34808 checkinfo: cannot runv(nim.exe --version), No such file or directory checking for nim ... no checkinfo: cannot runv(nim.exe --version), No such file or directory checking for nim ... no checking for git ... ok checkinfo: BusyBox v1.38.0-FRP-5579-g5749feb35 (2025-02-08 12:49:06 UTC)

Usage: gzip [-cfkdt123456789] [FILE]...

Compress FILEs (or stdin)

    -1..9   Compression level
    -d      Decompress
    -c      Write to stdout
    -f      Force
    -k      Keep input files
    -t      Test integrity

c:\users\username\scoop\apps\busybox\current\busybox.exe: unknown option -- version

checkinfo: BusyBox v1.38.0-FRP-5579-g5749feb35 (2025-02-08 12:49:06 UTC)

Usage: gzip [-cfkdt123456789] [FILE]...

Compress FILEs (or stdin)

    -1..9   Compression level
    -d      Decompress
    -c      Write to stdout
    -f      Force
    -k      Keep input files
    -t      Test integrity

c:\users\username\scoop\apps\busybox\current\busybox.exe: unknown option -- version

checking for gzip ... no checking for 7z ... c:\users\username\scoop\apps\xmake\current\winenv\bin\7z git rev-parse HEAD checking for cmake ... no checking for cmake ... no checking for cmake ... no 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\2022\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake finding fmt from xmake .. checking for xmake::fmt ... fmt 11.1.3 finding scnlib from vcpkg .. checking for vcpkg::scnlib ... scnlib 4.0.1 finding gtl from vcpkg .. checking for vcpkg::gtl ... gtl 1.2.0 finding tiny-optional from xmake .. checking for xmake::tiny-optional ... tiny-optional v1.3.1 finding uni_algo from xmake .. checking for xmake::uni_algo ... uni_algo v1.2.0 finding fast-float from vcpkg .. checking for vcpkg::fast-float ... fast-float 8.0.0 finding magic_enum from xmake .. checking for xmake::magic_enum ... magic_enum v0.9.7 finding sdl3 from vcpkg .. checking for pkg-config ... ok checking for vcpkg::sdl3 ... sdl3 3.2.6 finding sdl3-ttf from vcpkg .. checking for vcpkg::sdl3-ttf ... sdl3-ttf 3.1.0 finding quill from xmake .. checking for xmake::quill ... quill v8.0.0 finding tgui from xmake .. checking for xmake::tgui ... no finding tgui from vcpkg .. finding tgui from conan .. finding tgui from system .. checking for cl.exe ... C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.43.34808\bin\HostX64\x64\cl.exe checking for the c compiler (cc) ... cl.exe

"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.43.34808\bin\HostX64\x64\cl.exe" -c -nologo -Foc:\users\usernameP~1\AppData\Local\Temp.xmake\250304_30FD302BC85B4E008256150AB564A870.o c:\users\usernameP~1\AppData\Local\Temp.xmake\250304_775FB00633BC4F66BF87D39CCDE5CF30.c checking for cl.exe ... C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.43.34808\bin\HostX64\x64\cl.exe checking for the c++ compiler (cxx) ... cl.exe checking for link.exe ... C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.43.34808\bin\HostX64\x64\link.exe checking for the linker (ld) ... link.exe "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.43.34808\bin\HostX64\x64\link.exe" -nologo -dynamicbase -nxcompat -machine:x64 tgui.lib -out:c:\users\usernameP~1\AppData\Local\Temp.xmake\250304_30FD302BC85B4E008256150AB564A870.b c:\users\usernameP~1\AppData\Local\Temp.xmake\250304_30FD302BC85B4E008256150AB564A870.o checking for c links(tgui) checking for c snippet(find_package/tgui) checkinfo: ...gramdir\core\sandbox\modules\import\core\tool\linker.lua:75: @programdir\modules\core\tools\link.lua:175: LINK : fatal error LNK1181: cannot open input file 'tgui.lib'

stack traceback: [C]: in function 'error' [@programdir\core\base\os.lua:1075]: [@programdir\modules\core\tools\link.lua:175]: in function 'catch' [@programdir\core\sandbox\modules\try.lua:123]: in function 'try' [@programdir\modules\core\tools\link.lua:151]: [C]: in function 'xpcall' [@programdir\core\base\utils.lua:246]: [@programdir\core\tool\linker.lua:232]: in function 'link' [...gramdir\core\sandbox\modules\import\core\tool\linker.lua:73]: in function 'link' [@programdir\modules\lib\detect\check_cxsnippets.lua:249]: [C]: in function 'xpcall' [@programdir\core\base\utils.lua:246]: in function 'trycall' [@programdir\core\sandbox\modules\try.lua:117]: in function 'try' [@programdir\modules\lib\detect\check_cxsnippets.lua:237]: [@programdir\modules\package\manager\system\find_package.lua:73]: [@programdir\modules\package\manager\find_package.lua:86]: in function '_find_package_with_builtin_rule' [@programdir\modules\package\manager\find_package.lua:132]: in function '_find_package' [@programdir\modules\package\manager\find_package.lua:196]: [@programdir\modules\lib\detect\find_package.lua:86]: [@programdir\core\package\package.lua:1944]: in function '_fetch_library' [@programdir\core\package\package.lua:2114]: in function 'fetch' [...modules\private\action\require\impl\install_packages.lua:354]: in function 'jobfunc' [@programdir\modules\async\runjobs.lua:241]: [C]: in function 'xpcall' [@programdir\core\base\utils.lua:246]: in function 'trycall' [@programdir\core\sandbox\modules\try.lua:117]: in function 'try' [@programdir\modules\async\runjobs.lua:224]: in function 'cotask' [@programdir\core\base\scheduler.lua:406]:

checking for tgui ... no note: install or modify (m) these packages (pass -y to skip confirm)? -> tgui 1.7.0 [runtimes:"MT", license:zlib] please input: y (y/n/m) yes checking for ping ... ok pinging the host(github.com) ... 95 ms git -c core.fsmonitor=false clean -d -f -x Removing build_528241ab/ git -c core.fsmonitor=false reset --hard HEAD is now at 6d76a43 Updated version to 1.7 checkinfo: cannot runv(pkgconf.exe --version), No such file or directory checking for pkgconf ... no checkinfo: cannot runv(pkgconf.exe --version), No such file or directory checking for pkgconf ... no checking for pkg-config ... ok 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\2022\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake checking for link.exe ... C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.43.34808\bin\HostX64\x64\link.exe checking for the static library archiver (ar) ... link.exe checking for link.exe ... C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.43.34808\bin\HostX64\x64\link.exe checking for the shared library linker (sh) ... link.exe checkinfo: cannot runv(pkgconf.exe --version), No such file or directory checking for pkgconf ... no checkinfo: cannot runv(pkgconf.exe --version), No such file or directory checking for pkgconf ... no checking for pkg-config ... ok C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DTGUI_BACKEND=SDL_RENDERER -DTGUI_CXX_STANDARD=20 "-DCMAKE_INSTALL_PREFIX=C:\Users\username\AppData\Local\.xmake\packages\t\tgui\1.7.0\528241ab25dc46e1a181873a2ea06b60" -DCMAKE_INSTALL_LIBDIR:PATH=lib -G "Visual Studio 17 2022" -A x64 -DCMAKE_GENERATOR_TOOLSET=v143 -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded "-DCMAKE_COMPILE_PDB_OUTPUT_DIRECTORY=C:/Users/username/AppData/Local/.xmake/cache/packages/2503/t/tgui/1.7.0/source/tgui/build_528241ab/pdb" "-DCMAKE_PDB_OUTPUT_DIRECTORY=C:/Users/username/AppData/Local/.xmake/cache/packages/2503/t/tgui/1.7.0/source/tgui/build_528241ab/pdb" "-DCMAKE_C_FLAGS_RELEASE=/DWIN32 /D_WINDOWS /O2 /Ob2 /DNDEBUG -MT" "-DCMAKE_STATIC_LINKER_FLAGS_RELEASE=/machine:x64 -nodefaultlib:msvcrt.lib" "-DCMAKE_SHARED_LINKER_FLAGS_RELEASE=/machine:x64 /INCREMENTAL:NO -nodefaultlib:msvcrt.lib" "-DCMAKE_MODULE_LINKER_FLAGS_RELEASE= -nodefaultlib:msvcrt.lib" "-DCMAKE_EXE_LINKER_FLAGS_RELEASE=/machine:x64 /INCREMENTAL:NO -nodefaultlib:msvcrt.lib" "-DCMAKE_CXX_FLAGS_RELEASE=/DWIN32 /D_WINDOWS /GR /EHsc /O2 /Ob2 /DNDEBUG -MT" "C:\Users\username\AppData\Local\.xmake\cache\packages\2503\t\tgui\1.7.0\source\tgui" -- Selecting Windows SDK version 10.0.26100.0 to target Windows 10.0.19044. -- The CXX compiler identification is MSVC 19.42.34438.0 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.42.34433/bin/HostX64/x64/cl.exe - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done CMake Error at cmake/Dependencies.cmake:173 (message): CMake couldn't find SDL2 or SDL3.

For SDL3, set SDL3_DIR to the directory containing either SDL3Config.cmake or sdl3-config.cmake

For SDL2, set SDL2_DIR to the directory containing either SDL2Config.cmake or sdl2-config.cmake if such files exist

For SDL2 < 2.24 on Windows or macOS, for SDL files downloaded from github.com/libsdl-org/SDL/releases, set SDL2_PATH to the folder containing the 'include' and 'lib' directories, or the SDL2.framework file.

Call Stack (most recent call first): cmake/Dependencies.cmake:270 (tgui_find_dependency_sdl) src/Backend/CMakeLists.txt:180 (tgui_add_dependency_sdl) src/CMakeLists.txt:517 (include)

-- Configuring incomplete, errors occurred! error: @programdir\core\sandbox\modules\os.lua:378: execv(C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DTGUI_BACKEND=SDL_RENDERER -DTGUI_CXX_STANDARD=20 "-DCMAKE_INSTALL_PREFIX=C:\Users\username\AppData\Local\.xmake\packages\t\tgui\1.7.0\528241ab25dc46e1a181873a2ea06b60" -DCMAKE_INSTALL_LIBDIR:PATH=lib -G "Visual Studio 17 2022" -A x64 -DCMAKE_GENERATOR_TOOLSET=v143 -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded "-DCMAKE_COMPILE_PDB_OUTPUT_DIRECTORY=C:/Users/username/AppData/Local/.xmake/cache/packages/2503/t/tgui/1.7.0/source/tgui/build_528241ab/pdb" "-DCMAKE_PDB_OUTPUT_DIRECTORY=C:/Users/username/AppData/Local/.xmake/cache/packages/2503/t/tgui/1.7.0/source/tgui/build_528241ab/pdb" "-DCMAKE_C_FLAGS_RELEASE=/DWIN32 /D_WINDOWS /O2 /Ob2 /DNDEBUG -MT" "-DCMAKE_STATIC_LINKER_FLAGS_RELEASE=/machine:x64 -nodefaultlib:msvcrt.lib" "-DCMAKE_SHARED_LINKER_FLAGS_RELEASE=/machine:x64 /INCREMENTAL:NO -nodefaultlib:msvcrt.lib" "-DCMAKE_MODULE_LINKER_FLAGS_RELEASE= -nodefaultlib:msvcrt.lib" "-DCMAKE_EXE_LINKER_FLAGS_RELEASE=/machine:x64 /INCREMENTAL:NO -nodefaultlib:msvcrt.lib" "-DCMAKE_CXX_FLAGS_RELEASE=/DWIN32 /D_WINDOWS /GR /EHsc /O2 /Ob2 /DNDEBUG -MT" "C:\Users\username\AppData\Local\.xmake\cache\packages\2503\t\tgui\1.7.0\source\tgui") failed(1) stack traceback: [C]: in function 'error' [@programdir\core\base\os.lua:1075]: [@programdir\core\sandbox\modules\os.lua:378]: [@programdir\core\sandbox\modules\os.lua:291]: in function 'vrunv' [@programdir\modules\package\tools\cmake.lua:1318]: in function 'configure' [@programdir\modules\package\tools\cmake.lua:1360]: in function 'install' [.\xmake.lua:16]: in function 'script' [...dir\modules\private\action\require\impl\utils\filter.lua:114]: in function 'call' [...\modules\private\action\require\impl\actions\install.lua:452]:

=> install tgui 1.7.0 .. failed error: @programdir\core\main.lua:329: @programdir\core\sandbox\modules\import\core\base\task.lua:65: @programdir\modules\async\runjobs.lua:325: ...\modules\private\action\require\impl\actions\install.lua:561: install failed! stack traceback: [C]: in function 'error' [@programdir\core\base\os.lua:1075]: [...\modules\private\action\require\impl\actions\install.lua:561]: in function 'catch' [@programdir\core\sandbox\modules\try.lua:123]: in function 'try' [...\modules\private\action\require\impl\actions\install.lua:419]: [...modules\private\action\require\impl\install_packages.lua:510]: in function 'jobfunc' [@programdir\modules\async\runjobs.lua:241]:

stack traceback: [C]: in function 'error' @programdir\core\base\os.lua:1075: in function 'os.raiselevel' (...tail calls...) @programdir\core\main.lua:329: in upvalue 'cotask' @programdir\core\base\scheduler.lua:406: in function <@programdir\core\base\scheduler.lua:399>

ethindp avatar Mar 04 '25 20:03 ethindp

It is not supported. Only packages in the xmake-repo repository configured in add_deps can be found by cmake. And there is also a certain failure rate.

waruqi avatar Mar 05 '25 01:03 waruqi

Is there any way we can add support for this?

ethindp avatar Mar 05 '25 01:03 ethindp

use sdl3 in xmake-repo

waruqi avatar Mar 05 '25 02:03 waruqi