[llvm] Added support for stand-alone cmake object libraries.
authorMircea Trofin <mtrofin@google.com>
Tue, 9 Jun 2020 19:44:07 +0000 (12:44 -0700)
committerMircea Trofin <mtrofin@google.com>
Wed, 24 Jun 2020 15:18:42 +0000 (08:18 -0700)
commit62841415e685fe8857f75edd1fa92b7d1d08b875
tree2d55fbc9af80fd4a1317eae4dd283719982cd0cb
parenta0f967418f9e9030168ba934164cca56dc550634
[llvm] Added support for stand-alone cmake object libraries.

Summary:
Currently, add_llvm_library would create an OBJECT library alongside
of a STATIC / SHARED library, but losing the link interface (its
elements would become dependencies instead). To support scenarios
where linking an object library also brings in its usage
requirements, this patch adds support for 'stand-alone' OBJECT
libraries - i.e. without an accompanying SHARED/STATIC library, and
maintaining the link interface defined by the user.

This is useful for cases where, for example, we want to build a part
of a component separately. Using a STATIC target would incur the risk
that symbols not referenced in the consumer would be dropped (which may
be undesirable).

The current application is the ML part of Analysis. It should be part
of the Analysis component, so it may reference other analyses; and (in
upcoming changes) it has dependencies on optional libraries.

Reviewers: karies, davidxl, beanz, phosek, smeenai

Subscribers: mgorny, hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D81447
llvm/cmake/modules/AddLLVM.cmake