summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxq114 <[email protected]>2021-08-11 23:25:27 +0800
committerxq114 <[email protected]>2021-08-11 23:25:27 +0800
commit3fdef81bd4c17f224065296cf71c8f18a2b35f9e (patch)
treefc44f0cd7d49709c62496570baadf42a2f873aa2
parent9a29212b893502d685282660ab34646e167be1e9 (diff)
improve libfile finding on mingw
-rw-r--r--xmake/modules/target/action/install/cmake_importfiles.lua17
1 files changed, 13 insertions, 4 deletions
diff --git a/xmake/modules/target/action/install/cmake_importfiles.lua b/xmake/modules/target/action/install/cmake_importfiles.lua
index 0b6a8c276..e4e5d118e 100644
--- a/xmake/modules/target/action/install/cmake_importfiles.lua
+++ b/xmake/modules/target/action/install/cmake_importfiles.lua
@@ -21,17 +21,26 @@
-- imports
import("core.project.project")
--- get the builtin variables
-function _get_builtinvars(target, installdir)
+-- get the lib file of the target
+function _get_libfile(target, installdir)
local libfile = path.filename(target:targetfile())
if target:is_plat("windows") then
libfile = libfile:gsub("%.dll$", ".lib")
elseif target:is_plat("mingw") then
- libfile = libfile:gsub("%.dll$", ".dll.a")
+ if os.isfile(path.join(installdir, "lib", libfile:gsub("%.dll$", ".dll.a"))) then
+ libfile = libfile:gsub("%.dll$", ".dll.a")
+ else
+ libfile = libfile:gsub("%.dll$", ".lib")
+ end
end
+ return libfile
+end
+
+-- get the builtin variables
+function _get_builtinvars(target, installdir)
return {TARGETNAME = target:name(),
PROJECTNAME = project.name() or target:name(),
- TARGETFILENAME = libfile,
+ TARGETFILENAME = _get_libfile(target, installdir),
TARGETKIND = target:is_shared() and "SHARED" or "STATIC",
PACKAGE_VERSION = target:get("version") or "1.0.0",
TARGET_PTRBYTES = target:is_arch("x86", "i386") and "4" or "8"}