diff options
| author | star9029 <[email protected]> | 2024-09-27 00:33:50 +0800 |
|---|---|---|
| committer | star9029 <[email protected]> | 2024-09-27 00:33:50 +0800 |
| commit | 4d803f21b3d542ac6af25135b1351a3c8b6c691e (patch) | |
| tree | 41e021aa59378985a693860ca73ceda00e7d3d6a | |
| parent | 6e9508c16c4862f9145376372ec2eaffac0b6a3e (diff) | |
fix target_link_libraries
| -rw-r--r-- | xmake/plugins/project/cmake/cmakelists.lua | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/xmake/plugins/project/cmake/cmakelists.lua b/xmake/plugins/project/cmake/cmakelists.lua index aebc3ec89..b5b6f6b26 100644 --- a/xmake/plugins/project/cmake/cmakelists.lua +++ b/xmake/plugins/project/cmake/cmakelists.lua @@ -1007,16 +1007,27 @@ function _add_target_link_libraries(cmakelists, target, outputdir) end end - if #target:objectfiles() > objectfiles_set:size() or #object_deps ~= 0 then + local has_links = #target:objectfiles() > objectfiles_set:size() + if has_links then cmakelists:print("target_link_libraries(%s PRIVATE", target:name()) for _, objectfile in ipairs(target:objectfiles()) do if not objectfiles_set:has(objectfile) then cmakelists:print(" " .. _get_relative_unix_path_to_cmake(objectfile, outputdir)) end end + end + + if #object_deps ~= 0 then + if not has_links then + cmakelists:print("target_link_libraries(%s PRIVATE", target:name()) + has_links = true + end for _, dep in ipairs(object_deps) do cmakelists:print(" " .. dep) end + end + + if has_links then cmakelists:print(")") end end |
