[llvm] af78180 - [cmake] Properly support target properties.
Stephen Neuendorffer via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 17 14:08:27 PDT 2021
Author: Stephen Neuendorffer
Date: 2021-08-17T14:08:21-07:00
New Revision: af7818093677dcb4c0840aef96bc029deb219e57
URL: https://github.com/llvm/llvm-project/commit/af7818093677dcb4c0840aef96bc029deb219e57
DIFF: https://github.com/llvm/llvm-project/commit/af7818093677dcb4c0840aef96bc029deb219e57.diff
LOG: [cmake] Properly support target properties.
It's sometimes useful to use these directives when dealing with
external projects:
target_link_directories
target_link_libraries
target_include_directories
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.
Differential Revision: https://reviews.llvm.org/D108098
Added:
Modified:
llvm/cmake/modules/AddLLVM.cmake
Removed:
################################################################################
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 3e009f5061d3..2d497d0dc20c 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -486,6 +486,9 @@ function(llvm_add_library name)
# 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,11 @@ function(llvm_add_library name)
LINK_LIBS ${ARG_LINK_LIBS}
LINK_COMPONENTS ${ARG_LINK_COMPONENTS}
)
+
+ # Bring in the target link info from our original target.
+ target_link_directories(${name_static} PRIVATE $<TARGET_PROPERTY:${name},LINK_DIRECTORIES>)
+ target_link_libraries(${name_static} PRIVATE $<TARGET_PROPERTY:${name},LINK_LIBRARIES>)
+
# FIXME: Add name_static to anywhere in TARGET ${name}'s PROPERTY.
set(ARG_STATIC)
endif()
More information about the llvm-commits
mailing list