diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -495,6 +495,15 @@ endif() endif() + # LINK_COMPONENTS is necessary to allow libLLVM.so to be properly + # substituted for individual library dependencies if LLVM_LINK_LLVM_DYLIB + get_property(llvm_component_libs GLOBAL PROPERTY LLVM_COMPONENT_LIBS) + foreach(lib ${ARG_LINK_LIBS}) + if(${lib} IN_LIST llvm_component_libs) + message(SEND_ERROR "${name} specifies LINK_LIBS ${lib}, but LINK_LIBS cannot be used for LLVM libraries. Please use LINK_COMPONENTS instead.") + endif() + endforeach() + if(ARG_SHARED AND ARG_STATIC) # static set(name_static "${name}_static")