summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-11-21 22:43:55 +0800
committerruki <[email protected]>2024-11-21 22:43:55 +0800
commitdb0829f412cccc928d0f895bdebfec8874593781 (patch)
tree0958d7e19cb519747d2541129107efaec8f43dbf
parentef16d2434c22fc36c3a9d79bee9dfec6c00a5292 (diff)
fix cmake flags
-rw-r--r--xmake/modules/package/tools/cmake.lua9
1 files changed, 5 insertions, 4 deletions
diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua
index 6412eeb71..770c1a631 100644
--- a/xmake/modules/package/tools/cmake.lua
+++ b/xmake/modules/package/tools/cmake.lua
@@ -1245,8 +1245,9 @@ function _shrink_cmake_arguments(argv, oldir, opt)
if build_type then
table.insert(cmake_argv, ("if(CMAKE_BUILD_TYPE STREQUAL \"%s\")"):format(build_type))
end
- local flags = v:replace(" ", "\\ ")
- table.insert(cmake_argv, ("add_compile_options($<$<COMPILE_LANGUAGE:%s>:%s>)"):format(kind, flags))
+ local flags = v:replace("\"", "\\\"")
+ table.insert(cmake_argv, ("set(COMP_%s_FLAGS \"%s\")"):format(kind, flags))
+ table.insert(cmake_argv, ("add_compile_options($<$<COMPILE_LANGUAGE:%s>:${COMP_%s_FLAGS}>)"):format(kind, kind))
if build_type then
table.insert(cmake_argv, "endif()")
end
@@ -1255,14 +1256,14 @@ function _shrink_cmake_arguments(argv, oldir, opt)
end
-- shrink long arguments
if #v > 128 then
- table.insert(cmake_argv, ("set(%s \"%s\")"):format(k, v))
+ local flags = v:replace("\"", "\\\"")
+ table.insert(cmake_argv, ("set(%s \"%s\")"):format(k, flags))
shrink = true
return true
end
end
end)
if shrink then
- print(cmake_argv)
local cmakefile = path.join(opt.curdir and opt.curdir or oldir, "CMakeLists.txt")
io.insert(cmakefile, 1, table.concat(cmake_argv, "\n"))
end