xmake-io / xmake

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

compiler.version not set for conan package with MSVC #5659

Open richard-sim opened 1 month ago

richard-sim commented 1 month ago

Xmake Version

2.9.5

Operating System Version and Architecture

Windows 11

Describe Bug

The conan profile is not setting compiler.version in xmake 2.9.5 for MSVC 2022. I'm running Conan 2.7.1, and vcvars.bat has been called so MSVC is in the PATH.

Trying the example from the docs:

add_requires("conan::zlib/1.2.11", {alias = "zlib"})

Results in:

zlib/1.2.11: Invalid: 'settings.compiler.version' value not defined

Explicitly specifying compiler.version works:

add_requires("conan::zlib/1.2.11", {
    alias = "zlib",
    configs = {
        settings = {
            "compiler.version=194"
        }
    }
})

Expected Behavior

XMake should be setting compiler.version.

Project Configuration

add_requires("conan::zlib/1.2.11", {alias = "zlib"})

target("deps", function ()
    set_kind("phony")
    add_packages("zlib")
end)

Additional Information and Error Logs

Failure output (directly from the docs):

======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=14
compiler.runtime=static
compiler.runtime_type=Release
os=Windows

Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=14
compiler.runtime=static
compiler.runtime_type=Release
os=Windows

======== Computing dependency graph ========
zlib/1.2.11: Not found in local cache, looking in remotes...
zlib/1.2.11: Checking remote: conancenter
zlib/1.2.11: Downloaded recipe revision fca992a7d96a1b92bd956caa8a97d18f
Graph root
    conanfile.txt: D:\dev\build-sys-eval\foobar\src\build\.conan\zlib\1.2.11\conanfile.txt
Requirements
    zlib/1.2.11#fca992a7d96a1b92bd956caa8a97d18f - Downloaded (conancenter)

======== Computing necessary packages ========
Requirements
    zlib/1.2.11#fca992a7d96a1b92bd956caa8a97d18f:9477f26cffb0bf802e63e917b7e915e0dae68b91 - Invalid
ERROR: There are invalid packages:
zlib/1.2.11: Invalid: 'settings.compiler.version' value not defined
error: execv(conan install . -g XmakeGenerator --profile:build=profile_build.txt --profile:host=profile_host.txt --build=missing) failed(6)
  => install conan::zlib/1.2.11 latest .. failed
error: install failed!

Successful output (manually specifying compiler.version):

======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=14
compiler.runtime=static
compiler.runtime_type=Release
compiler.version=194
os=Windows

Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=14
compiler.runtime=static
compiler.runtime_type=Release
os=Windows

======== Computing dependency graph ========
Graph root
    conanfile.txt: D:\dev\build-sys-eval\foobar\src\build\.conan\zlib\1.2.11\conanfile.txt
Requirements
    zlib/1.2.11#fca992a7d96a1b92bd956caa8a97d18f - Cache

======== Computing necessary packages ========
zlib/1.2.11: Main binary package '805d40acaa2400bcd79bfb1b96f313f2713000a5' missing
zlib/1.2.11: Checking 1 compatible configurations
zlib/1.2.11: Compatible configurations not found in cache, checking servers
zlib/1.2.11: '04a6c37bc15f9f5fab59d7085ff6c17c75bc552d': compiler.version=193
Requirements
    zlib/1.2.11#fca992a7d96a1b92bd956caa8a97d18f:805d40acaa2400bcd79bfb1b96f313f2713000a5 - Build
waruqi commented 1 month ago

you can debug here https://github.com/xmake-io/xmake/blob/583f8e6944130e157ec85b8a975a76733b3eb775/xmake/modules/package/manager/conan/v2/install_package.lua#L184-L187

then open a pr to fix it.

richard-sim commented 1 month ago

