summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2026-01-12 22:43:39 +0800
committerruki <[email protected]>2026-01-12 22:43:39 +0800
commit168fe49abe77fbf2a1c1ba865bf22d4d8cdd371d (patch)
treecc59ab605d1cba0c38acde559275f180162c6c58
parent5a41cf81382a49f1a88b613f2e6b10b8ce7223c7 (diff)
fix libdir
-rw-r--r--xmake/modules/target/action/install/cmake_importfiles.lua16
1 files changed, 11 insertions, 5 deletions
diff --git a/xmake/modules/target/action/install/cmake_importfiles.lua b/xmake/modules/target/action/install/cmake_importfiles.lua
index 0b1195c68..ae2155ec7 100644
--- a/xmake/modules/target/action/install/cmake_importfiles.lua
+++ b/xmake/modules/target/action/install/cmake_importfiles.lua
@@ -37,14 +37,20 @@ function _get_libfile(target, libdir)
end
-- get the builtin variables
-function _get_builtinvars(target, libdir)
+function _get_builtinvars(target, installdir, libdir)
local target_ptrbytes
if target:is_plat("cross") then
target_ptrbytes = target:check_sizeof("void*")
else
target_ptrbytes = target:is_arch64() and "8" or "4"
end
- return {LIBDIR = libdir,
+ local libsubdir
+ if libdir:startswith(installdir) then
+ libsubdir = path.relative(libdir, installdir)
+ else
+ raise("target(%s): libdir(%s) is not in installdir(%s)", target:name(), libdir, installdir)
+ end
+ return {LIBDIR = libsubdir,
TARGETNAME = target:name(),
PROJECTNAME = project.name() or target:name(),
TARGETFILENAME = target:targetfile() and _get_libfile(target, libdir),
@@ -67,7 +73,7 @@ function _install_cmake_configfile(target, installdir, filename, opt)
vprint("generating %s ..", importfile_dst)
-- get the builtin variables
- local builtinvars = _get_builtinvars(target, libdir)
+ local builtinvars = _get_builtinvars(target, installdir, libdir)
-- copy and replace builtin variables
local content = io.readfile(importfile_src)
@@ -93,7 +99,7 @@ function _append_cmake_configfile(target, installdir, filename, opt)
local importfile_dst = path.join(libdir, "cmake", projectname, (filename:gsub("xxx", projectname)))
-- get the builtin variables
- local builtinvars = _get_builtinvars(target, libdir)
+ local builtinvars = _get_builtinvars(target, installdir, 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
@@ -133,7 +139,7 @@ function _install_cmake_targetfile(target, installdir, filename, opt)
vprint("generating %s ..", importfile_dst)
-- get the builtin variables
- local builtinvars = _get_builtinvars(target, libdir)
+ local builtinvars = _get_builtinvars(target, installdir, libdir)
-- copy and replace builtin variables
local content = io.readfile(importfile_src)