diff options
| author | ruki <[email protected]> | 2025-01-11 00:57:49 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-01-11 00:57:49 +0800 |
| commit | 1f34ccd505a67d3e71803d07e8d7bc7f1b9be4fd (patch) | |
| tree | 38688834c829d19883eced3913f8961de9e31e71 | |
| parent | 4810c79dcd1759389791148496d2b62bfdc90191 (diff) | |
improve to check pkgconfig/importfiles
| -rw-r--r-- | xmake/core/package/package.lua | 11 | ||||
| -rw-r--r-- | xmake/modules/lib/detect/check_importfiles.lua | 29 |
2 files changed, 31 insertions, 9 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index f81bf2a0a..ea33e24fa 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -2721,14 +2721,17 @@ end -- function _instance:check_importfiles(names, opt) opt = opt or {} - if opt.configdirs == nil then - local configdirs = {} + if opt.PKG_CONFIG_PATH == nil then + local PKG_CONFIG_PATH = {} local linkdirs = table.wrap(self:get("linkdirs") or "lib") local installdir = self:installdir() for _, linkdir in ipairs(linkdirs) do - table.insert(configdirs, path.join(installdir, linkdir)) + table.insert(PKG_CONFIG_PATH, path.join(installdir, linkdir, "pkgconfig")) end - opt.configdirs = configdirs + opt.PKG_CONFIG_PATH = PKG_CONFIG_PATH + end + if opt.CMAKE_PREFIX_PATH == nil then + opt.CMAKE_PREFIX_PATH = self:installdir() end return sandbox_module.import("lib.detect.check_importfiles", {anonymous = true})(names or ("pkgconfig::" .. self:name()), opt) end diff --git a/xmake/modules/lib/detect/check_importfiles.lua b/xmake/modules/lib/detect/check_importfiles.lua index caa61e4c7..5395413a7 100644 --- a/xmake/modules/lib/detect/check_importfiles.lua +++ b/xmake/modules/lib/detect/check_importfiles.lua @@ -21,6 +21,7 @@ -- imports import("core.base.option") import("lib.detect.pkgconfig") +import("package.manager.cmake.find_package", {alias = "cmake_find_package"}) -- check the given importfiles for pkgconfig/cmake -- @@ -28,6 +29,10 @@ import("lib.detect.pkgconfig") -- @param opt the argument options, e.g. { verbose = true, configdirs = {"lib"}} -- function main(names, opt) + local verbose + if opt.verbose or option.get("verbose") or option.get("diagnosis") then + verbose = true + end for _, name in ipairs(names) do local kind local parts = name:split("::") @@ -38,17 +43,31 @@ function main(names, opt) if kind == nil then kind = "pkgconfig" end + if verbose then + cprint("${dim}> checking for %s/%s", kind, name) + end if kind == "pkgconfig" then + opt.configdirs = opt.PKG_CONFIG_PATH local result = pkgconfig.libinfo(name, opt) - if opt.verbose or option.get("verbose") or option.get("diagnosis") then - cprint("${dim}> checking for pkgconfig/%s.pc", name) - if result then - print(result) - end + if verbose and result then + print(result) end if not result then return false, string.format("pkgconfig/%s.pc not found!", name) end + elseif kind == "cmake" then + if opt.CMAKE_PREFIX_PATH then + opt.configs = opt.configs or {} + opt.configs.envs = opt.configs.envs or {} + opt.configs.envs.CMAKE_PREFIX_PATH = path.joinenv(opt.CMAKE_PREFIX_PATH) + end + local result = cmake_find_package(name, opt) + if verbose and result then + print(result) + end + if not result then + return false, string.format("cmake/%s.cmake not found!", name) + end end end return true |
