diff options
| author | ruki <[email protected]> | 2022-11-15 22:29:23 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-11-15 22:29:23 +0800 |
| commit | b5a4e93c9f12c9f9ce23c3c4c17b26c7960cbfc2 (patch) | |
| tree | bd5628901fd56148ebec547bb31f012a24118481 | |
| parent | 6a293455158e8cf5a30796791b591d7e71746433 (diff) | |
improve to find_cl
| -rw-r--r-- | xmake/modules/detect/tools/find_cl.lua | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/xmake/modules/detect/tools/find_cl.lua b/xmake/modules/detect/tools/find_cl.lua index 4ee7108c6..350f15c86 100644 --- a/xmake/modules/detect/tools/find_cl.lua +++ b/xmake/modules/detect/tools/find_cl.lua @@ -38,7 +38,18 @@ function main(opt) -- init options opt = opt or {} - opt.check = opt.check or function (program) os.runv(program, {}, {envs = opt.envs}) end + opt.check = opt.check or function (program) + local ok = try { function () os.runv(program, {}, {envs = opt.envs}); return true end } + if not ok then + -- @see https://github.com/xmake-io/xmake/issues/3057 + local objectfile = os.tmpfile() .. ".obj" + local sourcefile = os.tmpfile() .. ".c" + io.writefile(sourcefile, "int main(int argc, char** argv)\n{return 0;}") + os.runv(program, {"-c", "-Fo" .. objectfile, sourcefile}, {envs = opt.envs}) + os.rm(objectfile) + os.rm(sourcefile) + end + end -- find program local program = find_program(opt.program or "cl.exe", opt) |
