diff options
| author | ruki <[email protected]> | 2021-09-16 22:44:11 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-09-16 22:44:11 +0800 |
| commit | b0de078312f7c87f54c9229b913992a495a3b2ed (patch) | |
| tree | a00f5709f96e3e278315dd41e2ba90b5ad657d9f /xmake/core/project/target.lua | |
| parent | 8f3d4ec9654ba58a5a098213c2d28c01ecd1649c (diff) | |
improve find_library
Diffstat (limited to 'xmake/core/project/target.lua')
| -rw-r--r-- | xmake/core/project/target.lua | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 959e94f5b..7b0ce47d9 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -2058,14 +2058,19 @@ function target.filename(targetname, targetkind, opt) end -- get the link name of the target file -function target.linkname(filename) +function target.linkname(filename, opt) -- for implib/mingw, e.g. libxxx.dll.a + opt = opt or {} if filename:startswith("lib") and filename:endswith(".dll.a") then return filename:sub(4, #filename - 6) end - local linkname, count = filename:gsub(target.filename("__pattern__", "static"):gsub("%.", "%%."):gsub("__pattern__", "(.+)") .. "$", "%1") + local linkname, count = filename:gsub(target.filename("__pattern__", "static", {plat = opt.plat}):gsub("%.", "%%."):gsub("__pattern__", "(.+)") .. "$", "%1") if count == 0 then - linkname, count = filename:gsub(target.filename("__pattern__", "shared"):gsub("%.", "%%."):gsub("__pattern__", "(.+)") .. "$", "%1") + linkname, count = filename:gsub(target.filename("__pattern__", "shared", {plat = opt.plat}):gsub("%.", "%%."):gsub("__pattern__", "(.+)") .. "$", "%1") + end + -- in order to be compatible with mingw/windows library with .lib + if count == 0 and opt.plat == "mingw" then + linkname, count = filename:gsub(target.filename("__pattern__", "static", {plat = "windows"}):gsub("%.", "%%."):gsub("__pattern__", "(.+)") .. "$", "%1") end return count > 0 and linkname or nil end |
