diff options
| author | ruki <[email protected]> | 2024-01-24 22:39:30 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-01-25 12:09:59 +0800 |
| commit | fec77395b2f96bac0bde5cd4d79115fd6d4b377e (patch) | |
| tree | 7d7cec18c2db28b41c0c547a72dfed366a0b439b /xmake/modules | |
| parent | c6445c7e401b348c5ca8afce229a1f4f45e9cf61 (diff) | |
split c and c++ languages
Diffstat (limited to 'xmake/modules')
| -rw-r--r-- | xmake/modules/core/tools/clang.lua | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/xmake/modules/core/tools/clang.lua b/xmake/modules/core/tools/clang.lua index 0ca812f39..313728894 100644 --- a/xmake/modules/core/tools/clang.lua +++ b/xmake/modules/core/tools/clang.lua @@ -194,7 +194,8 @@ end -- make the runtime flag -- @see https://github.com/xmake-io/xmake/issues/3546 -function nf_runtime(self, runtime) +function nf_runtime(self, runtime, opt) + opt = opt or {} local kind = self:kind() if self:is_plat("windows") and runtime then if not _has_ms_runtime_lib(self) then @@ -230,15 +231,18 @@ function nf_runtime(self, runtime) ["stdc++_shared"] = "-stdlib=libstdc++", } elseif kind == "ld" or kind == "sh" then - maps = { - ["c++_static"] = "-stdlib=libc++", - ["c++_shared"] = "-stdlib=libc++", - ["stdc++_static"] = "-stdlib=libstdc++", - ["stdc++_shared"] = "-stdlib=libstdc++", - } - if runtime:endswith("_static") and _has_static_libstdcxx(self) then - maps["c++_static"] = table.join(maps["c++_static"], "-static-libstdc++") - maps["stdc++_static"] = table.join(maps["stdc++_static"], "-static-libstdc++") + local target = opt.target + if target and target.sourcekinds and table.contains(table.wrap(target:sourcekinds()), "cxx") then + maps = { + ["c++_static"] = "-stdlib=libc++", + ["c++_shared"] = "-stdlib=libc++", + ["stdc++_static"] = "-stdlib=libstdc++", + ["stdc++_shared"] = "-stdlib=libstdc++", + } + if runtime:endswith("_static") and _has_static_libstdcxx(self) then + maps["c++_static"] = table.join(maps["c++_static"], "-static-libstdc++") + maps["stdc++_static"] = table.join(maps["stdc++_static"], "-static-libstdc++") + end end end return maps and maps[runtime] |
