summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-02-26 22:42:01 +0800
committerruki <[email protected]>2021-02-26 22:42:01 +0800
commit8a1528fdb97a228ae62113d3b6c1b4e0a3e19381 (patch)
treea1179cf6927552afe693166d68ba81c268dbe7bd
parent4a385a981f83ad40d19d590dd147e7f88525cc3a (diff)
improve cl/has_flags
-rw-r--r--xmake/modules/detect/tools/cl/has_flags.lua6
1 files 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