diff options
| author | ruki <[email protected]> | 2024-07-13 19:42:15 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-07-13 19:42:15 +0800 |
| commit | 1a671d05a06450fc7e43c8ea6ac0db972457c492 (patch) | |
| tree | a4fb69fcecdf5ab5e2607ffdbdf733884f335528 | |
| parent | ded9e3e9b5fde19d546dfb336800c0f993240361 (diff) | |
improve conan to support vs 17.1 #5338
| -rw-r--r-- | xmake/modules/package/manager/conan/v2/install_package.lua | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/xmake/modules/package/manager/conan/v2/install_package.lua b/xmake/modules/package/manager/conan/v2/install_package.lua index 5d2bdd384..379de3296 100644 --- a/xmake/modules/package/manager/conan/v2/install_package.lua +++ b/xmake/modules/package/manager/conan/v2/install_package.lua @@ -150,13 +150,18 @@ function _conan_get_build_type(mode) end -- get compiler version -function _conan_get_compiler_version(name, program) +function _conan_get_compiler_version(name, opt) + opt = opt or {} local version - local result = find_tool(name, {program = program, version = true}) + local result = find_tool(name, {program = opt.program, version = true, envs = opt.envs}) if result and result.version then local v = semver.try_parse(result.version) if v then - version = v:major() + if name == "cl" then + version = tostring(v:major()) .. tostring(v:minor()):sub(1, 1) + else + version = tostring(v:major()) + end end end return version @@ -170,16 +175,15 @@ function _conan_generate_compiler_profile(profile, configs, opt) local runtimes = configs.runtimes if plat == "windows" then -- https://github.com/conan-io/conan/blob/353c63b16c31c90d370305b5cbb5dc175cf8a443/conan/tools/microsoft/visual.py#L13 - local vsvers = {["2022"] = "193", - ["2019"] = "192", - ["2017"] = "191", - ["2015"] = "190", - ["2013"] = "180", - ["2012"] = "170"} - local vs = assert(config.get("vs"), "vs not found!") + -- https://github.com/xmake-io/xmake/issues/5338 + local msvc = toolchain.load("msvc", {plat = plat, arch = arch}) + assert(msvc:check(), "vs not found!") + local vs = assert(msvc:config("vs"), "vs not found!") profile:print("compiler=msvc") - profile:print("compiler.version=" .. assert(vsvers[vs], "unknown msvc version!")) - -- @see https://github.com/conan-io/conan/issues/12387 + local version = _conan_get_compiler_version("cl", {envs = msvc:runenvs()}) + if version then + profile:print("compiler.version=" .. version) + end -- @see https://github.com/conan-io/conan/issues/12387 if tonumber(vs) >= 2015 then profile:print("compiler.cppstd=14") end @@ -216,7 +220,7 @@ function _conan_generate_compiler_profile(profile, configs, opt) profile:print("compiler.libcxx=" .. runtimes) end local program, toolname = ndk:tool("cc") - local version = _conan_get_compiler_version(toolname, program) + local version = _conan_get_compiler_version(toolname, {program = program}) profile:print("compiler=" .. toolname) if version then profile:print("compiler.version=" .. version) @@ -235,7 +239,7 @@ function _conan_generate_compiler_profile(profile, configs, opt) libcxx = "libc++" end profile:print("compiler.libcxx=" .. libcxx) - local version = _conan_get_compiler_version(toolname, program) + local version = _conan_get_compiler_version(toolname, {program = program}) if version then profile:print("compiler.version=" .. version) end @@ -333,3 +337,4 @@ function main(conan, name, opt) -- leave build directory os.cd(oldir) end + |
