From 96d893d29f543f4f24b42fab0645e406435922b8 Mon Sep 17 00:00:00 2001 From: xq114 <1140735506@qq.com> Date: Thu, 22 Apr 2021 22:42:38 +0800 Subject: improve package.tools.cmake --- xmake/modules/package/tools/cmake.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'xmake/modules/package/tools/cmake.lua') diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua index 92d6d7e72..7aaf64b7d 100644 --- a/xmake/modules/package/tools/cmake.lua +++ b/xmake/modules/package/tools/cmake.lua @@ -116,6 +116,11 @@ function _get_cflags(package, opt) table.join2(result, opt.cxflags) end table.join2(result, _get_cflags_from_packagedeps(package, opt)) + for i, flag in ipairs(result) do + if flag:match(" ") then + result[i] = '"' .. flag .. '"' + end + end if #result > 0 then return table.concat(result, ' ') end @@ -141,6 +146,11 @@ function _get_cxxflags(package, opt) table.join2(result, opt.cxflags) end table.join2(result, _get_cflags_from_packagedeps(package, opt)) + for i, flag in ipairs(result) do + if flag:match(" ") then + result[i] = '"' .. flag .. '"' + end + end if #result > 0 then return table.concat(result, ' ') end @@ -160,6 +170,11 @@ function _get_asflags(package, opt) if opt.asflags then table.join2(result, opt.asflags) end + for i, flag in ipairs(result) do + if flag:match(" ") then + result[i] = '"' .. flag .. '"' + end + end if #result > 0 then return table.concat(result, ' ') end @@ -179,6 +194,11 @@ function _get_ldflags(package, opt) if opt.ldflags then table.join2(result, opt.ldflags) end + for i, flag in ipairs(result) do + if flag:match(" ") then + result[i] = '"' .. flag .. '"' + end + end if #result > 0 then return table.concat(result, ' ') end @@ -198,6 +218,11 @@ function _get_shflags(package, opt) if opt.shflags then table.join2(result, opt.shflags) end + for i, flag in ipairs(result) do + if flag:match(" ") then + result[i] = '"' .. flag .. '"' + end + end if #result > 0 then return table.concat(result, ' ') end -- cgit v1.3.1 From 51bc592d022d1b812bae3f12fb9365f1842c30c3 Mon Sep 17 00:00:00 2001 From: xq114 <1140735506@qq.com> Date: Fri, 23 Apr 2021 13:08:27 +0800 Subject: using os.args instead of custom workaround --- xmake/modules/package/tools/cmake.lua | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) (limited to 'xmake/modules/package/tools/cmake.lua') diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua index 7aaf64b7d..a15812300 100644 --- a/xmake/modules/package/tools/cmake.lua +++ b/xmake/modules/package/tools/cmake.lua @@ -116,13 +116,8 @@ function _get_cflags(package, opt) table.join2(result, opt.cxflags) end table.join2(result, _get_cflags_from_packagedeps(package, opt)) - for i, flag in ipairs(result) do - if flag:match(" ") then - result[i] = '"' .. flag .. '"' - end - end if #result > 0 then - return table.concat(result, ' ') + return os.args(result) end end @@ -146,13 +141,8 @@ function _get_cxxflags(package, opt) table.join2(result, opt.cxflags) end table.join2(result, _get_cflags_from_packagedeps(package, opt)) - for i, flag in ipairs(result) do - if flag:match(" ") then - result[i] = '"' .. flag .. '"' - end - end if #result > 0 then - return table.concat(result, ' ') + return os.args(result) end end @@ -170,13 +160,8 @@ function _get_asflags(package, opt) if opt.asflags then table.join2(result, opt.asflags) end - for i, flag in ipairs(result) do - if flag:match(" ") then - result[i] = '"' .. flag .. '"' - end - end if #result > 0 then - return table.concat(result, ' ') + return os.args(result) end end @@ -194,13 +179,8 @@ function _get_ldflags(package, opt) if opt.ldflags then table.join2(result, opt.ldflags) end - for i, flag in ipairs(result) do - if flag:match(" ") then - result[i] = '"' .. flag .. '"' - end - end if #result > 0 then - return table.concat(result, ' ') + return os.args(result) end end @@ -218,13 +198,8 @@ function _get_shflags(package, opt) if opt.shflags then table.join2(result, opt.shflags) end - for i, flag in ipairs(result) do - if flag:match(" ") then - result[i] = '"' .. flag .. '"' - end - end if #result > 0 then - return table.concat(result, ' ') + return os.args(result) end end -- cgit v1.3.1