summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichardYCJ <[email protected]>2023-03-11 11:00:06 +0800
committerRichardYCJ <[email protected]>2023-03-11 11:00:06 +0800
commit8355798b9a065b8c4e0eed31214205cedb06b766 (patch)
tree87d751d8cc60d426af008b767025e7d5f712807d
parenta44858347dea6e083791663f462bf90a1878a18a (diff)
fix cmake::find_package, use format string instead of gsub
-rw-r--r--xmake/modules/package/manager/cmake/find_package.lua8
1 files changed, 4 insertions, 4 deletions
diff --git a/xmake/modules/package/manager/cmake/find_package.lua b/xmake/modules/package/manager/cmake/find_package.lua
index e6bfcaafb..503259b46 100644
--- a/xmake/modules/package/manager/cmake/find_package.lua
+++ b/xmake/modules/package/manager/cmake/find_package.lua
@@ -86,8 +86,8 @@ function _find_package(cmake, name, opt)
if configs.include_dirs then
includedirs = table.concat(table.wrap(configs.include_dirs), " ")
else
- includedirs = string.gsub("${X_INCLUDE_DIR} ${X_INCLUDE_DIRS}", "X", name)
- includedirs = includedirs .. string.gsub(" ${X_INCLUDE_DIR} ${X_INCLUDE_DIRS}", "X", name:upper())
+ includedirs = ("${%s_INCLUDE_DIR} ${%s_INCLUDE_DIRS}"):format(name, name)
+ includedirs = includedirs .. (" ${%s_INCLUDE_DIR} ${%s_INCLUDE_DIRS}"):format(name:upper(), name:upper())
end
cmakefile:print(" target_include_directories(%s PRIVATE %s)", testname, includedirs)
-- reserved for backword compatibility
@@ -98,8 +98,8 @@ function _find_package(cmake, name, opt)
if configs.link_libraries then
linklibs = table.concat(table.wrap(configs.link_libraries), " ")
else
- linklibs = string.gsub("${X_LIBRARY} ${X_LIBRARIES} ${X_LIBS}", "X", name)
- linklibs = linklibs .. string.gsub(" ${X_LIBRARY} ${X_LIBRARIES} ${X_LIBS}", "X", name:upper())
+ linklibs = ("${%s_LIBRARY} ${%s_LIBRARIES} ${%s_LIBS}"):format(name, name, name)
+ linklibs = linklibs .. (" ${%s_LIBRARY} ${%s_LIBRARIES} ${%s_LIBS}"):format(name:upper(), name:upper(), name:upper())
end
cmakefile:print(" target_link_libraries(%s PRIVATE %s)", testname, linklibs)
cmakefile:print("endif(%s_FOUND)", name)