From a3b4b157db9eab2a98929429952e9ec4b05a9ebf Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 3 May 2023 00:39:38 +0800 Subject: improve conan2 for macos/clang --- .../package/manager/conan/v2/install_package.lua | 25 ++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/xmake/modules/package/manager/conan/v2/install_package.lua b/xmake/modules/package/manager/conan/v2/install_package.lua index 82e53aad3..399665136 100644 --- a/xmake/modules/package/manager/conan/v2/install_package.lua +++ b/xmake/modules/package/manager/conan/v2/install_package.lua @@ -187,10 +187,27 @@ function _conan_generate_compiler_profile(profile, configs, opt) profile:print("os.api_level=" .. ndk_sdkver) end else - profile:print("compiler=gcc") - profile:print("compiler.cppstd=gnu17") - profile:print("compiler.libcxx=libstdc++11") - profile:print("compiler.version=11") + local program, toolname = platform.tool("cc", plat, arch) + if toolname == "gcc" or toolname == "clang" then + local version + local gcc = find_tool(toolname, {program = program, version = true}) + if gcc and gcc.version then + local v = semver.try_parse(gcc.version) + if v then + version = v:major() + end + end + profile:print("compiler=" .. toolname) + profile:print("compiler.cppstd=gnu17") + if toolname == "clang" then + profile:print("compiler.libcxx=libc++") + else + profile:print("compiler.libcxx=libstdc++11") + end + if version then + profile:print("compiler.version=" .. version) + end + end end end -- cgit v1.3.1