[llvm] 8303b1f - [cmake] Ensure that LINK_LIBS are dependencies for object library targets
Stephen Neuendorffer via llvm-commits
llvm-commits at lists.llvm.org
Mon May 4 08:46:29 PDT 2020
Author: Stephen Neuendorffer
Date: 2020-05-04T08:45:53-07:00
New Revision: 8303b1f46af6c9838d3338479e5db2551daae248
URL: https://github.com/llvm/llvm-project/commit/8303b1f46af6c9838d3338479e5db2551daae248
DIFF: https://github.com/llvm/llvm-project/commit/8303b1f46af6c9838d3338479e5db2551daae248.diff
LOG: [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
Added:
Modified:
llvm/cmake/modules/AddLLVM.cmake
Removed:
################################################################################
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index caba91fd8352..98ef125c0e86 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -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)
More information about the llvm-commits
mailing list