@@ -43,12 +43,12 @@ function _add_vsenv(toolchain, name, curenvs)
43
43
break
44
44
end
45
45
end
46
- toolchain :add (" runenvs" , name , table .unwrap (path .splitenv (new )))
46
+ toolchain :add (" runenvs" , name , table.unpack (path .splitenv (new )))
47
47
end
48
48
end
49
49
50
50
-- add the given ifort environment
51
- function _add_ifortenv (toolchain , name )
51
+ function _add_ifortenv (toolchain , name , curenvs )
52
52
53
53
-- get ifortvarsall
54
54
local ifortvarsall = toolchain :config (" varsall" )
@@ -61,9 +61,17 @@ function _add_ifortenv(toolchain, name)
61
61
local ifortenv = ifortvarsall [arch ] or {}
62
62
63
63
-- get the paths for the ifort environment
64
- local env = ifortenv [name ]
65
- if env then
66
- toolchain :add (" runenvs" , name :upper (), path .splitenv (env ))
64
+ local new = ifortvarsall [name ]
65
+ if new then
66
+ -- fix case naming conflict for cmake/msbuild between the new msvc envs and current environment, if we are running xmake in vs prompt.
67
+ -- @see https://github.com/xmake-io/xmake/issues/4751
68
+ for k , c in pairs (curenvs ) do
69
+ if name :lower () == k :lower () and name ~= k then
70
+ name = k
71
+ break
72
+ end
73
+ end
74
+ toolchain :add (" runenvs" , name , table.unpack (path .splitenv (new )))
67
75
end
68
76
end
69
77
@@ -82,17 +90,12 @@ function _load_intel_on_windows(toolchain)
82
90
toolchain :set (" toolset" , " fcsh" , " ifort.exe" )
83
91
toolchain :set (" toolset" , " ar" , " link.exe" )
84
92
85
- -- add ifort environments
86
- _add_ifortenv (toolchain , " PATH" )
87
- _add_ifortenv (toolchain , " LIB" )
88
- _add_ifortenv (toolchain , " INCLUDE" )
89
- _add_ifortenv (toolchain , " LIBPATH" )
90
-
91
- -- add vs environments
93
+ -- add ifort and vs environments
92
94
local expect_vars = {" PATH" , " LIB" , " INCLUDE" , " LIBPATH" }
93
95
local curenvs = os .getenvs ()
94
96
for _ , name in ipairs (expect_vars ) do
95
97
_add_vsenv (toolchain , name , curenvs )
98
+ _add_ifortenv (toolchain , name , curenvs )
96
99
end
97
100
for _ , name in ipairs (find_vstudio .get_vcvars ()) do
98
101
if not table .contains (expect_vars , name :upper ()) then
0 commit comments