Thanks for the reply. I'll try and take a look, but I am unfamiliar with both lua and xmake - I'm just starting to evaluate it for a new project (which is why I'm going through the docs trying things out).

waruqi commented 1 month ago

and please use add_requires("zlib") as much as possible.

waruqi commented 3 weeks ago

It works for me.

compiler.runtime=static
compiler.runtime_type=Release
compiler.version=194
os=Windows
PS C:\Users\wangrunqing\Downloads\test91> xmake f -cvD
checking for platform ... windows
checking for architecture ... x64
checking for cl.exe ... C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe
checking for Microsoft Visual Studio (x64) version ... 2022
checking for Microsoft C/C++ Compiler (x64) version ... 19.41.33923
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(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: cannot runv(gzip.exe --version), No such file or directory
checking for gzip ... no
checking for 7z ... D:\projects\personal\xmake\xmake\winenv\bin\7z
finding zlib/1.2.11 from conan ..
checking for conan::zlib/1.2.11 ... no
note: install or modify (m) these packages (pass -y to skip confirm)?
in conan:
  -> conan::zlib/1.2.11 latest [runtimes:"MT"]
please input: y (y/n/m)

installing zlib/1.2.11 from conan ..
checking for conan ... ok
conan config install D:\projects\personal\xmake\xmake\scripts\conan
Copying file xmake_generator.py to C:\Users\wangrunqing\.conan2\extensions\generators
generate C:\Users\wangrunqing\Downloads\test91\build\.conan\zlib\1.2.11\conanfile.txt ..
conan install . -g XmakeGenerator --profile:build=profile_build.txt --profile:host=profile_host.txt --build=missing

======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=14
compiler.runtime=static
compiler.runtime_type=Release
compiler.version=194
os=Windows

Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=14
compiler.runtime=static
compiler.runtime_type=Release
compiler.version=194
os=Windows

======== Computing dependency graph ========
Graph root
    conanfile.txt: C:\Users\wangrunqing\Downloads\test91\build\.conan\zlib\1.2.11\conanfile.txt
Requirements
    zlib/1.2.11#fca992a7d96a1b92bd956caa8a97d18f - Cache

======== Computing necessary packages ========
zlib/1.2.11: Checking 1 compatible configurations
zlib/1.2.11: Compatible configurations not found in cache, checking servers
zlib/1.2.11: '04a6c37bc15f9f5fab59d7085ff6c17c75bc552d': compiler.version=193
Requirements
    zlib/1.2.11#fca992a7d96a1b92bd956caa8a97d18f:805d40acaa2400bcd79bfb1b96f313f2713000a5 - Build

======== Installing packages ========

-------- Installing package zlib/1.2.11 (1 of 1) --------
zlib/1.2.11: Building from source
zlib/1.2.11: Package zlib/1.2.11:805d40acaa2400bcd79bfb1b96f313f2713000a5
zlib/1.2.11: Copying sources to build folder
zlib/1.2.11: Building your package in C:\Users\wangrunqing\.conan2\p\b\zlibe89ffb4a04318\b
zlib/1.2.11: Calling generate()
zlib/1.2.11: Generators folder: C:\Users\wangrunqing\.conan2\p\b\zlibe89ffb4a04318\b\build\generators
zlib/1.2.11: CMakeToolchain generated: conan_toolchain.cmake
zlib/1.2.11: CMakeToolchain generated: C:\Users\wangrunqing\.conan2\p\b\zlibe89ffb4a04318\b\build\generators\CMakePresets.json
zlib/1.2.11: CMakeToolchain generated: C:\Users\wangrunqing\.conan2\p\b\zlibe89ffb4a04318\b\src\CMakeUserPresets.json
zlib/1.2.11: Generating aggregated env files
zlib/1.2.11: Generated aggregated env files: ['conanbuild.bat', 'conanrun.bat']
zlib/1.2.11: Calling build()
zlib/1.2.11: Apply patch (conan): separate static/shared builds, disable debug suffix, disable building examples
zlib/1.2.11: Apply patch (portability): fix condition for WIDECHAR usage
zlib/1.2.11: Running CMake.configure()
zlib/1.2.11: RUN: cmake -G "Visual Studio 17 2022" -DCMAKE_TOOLCHAIN_FILE="generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="C:/Users/wangrunqing/.conan2/p/b/zlibe89ffb4a04318/p" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" "C:/Users/wangrunqing/.conan2/p/b/zlibe89ffb4a04318/b/src"
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- Using Conan toolchain: C:/Users/wangrunqing/.conan2/p/b/zlibe89ffb4a04318/b/build/generators/conan_toolchain.cmake
-- Conan toolchain: CMAKE_GENERATOR_TOOLSET=v143
-- Conan toolchain: Setting CMAKE_MSVC_RUNTIME_LIBRARY=$<$<CONFIG:Release>:MultiThreaded>
-- Conan toolchain: Setting BUILD_SHARED_LIBS = OFF
-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19044.
-- The C compiler identification is MSVC 19.41.33923.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Preview/VC/Tools/MSVC/14.41.33923/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of off64_t
-- Check size of off64_t - failed
-- Looking for fseeko
-- Looking for fseeko - not found
-- Looking for unistd.h
-- Looking for unistd.h - not found
-- Renaming
--     C:/Users/wangrunqing/.conan2/p/b/zlibe89ffb4a04318/b/src/zconf.h
-- to 'zconf.h.included' because this file is included with zlib
-- but CMake generates it automatically in the build directory.
-- Configuring done (16.3s)
-- Generating done (0.1s)
-- Build files have been written to: C:/Users/wangrunqing/.conan2/p/b/zlibe89ffb4a04318/b/build

zlib/1.2.11: Running CMake.build()
zlib/1.2.11: RUN: cmake --build "C:\Users\wangrunqing\.conan2\p\b\zlibe89ffb4a04318\b\build" --config Release
适用于 .NET Framework MSBuild 版本 17.11.0-preview-24279-02+b963c24ef

  1>Checking Build System
  Building Custom Rule C:/Users/wangrunqing/.conan2/p/b/zlibe89ffb4a04318/b/src/CMakeLists.txt
  adler32.c
  compress.c
  crc32.c
  deflate.c
  gzclose.c
  gzlib.c
  gzread.c
  gzwrite.c
C:\Users\wangrunqing\.conan2\p\b\zlibe89ffb4a04318\b\src\gzread.c(319,17): warning C4267: “=”: 从“size_t”转换到“unsigned int”,可能丢失数据 [C:\Users\wangrunqing\.con
an2\p\b\zlibe89ffb4a04318\b\build\zlib.vcxproj]
  inflate.c
  infback.c
C:\Users\wangrunqing\.conan2\p\b\zlibe89ffb4a04318\b\src\gzread.c(400,11): warning C4267: “=”: 从“size_t”转换到“unsigned int”,可能丢失数据 [C:\Users\wangrunqing\.con
an2\p\b\zlibe89ffb4a04318\b\build\zlib.vcxproj]
  inftrees.c
  inffast.c
  trees.c
  uncompr.c
  zutil.c
C:\Users\wangrunqing\.conan2\p\b\zlibe89ffb4a04318\b\src\gzread.c(472,11): warning C4267: “=”: 从“size_t”转换到“int”,可能丢失数据 [C:\Users\wangrunqing\.conan2\p\b\z
libe89ffb4a04318\b\build\zlib.vcxproj]
C:\Users\wangrunqing\.conan2\p\b\zlibe89ffb4a04318\b\src\gzwrite.c(212,24): warning C4267: “=”: 从“size_t”转换到“unsigned int”,可能丢失数据 [C:\Users\wangrunqing\.co
nan2\p\b\zlibe89ffb4a04318\b\build\zlib.vcxproj]
C:\Users\wangrunqing\.conan2\p\b\zlibe89ffb4a04318\b\src\gzwrite.c(232,21): warning C4267: “=”: 从“size_t”转换到“unsigned int”,可能丢失数据 [C:\Users\wangrunqing\.co
nan2\p\b\zlibe89ffb4a04318\b\build\zlib.vcxproj]
C:\Users\wangrunqing\.conan2\p\b\zlibe89ffb4a04318\b\src\gzwrite.c(371,11): warning C4267: “=”: 从“size_t”转换到“int”,可能丢失数据 [C:\Users\wangrunqing\.conan2\p\b\
zlibe89ffb4a04318\b\build\zlib.vcxproj]
  zlib.vcxproj -> C:\Users\wangrunqing\.conan2\p\b\zlibe89ffb4a04318\b\build\Release\zlib.lib
  Building Custom Rule C:/Users/wangrunqing/.conan2/p/b/zlibe89ffb4a04318/b/src/CMakeLists.txt

zlib/1.2.11: Package '805d40acaa2400bcd79bfb1b96f313f2713000a5' built
zlib/1.2.11: Build folder C:\Users\wangrunqing\.conan2\p\b\zlibe89ffb4a04318\b\build
zlib/1.2.11: Generating the package
zlib/1.2.11: Packaging in folder C:\Users\wangrunqing\.conan2\p\b\zlibe89ffb4a04318\p
zlib/1.2.11: Calling package()
zlib/1.2.11: Running CMake.install()
zlib/1.2.11: RUN: cmake --install "C:\Users\wangrunqing\.conan2\p\b\zlibe89ffb4a04318\b\build" --config Release --prefix "C:/Users/wangrunqing/.conan2/p/b/zlibe89ffb4a04318/p"
-- Installing: C:/Users/wangrunqing/.conan2/p/b/zlibe89ffb4a04318/p/lib/zlib.lib
-- Installing: C:/Users/wangrunqing/.conan2/p/b/zlibe89ffb4a04318/p/include/zconf.h
-- Installing: C:/Users/wangrunqing/.conan2/p/b/zlibe89ffb4a04318/p/include/zlib.h

zlib/1.2.11: package(): Packaged 2 '.h' files: zconf.h, zlib.h
zlib/1.2.11: package(): Packaged 1 '.lib' file: zlib.lib
zlib/1.2.11: package(): Packaged 1 file: LICENSE
zlib/1.2.11: Created package revision f639919251869e1d221cb98443860ba8
zlib/1.2.11: Package '805d40acaa2400bcd79bfb1b96f313f2713000a5' created
zlib/1.2.11: Full package reference: zlib/1.2.11#fca992a7d96a1b92bd956caa8a97d18f:805d40acaa2400bcd79bfb1b96f313f2713000a5#f639919251869e1d221cb98443860ba8
zlib/1.2.11: Package folder C:\Users\wangrunqing\.conan2\p\b\zlibe89ffb4a04318\p
WARN: deprecated: Usage of deprecated Conan 1.X features that will be removed in Conan 2.X:
WARN: deprecated:     'cpp_info.names' used in: zlib/1.2.11

======== Finalizing install (deploy, generators) ========
conanfile.txt: Writing generators to C:\Users\wangrunqing\Downloads\test91\build\.conan\zlib\1.2.11
conanfile.txt: Generator 'XmakeGenerator' calling 'generate()'
XmakeGenerator: generating build info ..
zlib {
  Windows_x86_64_Release =
  {
    includedirs    = {"C:/Users/wangrunqing/.conan2/p/b/zlibe89ffb4a04318/p/include"},
    linkdirs       = {"C:/Users/wangrunqing/.conan2/p/b/zlibe89ffb4a04318/p/lib"},
    links          = {"zlib"},
    frameworkdirs  = {},
    frameworks     = {},
    syslinks       = {},
    defines        = {},
    cxxflags       = {},
    cflags         = {},
    shflags        = {},
    ldflags        = {},
    __bindirs      = {"C:/Users/wangrunqing/.conan2/p/b/zlibe89ffb4a04318/p/bin"},
    __resdirs      = {},
    __srcdirs      = {}
  }
}
{
  Windows_x86_64_Release =
  {
    includedirs    = {"C:/Users/wangrunqing/.conan2/p/b/zlibe89ffb4a04318/p/include"},
    linkdirs       = {"C:/Users/wangrunqing/.conan2/p/b/zlibe89ffb4a04318/p/lib"},
    links          = {"zlib"},
    frameworkdirs  = {},
    frameworks     = {},
    syslinks       = {},
    defines        = {},
    cxxflags       = {},
    cflags         = {},
    shflags        = {},
    ldflags        = {},
    __bindirs      = {"C:/Users/wangrunqing/.conan2/p/b/zlibe89ffb4a04318/p/bin"},
    __resdirs      = {},
    __srcdirs      = {},
    __dep_names    = {}
  }
}
conanfile.txt: Generating aggregated env files
conanfile.txt: Generated aggregated env files: ['conanbuild.bat', 'conanrun.bat']
Install finished successfully
finding zlib/1.2.11 from conan ..
checking for conan::zlib/1.2.11 ... zlib/1.2.11
{
  linkdirs = "C:/Users/wangrunqing/.conan2/p/b/zlibe89ffb4a04318/p/lib",
  sysincludedirs = "C:/Users/wangrunqing/.conan2/p/b/zlibe89ffb4a04318/p/include",
  libfiles = "C:\Users\wangrunqing\.conan2\p\b\zlibe89ffb4a04318\p\lib\zlib.lib",
  links = "zlib",
  static = true
}

  => install conan::zlib/1.2.11 latest .. ok
checking for link.exe ... C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\link.exe
checking for the linker (ld) ... link.exe
configure
{
    vs = 2022
    kind = static
    buildir = build
    host = windows
    proxy_pac = pac.lua
    mode = release
    theme = default
    clean = true
    arch = x64
    network = public
    plat = windows
    ndk_stdcxx = true
    ccache = true
}