diff options
| author | ruki <[email protected]> | 2026-01-12 22:41:16 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2026-01-12 22:41:16 +0800 |
| commit | 5a41cf81382a49f1a88b613f2e6b10b8ce7223c7 (patch) | |
| tree | fbc79c5fbdfbc4319299ac59dfa25b203d3be5b9 | |
| parent | d1f4de4fe9450980b7098f3aa2598ba7e964aaf5 (diff) | |
fix installdir of imporfiles
| -rw-r--r-- | xmake/modules/target/action/install/cmake_importfiles.lua | 31 | ||||
| -rw-r--r-- | xmake/modules/target/action/install/pkgconfig_importfiles.lua | 3 |
2 files changed, 19 insertions, 15 deletions
diff --git a/xmake/modules/target/action/install/cmake_importfiles.lua b/xmake/modules/target/action/install/cmake_importfiles.lua index 6b8769225..0b1195c68 100644 --- a/xmake/modules/target/action/install/cmake_importfiles.lua +++ b/xmake/modules/target/action/install/cmake_importfiles.lua @@ -22,12 +22,12 @@ import("core.project.project") -- get the lib file of the target -function _get_libfile(target, installdir) +function _get_libfile(target, libdir) local libfile = path.filename(target:targetfile()) if target:is_plat("windows") then libfile = libfile:gsub("%.dll$", ".lib") elseif target:is_plat("mingw") then - if os.isfile(path.join(installdir, "lib", libfile:gsub("%.dll$", ".dll.a"))) then + if os.isfile(path.join(libdir, libfile:gsub("%.dll$", ".dll.a"))) then libfile = libfile:gsub("%.dll$", ".dll.a") else libfile = libfile:gsub("%.dll$", ".lib") @@ -37,7 +37,7 @@ function _get_libfile(target, installdir) end -- get the builtin variables -function _get_builtinvars(target, installdir, libdir) +function _get_builtinvars(target, libdir) local target_ptrbytes if target:is_plat("cross") then target_ptrbytes = target:check_sizeof("void*") @@ -47,7 +47,7 @@ function _get_builtinvars(target, installdir, libdir) return {LIBDIR = libdir, TARGETNAME = target:name(), PROJECTNAME = project.name() or target:name(), - TARGETFILENAME = target:targetfile() and _get_libfile(target, installdir), + TARGETFILENAME = target:targetfile() and _get_libfile(target, libdir), TARGETKIND = target:is_headeronly() and "INTERFACE" or (target:is_shared() and "SHARED" or "STATIC"), PACKAGE_VERSION = target:get("version") or "1.0.0", TARGET_PTRBYTES = target_ptrbytes} @@ -55,18 +55,19 @@ end -- install cmake config file function _install_cmake_configfile(target, installdir, filename, opt) + opt = opt or {} -- get import file path - local libdir = opt and opt.libdir or "lib" + local libdir = opt.libdir and path.join(installdir, opt.libdir) or target:libdir() local projectname = project.name() or target:name() local importfile_src = path.join(os.programdir(), "scripts", "cmake_importfiles", filename) - local importfile_dst = path.join(installdir, libdir, "cmake", projectname, (filename:gsub("xxx", projectname))) + local importfile_dst = path.join(libdir, "cmake", projectname, (filename:gsub("xxx", projectname))) -- trace vprint("generating %s ..", importfile_dst) -- get the builtin variables - local builtinvars = _get_builtinvars(target, installdir, libdir) + local builtinvars = _get_builtinvars(target, libdir) -- copy and replace builtin variables local content = io.readfile(importfile_src) @@ -83,15 +84,16 @@ end -- append target to cmake config file function _append_cmake_configfile(target, installdir, filename, opt) + opt = opt or {} -- get import file path - local libdir = opt and opt.libdir or "lib" + local libdir = opt.libdir and path.join(installdir, opt.libdir) or target:libdir() local projectname = project.name() or target:name() local importfile_src = path.join(os.programdir(), "scripts", "cmake_importfiles", filename) - local importfile_dst = path.join(installdir, libdir, "cmake", projectname, (filename:gsub("xxx", projectname))) + local importfile_dst = path.join(libdir, "cmake", projectname, (filename:gsub("xxx", projectname))) -- get the builtin variables - local builtinvars = _get_builtinvars(target, installdir, libdir) + local builtinvars = _get_builtinvars(target, libdir) -- generate the file if not exist / file is outdated if target:is_headeronly() or not os.isfile(importfile_dst) or os.mtime(importfile_dst) < os.mtime(target:targetfile()) then @@ -119,18 +121,19 @@ end -- install cmake target file function _install_cmake_targetfile(target, installdir, filename, opt) + opt = opt or {} -- get import file path - local libdir = opt and opt.libdir or "lib" + local libdir = opt.libdir and path.join(installdir, opt.libdir) or target:libdir() local projectname = project.name() or target:name() local importfile_src = path.join(os.programdir(), "scripts", "cmake_importfiles", filename) - local importfile_dst = path.join(installdir, libdir, "cmake", projectname, (filename:gsub("xxx", target:name()))) + local importfile_dst = path.join(libdir, "cmake", projectname, (filename:gsub("xxx", target:name()))) -- trace vprint("generating %s ..", importfile_dst) -- get the builtin variables - local builtinvars = _get_builtinvars(target, installdir, libdir) + local builtinvars = _get_builtinvars(target, libdir) -- copy and replace builtin variables local content = io.readfile(importfile_src) @@ -142,7 +145,7 @@ function _install_cmake_targetfile(target, installdir, filename, opt) end) local libfile = path.filename(target:targetfile()) local postfix = is_mode("debug") and "DEBUG" or "RELEASE" - if target:is_shared() and (_get_libfile(target, installdir) ~= libfile) then + if target:is_shared() and (_get_libfile(target, libdir) ~= libfile) then -- On DLL platforms, the import library is named differently from the target file content = content:gsub("# IMPORTED_IMPLIB_" .. postfix, "IMPORTED_IMPLIB_" .. postfix) content = content:gsub( diff --git a/xmake/modules/target/action/install/pkgconfig_importfiles.lua b/xmake/modules/target/action/install/pkgconfig_importfiles.lua index b96833071..cdeb42831 100644 --- a/xmake/modules/target/action/install/pkgconfig_importfiles.lua +++ b/xmake/modules/target/action/install/pkgconfig_importfiles.lua @@ -30,7 +30,8 @@ function main(target, opt) end -- get pkgconfig/.pc file - local pcfile = path.join(installdir, opt and opt.libdir or "lib", "pkgconfig", opt.filename or (target:basename() .. ".pc")) + local libdir = opt.libdir and path.join(installdir, opt.libdir) or target:libdir() + local pcfile = path.join(libdir, "pkgconfig", opt.filename or (target:basename() .. ".pc")) -- get includedirs local includedirs = opt.includedirs |
