diff options
| author | ruki <[email protected]> | 2024-05-23 22:57:20 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-05-23 22:57:20 +0800 |
| commit | be0da314e2a706fff2d10ef68588275d2a90e638 (patch) | |
| tree | 73c8b43002c56a0a13aa0385b85aef8e901b3855 /xmake/toolchains/icx/load.lua | |
| parent | 537c5aacf5d0306a3ca786932737991c29e8ecc5 (diff) | |
check vs for ifort/icx
Diffstat (limited to 'xmake/toolchains/icx/load.lua')
| -rw-r--r-- | xmake/toolchains/icx/load.lua | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/xmake/toolchains/icx/load.lua b/xmake/toolchains/icx/load.lua index ebe3e8554..74f021c07 100644 --- a/xmake/toolchains/icx/load.lua +++ b/xmake/toolchains/icx/load.lua @@ -21,6 +21,31 @@ -- imports import("core.base.option") import("core.project.config") +import("detect.sdks.find_vstudio") + +-- add the given vs environment +function _add_vsenv(toolchain, name, curenvs) + + -- get vcvars + local vcvars = toolchain:config("vcvars") + if not vcvars then + return + end + + -- 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 -- add the given icx environment function _add_icxenv(toolchain, name) @@ -73,6 +98,18 @@ function _load_intel_on_windows(toolchain) _add_icxenv(toolchain, "LIB") _add_icxenv(toolchain, "INCLUDE") _add_icxenv(toolchain, "LIBPATH") + + -- 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, curenvs) + end + for _, name in ipairs(find_vstudio.get_vcvars()) do + if not table.contains(expect_vars, name:upper()) then + _add_vsenv(toolchain, name, curenvs) + end + end end -- load intel on linux |
