[PATCH] D108098: [cmake] properly support target_link_directories and target_include_directories

Stephen Neuendorffer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 15 17:20:37 PDT 2021


stephenneuendorffer created this revision.
Herald added a subscriber: mgorny.
stephenneuendorffer requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

It's sometimes useful to use these directives when dealing with
external projects.  However, under certain circumstances,
llvm_add_library can generate multiple targets.  We need to transfer
these properties to the new targets.  Note that using a generator
expression is necessary because these properties will only be set
after llvm_add_library is called.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108098

Files:
  llvm/cmake/modules/AddLLVM.cmake


Index: llvm/cmake/modules/AddLLVM.cmake
===================================================================
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -486,6 +486,9 @@
     # Do add_dependencies(obj) later due to CMake issue 14747.
     list(APPEND objlibs ${obj_name})
 
+    # Bring in the target include directories from our original target
+    target_include_directories(${obj_name} PRIVATE $<TARGET_PROPERTY:${name},INCLUDE_DIRECTORIES>)
+
     set_target_properties(${obj_name} PROPERTIES FOLDER "Object Libraries")
     if(ARG_DEPENDS)
       add_dependencies(${obj_name} ${ARG_DEPENDS})
@@ -525,6 +528,10 @@
       LINK_LIBS ${ARG_LINK_LIBS}
       LINK_COMPONENTS ${ARG_LINK_COMPONENTS}
       )
+
+    # Bring in the target link directories from our original target
+    target_link_directories(${name_static} PRIVATE $<TARGET_PROPERTY:${name},LINK_DIRECTORIES>)
+
     # FIXME: Add name_static to anywhere in TARGET ${name}'s PROPERTY.
     set(ARG_STATIC)
   endif()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108098.366533.patch
Type: text/x-patch
Size: 1014 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210816/e1174215/attachment.bin>


More information about the llvm-commits mailing list