From 8a1528fdb97a228ae62113d3b6c1b4e0a3e19381 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 26 Feb 2021 22:42:01 +0800 Subject: improve cl/has_flags --- xmake/modules/detect/tools/cl/has_flags.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xmake/modules/detect/tools/cl/has_flags.lua b/xmake/modules/detect/tools/cl/has_flags.lua index 2a398041d..a1cb9ace7 100644 --- a/xmake/modules/detect/tools/cl/has_flags.lua +++ b/xmake/modules/detect/tools/cl/has_flags.lua @@ -59,7 +59,8 @@ end function _check_try_running(flags, opt) -- make an stub source file - local sourcefile = path.join(os.tmpdir(), "detect", "cl_has_flags.c") + local tmpdir = path.join(os.tmpdir(), "detect") + local sourcefile = path.join(tmpdir, "cl_has_flags.c") if not os.isfile(sourcefile) then io.writefile(sourcefile, "int main(int argc, char** argv)\n{return 0;}") end @@ -67,7 +68,8 @@ function _check_try_running(flags, opt) -- check it local errors = nil return try { function () - local _, errs = os.iorunv(opt.program, table.join("-c", "-nologo", flags, "-Fo" .. os.nuldev(), sourcefile), {envs = opt.envs}) + local _, errs = os.iorunv(opt.program, table.join("-c", "-nologo", flags, "-Fo" .. os.nuldev(), sourcefile), + {envs = opt.envs, curdir = tmpdir}) -- we need switch to tmpdir to avoid generating some tmp files, e.g. /Zi -> vc140.pdb if errs and #errs:trim() > 0 then return false, errs end -- cgit v1.3.1