Skip to content

Commit dc2e263

Browse files
committed
fix icx/ifort envs
1 parent be0da31 commit dc2e263

File tree

2 files changed

+30
-24
lines changed

2 files changed

+30
-24
lines changed

xmake/toolchains/icx/load.lua

+15-12
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ function _add_vsenv(toolchain, name, curenvs)
4343
break
4444
end
4545
end
46-
toolchain:add("runenvs", name, table.unwrap(path.splitenv(new)))
46+
toolchain:add("runenvs", name, table.unpack(path.splitenv(new)))
4747
end
4848
end
4949

5050
-- add the given icx environment
51-
function _add_icxenv(toolchain, name)
51+
function _add_icxenv(toolchain, name, curenvs)
5252

5353
-- get icxvarsall
5454
local icxvarsall = toolchain:config("varsall")
@@ -61,9 +61,17 @@ function _add_icxenv(toolchain, name)
6161
local icxenv = icxvarsall[arch] or {}
6262

6363
-- get the paths for the icx environment
64-
local env = icxenv[name]
65-
if env then
66-
toolchain:add("runenvs", name:upper(), path.splitenv(env))
64+
local new = icxvarsall[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)))
6775
end
6876
end
6977

@@ -93,17 +101,12 @@ function _load_intel_on_windows(toolchain)
93101
toolchain:set("toolset", "as", "icx")
94102
end
95103

96-
-- add icx environments
97-
_add_icxenv(toolchain, "PATH")
98-
_add_icxenv(toolchain, "LIB")
99-
_add_icxenv(toolchain, "INCLUDE")
100-
_add_icxenv(toolchain, "LIBPATH")
101-
102-
-- add vs environments
104+
-- add vs/icx environments
103105
local expect_vars = {"PATH", "LIB", "INCLUDE", "LIBPATH"}
104106
local curenvs = os.getenvs()
105107
for _, name in ipairs(expect_vars) do
106108
_add_vsenv(toolchain, name, curenvs)
109+
_add_icxenv(toolchain, name, curenvs)
107110
end
108111
for _, name in ipairs(find_vstudio.get_vcvars()) do
109112
if not table.contains(expect_vars, name:upper()) then

xmake/toolchains/ifort/load.lua

+15-12
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ function _add_vsenv(toolchain, name, curenvs)
4343
break
4444
end
4545
end
46-
toolchain:add("runenvs", name, table.unwrap(path.splitenv(new)))
46+
toolchain:add("runenvs", name, table.unpack(path.splitenv(new)))
4747
end
4848
end
4949

5050
-- add the given ifort environment
51-
function _add_ifortenv(toolchain, name)
51+
function _add_ifortenv(toolchain, name, curenvs)
5252

5353
-- get ifortvarsall
5454
local ifortvarsall = toolchain:config("varsall")
@@ -61,9 +61,17 @@ function _add_ifortenv(toolchain, name)
6161
local ifortenv = ifortvarsall[arch] or {}
6262

6363
-- 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)))
6775
end
6876
end
6977

@@ -82,17 +90,12 @@ function _load_intel_on_windows(toolchain)
8290
toolchain:set("toolset", "fcsh", "ifort.exe")
8391
toolchain:set("toolset", "ar", "link.exe")
8492

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
9294
local expect_vars = {"PATH", "LIB", "INCLUDE", "LIBPATH"}
9395
local curenvs = os.getenvs()
9496
for _, name in ipairs(expect_vars) do
9597
_add_vsenv(toolchain, name, curenvs)
98+
_add_ifortenv(toolchain, name, curenvs)
9699
end
97100
for _, name in ipairs(find_vstudio.get_vcvars()) do
98101
if not table.contains(expect_vars, name:upper()) then

0 commit comments

Comments
 (0)