1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

[cmake] Ensure that LINK_LIBS are dependencies for object library targets

In MLIR, it is common for automatically generated headers to be included
in many places.  To avoid tracking these dependencies explicitly in
cmake, they are treated as part of a library which 'owns' the generated
header.  Users of the generated header link against the owning library.
However, object libraries don't actually 'link', so this dependence gets
lost.  This patch adds an explicit dependence for these generated headers
when creating object library targets to ensure that generated headers
are appropriately generated

Differential Revision: https://reviews.llvm.org/D79241
This commit is contained in:
Stephen Neuendorffer 2020-04-30 17:16:59 -07:00
parent bdd36c8537
commit a8645ae6d6

View File

@ -467,6 +467,16 @@ function(llvm_add_library name)
if(ARG_DEPENDS)
add_dependencies(${obj_name} ${ARG_DEPENDS})
endif()
# Treat link libraries like PUBLIC dependencies. LINK_LIBS might
# result in generating header files. Add a dependendency so that
# the generated header is created before this object library.
if(ARG_LINK_LIBS)
foreach(link_lib ${ARG_LINK_LIBS})
if(TARGET ${link_lib})
add_dependencies(${obj_name} ${link_lib})
endif()
endforeach()
endif()
endif()
if(ARG_SHARED AND ARG_STATIC)