From 3ffd904326d6a06f8f63a92bc1d2334a8d8441fd Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 12 Jan 2026 22:54:07 +0800 Subject: improve cmake installdir --- xmake/modules/target/action/install/cmake_importfiles.lua | 15 +++++++++------ 1 file 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()))) -- cgit v1.3.1