summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2026-01-12 22:54:07 +0800
committerruki <[email protected]>2026-01-12 22:54:07 +0800
commit3ffd904326d6a06f8f63a92bc1d2334a8d8441fd (patch)
tree83192d6b37fb25c0586dd01c75af93f1056e38f5
parent168fe49abe77fbf2a1c1ba865bf22d4d8cdd371d (diff)
improve cmake installdir
-rw-r--r--xmake/modules/target/action/install/cmake_importfiles.lua15
1 files changed, 9 insertions, 6 deletions
diff --git a/xmake/modules/target/action/install/cmake_importfiles.lua b/xmake/modules/target/action/install/cmake_importfiles.lua
index ae2155ec7..b4efecb08 100644
--- a/xmake/modules/target/action/install/cmake_importfiles.lua
+++ b/xmake/modules/target/action/install/cmake_importfiles.lua
@@ -21,6 +21,12 @@
-- imports
import("core.project.project")
+-- get install libdir
+function _get_install_libdir(target, installdir, opt)
+ opt = opt or {}
+ return opt.libdir and path.join(installdir, opt.libdir) or target:libdir()
+end
+
-- get the lib file of the target
function _get_libfile(target, libdir)
local libfile = path.filename(target:targetfile())
@@ -61,10 +67,9 @@ end
-- install cmake config file
function _install_cmake_configfile(target, installdir, filename, opt)
- opt = opt or {}
-- get import file path
- local libdir = opt.libdir and path.join(installdir, opt.libdir) or target:libdir()
+ local libdir = _get_install_libdir(target, installdir, opt)
local projectname = project.name() or target:name()
local importfile_src = path.join(os.programdir(), "scripts", "cmake_importfiles", filename)
local importfile_dst = path.join(libdir, "cmake", projectname, (filename:gsub("xxx", projectname)))
@@ -90,10 +95,9 @@ 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.libdir and path.join(installdir, opt.libdir) or target:libdir()
+ local libdir = _get_install_libdir(target, installdir, opt)
local projectname = project.name() or target:name()
local importfile_src = path.join(os.programdir(), "scripts", "cmake_importfiles", filename)
local importfile_dst = path.join(libdir, "cmake", projectname, (filename:gsub("xxx", projectname)))
@@ -127,10 +131,9 @@ end
-- install cmake target file
function _install_cmake_targetfile(target, installdir, filename, opt)
- opt = opt or {}
-- get import file path
- local libdir = opt.libdir and path.join(installdir, opt.libdir) or target:libdir()
+ local libdir = _get_install_libdir(target, installdir, opt)
local projectname = project.name() or target:name()
local importfile_src = path.join(os.programdir(), "scripts", "cmake_importfiles", filename)
local importfile_dst = path.join(libdir, "cmake", projectname, (filename:gsub("xxx", target:name())))