diff options
| author | ruki <[email protected]> | 2021-12-17 22:33:57 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-12-17 22:33:57 +0800 |
| commit | e8aa2b2b36fc5977bb0997cf2697837435937e98 (patch) | |
| tree | 25df1ba52f7661db77c093fd005ab4cc28da9106 /xmake/modules/detect/tools/gcc/has_flags.lua | |
| parent | 369afb0809747329524839edbeab813ad3cf0de8 (diff) | |
improve cmake.find_package and check gcc ldflags
Diffstat (limited to 'xmake/modules/detect/tools/gcc/has_flags.lua')
| -rw-r--r-- | xmake/modules/detect/tools/gcc/has_flags.lua | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/xmake/modules/detect/tools/gcc/has_flags.lua b/xmake/modules/detect/tools/gcc/has_flags.lua index 7b4a40fd2..f7cf1d29e 100644 --- a/xmake/modules/detect/tools/gcc/has_flags.lua +++ b/xmake/modules/detect/tools/gcc/has_flags.lua @@ -44,36 +44,27 @@ end -- attempt to check it from the argument list function _check_from_arglist(flags, opt, islinker) - - -- only for compiler - if islinker or #flags > 1 then - return - end - - -- make cache key - local key = "detect.tools.gcc.has_flags" - - -- make flags key + local key = "detect.tools.gcc." .. (islinker and "has_ldflags" or "has_cflags") local flagskey = opt.program .. "_" .. (opt.programver or "") - - -- get all flags from argument list local allflags = detectcache:get2(key, flagskey) if not allflags then - - -- get argument list allflags = {} - local arglist = os.iorunv(opt.program, {"--help"}, {envs = opt.envs}) + local arglist = try {function () return os.iorunv(opt.program, {islinker and "-Wl,--help" or "--help"}, {envs = opt.envs}) end} if arglist then for arg in arglist:gmatch("%s+(%-[%-%a%d]+)%s+") do allflags[arg] = true end end - - -- save cache detectcache:set2(key, flagskey, allflags) detectcache:save() end - return allflags[flags[1]] + local flag = flags[1] + if islinker and flag then + if flag:startswith("-Wl,") then + flag = flag:match("-Wl,(.-),") or flag:sub(5) + end + end + return allflags[flag] end -- get extension |
