summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-07-27 00:28:21 +0800
committerruki <[email protected]>2022-07-27 00:28:21 +0800
commit30d028d5795e16cf0d5384abaa4835e2f0747248 (patch)
tree768e24dbb85d1aa8ad74f16fa945c3feae7a7ffe
parent5380037223db871fee5754d3f6839d3b7fcb15a1 (diff)
improve cmake.find_package
-rw-r--r--xmake/modules/package/manager/cmake/find_package.lua9
1 files changed, 9 insertions, 0 deletions
diff --git a/xmake/modules/package/manager/cmake/find_package.lua b/xmake/modules/package/manager/cmake/find_package.lua
index e4890ad68..f039dd042 100644
--- a/xmake/modules/package/manager/cmake/find_package.lua
+++ b/xmake/modules/package/manager/cmake/find_package.lua
@@ -45,6 +45,11 @@ function _find_package(cmake, name, opt)
if opt.require_version and opt.require_version ~= "latest" then
requirestr = requirestr .. " " .. opt.require_version
end
+ -- set search mode, CONFIG, MODULE, BOTH
+ -- e.g. https://cmake.org/cmake/help/latest/command/find_package.html#id4
+ if configs.search_mode then
+ requirestr = requirestr .. " " .. configs.search_mode
+ end
-- use opt.components is for backward compatibility
local components = configs.components or opt.components
if components then
@@ -84,6 +89,10 @@ function _find_package(cmake, name, opt)
testname, name, name, name)
cmakefile:print(" target_link_libraries(%s ${%s_LIBRARY} ${%s_LIBRARIES} ${%s_LIBS})",
testname, name:upper(), name:upper(), name:upper())
+ if configs.link_libraries then
+ cmakefile:print(" target_link_libraries(%s %s)",
+ testname, table.concat(table.wrap(configs.link_libraries), " "))
+ end
cmakefile:print("endif(%s_FOUND)", name)
cmakefile:close()