summaryrefslogtreecommitdiff
path: root/xmake/modules/lib
diff options
context:
space:
mode:
authorruki <[email protected]>2025-01-11 00:57:49 +0800
committerruki <[email protected]>2025-01-11 00:57:49 +0800
commit1f34ccd505a67d3e71803d07e8d7bc7f1b9be4fd (patch)
tree38688834c829d19883eced3913f8961de9e31e71 /xmake/modules/lib
parent4810c79dcd1759389791148496d2b62bfdc90191 (diff)
improve to check pkgconfig/importfiles
Diffstat (limited to 'xmake/modules/lib')
-rw-r--r--xmake/modules/lib/detect/check_importfiles.lua29
1 files changed, 24 insertions, 5 deletions
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