summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-02-22 23:37:43 +0800
committerruki <[email protected]>2024-02-22 23:37:43 +0800
commit4785dbaf7dc11ff84ccdc2b0943618950363d1c5 (patch)
treed8799c7667a4d0a42d30d180accb760c2e35c0f0
parent2104e5927ecad9eb17180590c53875e1ee15b711 (diff)
improve clang-cl envs
-rw-r--r--xmake/toolchains/clang-cl/load.lua15
1 files changed, 12 insertions, 3 deletions
diff --git a/xmake/toolchains/clang-cl/load.lua b/xmake/toolchains/clang-cl/load.lua
index 3b0da0e0a..3763b8d2e 100644
--- a/xmake/toolchains/clang-cl/load.lua
+++ b/xmake/toolchains/clang-cl/load.lua
@@ -24,7 +24,7 @@ import("core.project.config")
import("detect.sdks.find_vstudio")
-- add the given vs environment
-function _add_vsenv(toolchain, name)
+function _add_vsenv(toolchain, name, curenvs)
-- get vcvars
local vcvars = toolchain:config("vcvars")
@@ -35,6 +35,14 @@ function _add_vsenv(toolchain, name)
-- get the paths for the vs environment
local new = vcvars[name]
if new then
+ -- fix case naming conflict for cmake/msbuild between the new msvc envs and current environment, if we are running xmake in vs prompt.
+ -- @see https://github.com/xmake-io/xmake/issues/4751
+ for k, c in pairs(curenvs) do
+ if name:lower() == k:lower() and name ~= k then
+ name = k
+ break
+ end
+ end
toolchain:add("runenvs", name, table.unwrap(path.splitenv(new)))
end
end
@@ -57,12 +65,13 @@ function main(toolchain)
-- add vs environments
local expect_vars = {"PATH", "LIB", "INCLUDE", "LIBPATH"}
+ local curenvs = os.getenvs()
for _, name in ipairs(expect_vars) do
- _add_vsenv(toolchain, name)
+ _add_vsenv(toolchain, name, curenvs)
end
for _, name in ipairs(find_vstudio.get_vcvars()) do
if not table.contains(expect_vars, name:upper()) then
- _add_vsenv(toolchain, name)
+ _add_vsenv(toolchain, name, curenvs)
end
end