From 16e8c3532b8ff54dadea579cc9525e63bfbf013d Mon Sep 17 00:00:00 2001 From: ruki Date: Sun, 10 Mar 2024 21:52:39 +0800 Subject: fix cmakelist #4816 --- xmake/plugins/project/cmake/cmakelists.lua | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/xmake/plugins/project/cmake/cmakelists.lua b/xmake/plugins/project/cmake/cmakelists.lua index 5bbcf05fe..b4dfe8bce 100644 --- a/xmake/plugins/project/cmake/cmakelists.lua +++ b/xmake/plugins/project/cmake/cmakelists.lua @@ -196,16 +196,19 @@ function _translate_flag(flag, outputdir) if flag then if path.instance_of(flag) then flag = flag:clone():set(_get_relative_unix_path_to_cmake(flag:rawstr(), outputdir)):str() - elseif path.is_absolute(flag) then - flag = _get_relative_unix_path_to_cmake(flag, outputdir) - elseif flag:startswith("-fmodule-file=") then - flag = "-fmodule-file=" .. _get_relative_unix_path_to_cmake(flag:sub(15), outputdir) - elseif flag:startswith("-fmodule-mapper=") then - flag = "-fmodule-mapper=" .. _get_relative_unix_path_to_cmake(flag:sub(17), outputdir) - elseif flag:match("(.+)=(.+)") then - local k, v = flag:match("(.+)=(.+)") - if v and (v:endswith(".ifc") or v:endswith(".map")) then -- e.g. hello=xxx/hello.ifc - flag = k .. "=" .. _get_relative_unix_path_to_cmake(v, outputdir) + -- it may be table, https://github.com/xmake-io/xmake/issues/4816 + elseif type(flag) == "string" then + if path.is_absolute(flag) then + flag = _get_relative_unix_path_to_cmake(flag, outputdir) + elseif flag:startswith("-fmodule-file=") then + flag = "-fmodule-file=" .. _get_relative_unix_path_to_cmake(flag:sub(15), outputdir) + elseif flag:startswith("-fmodule-mapper=") then + flag = "-fmodule-mapper=" .. _get_relative_unix_path_to_cmake(flag:sub(17), outputdir) + elseif flag:match("(.+)=(.+)") then + local k, v = flag:match("(.+)=(.+)") + if v and (v:endswith(".ifc") or v:endswith(".map")) then -- e.g. hello=xxx/hello.ifc + flag = k .. "=" .. _get_relative_unix_path_to_cmake(v, outputdir) + end end end end -- cgit v1.3.1