Skip to content

Commit

Permalink
[cmake] Ensure that LINK_LIBS are dependencies for object library tar…
Browse files Browse the repository at this point in the history
…gets

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
  • Loading branch information
stephenneuendorffer committed May 4, 2020
1 parent d28f69d commit 8303b1f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions llvm/cmake/modules/AddLLVM.cmake
Expand Up @@ -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)
Expand Down

0 comments on commit 8303b1f

Please sign in to comment.