Skip to content

Commit

Permalink
fix target_link_libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
star-hengxing committed Sep 26, 2024
1 parent 6e9508c commit 4d803f2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion xmake/plugins/project/cmake/cmakelists.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4d803f2

Please sign in to comment.