llvm.org GIT mirror llvm / 8571df6
[CMake] Move LLVMBUILD_LIB_DEPS stuff from add_llvm_library (and LLVm-Config) to llvm_add_library to centralize target_link_libraries. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202260 91177308-0d34-0410-b5e6-96231b3b80d8 NAKAMURA Takumi 6 years ago
1 changed file(s) with 31 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
288288 endif()
289289 endif()
290290
291 if(ARG_STATIC)
292 target_link_libraries(${name} ${cmake_2_8_12_INTERFACE} ${ARG_LINK_LIBS})
291 # Add the explicit dependency information for this library.
292 #
293 # It would be nice to verify that we have the dependencies for this library
294 # name, but using get_property(... SET) doesn't suffice to determine if a
295 # property has been set to an empty value.
296 get_property(lib_deps GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_${name})
297
298 llvm_map_components_to_libnames(llvm_libs
299 ${ARG_LINK_COMPONENTS}
300 ${LLVM_LINK_COMPONENTS}
301 )
302
303 if(CMAKE_VERSION VERSION_LESS 2.8.12)
304 # Link libs w/o keywords, assuming PUBLIC.
305 target_link_libraries(${name}
306 ${ARG_LINK_LIBS}
307 ${lib_deps}
308 ${llvm_libs}
309 )
310 elseif(ARG_STATIC)
311 target_link_libraries(${name} INTERFACE
312 ${ARG_LINK_LIBS}
313 ${lib_deps}
314 ${llvm_libs}
315 )
293316 else()
294317 # MODULE|SHARED
295 target_link_libraries(${name} ${cmake_2_8_12_PRIVATE} ${ARG_LINK_LIBS})
296 endif()
297
298 llvm_config(${name} ${ARG_LINK_COMPONENTS} ${LLVM_LINK_COMPONENTS})
318 target_link_libraries(${name} PRIVATE
319 ${ARG_LINK_LIBS}
320 ${lib_deps}
321 ${llvm_libs}
322 )
323 endif()
299324
300325 if(LLVM_COMMON_DEPENDS)
301326 add_dependencies(${name} ${LLVM_COMMON_DEPENDS})
327352 set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
328353 endif()
329354 set_target_properties(${name} PROPERTIES FOLDER "Libraries")
330
331 # Add the explicit dependency information for this library.
332 #
333 # It would be nice to verify that we have the dependencies for this library
334 # name, but using get_property(... SET) doesn't suffice to determine if a
335 # property has been set to an empty value.
336 get_property(lib_deps GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_${name})
337 target_link_libraries(${name} ${cmake_2_8_12_INTERFACE} ${lib_deps})
338355 endmacro(add_llvm_library name)
339356
340357 macro(add_llvm_loadable_module name)