From cffdbf25772f185bdd86bb08705d0ddfe288bfb9 Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 29 Jun 2017 17:56:38 +0800 Subject: improve link has_flag --- xmake/modules/detect/tools/link/has_flag.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/xmake/modules/detect/tools/link/has_flag.lua b/xmake/modules/detect/tools/link/has_flag.lua index e46647f99..008f28912 100644 --- a/xmake/modules/detect/tools/link/has_flag.lua +++ b/xmake/modules/detect/tools/link/has_flag.lua @@ -71,9 +71,14 @@ end function _check_try_running(flag, opt) -- make an stub source file - local sourcefile = path.join(os.tmpdir(), "detect", "link_has_flag.c") + local winmain = flag:lower():find("subsystem:windows") + local sourcefile = path.join(os.tmpdir(), "detect", ifelse(winmain, "winmain_", "") .. "link_has_flag.c") if not os.isfile(sourcefile) then - io.writefile(sourcefile, "int main(int argc, char** argv)\n{return 0;}") + if winmain then + io.writefile(sourcefile, "int WinMain(void* instance, void* previnst, char** argv, int argc)\n{return 0;}") + else + io.writefile(sourcefile, "int main(int argc, char** argv)\n{return 0;}") + end end -- compile the source file -- cgit v1.3.1