[cmake] rework LLVM_LINK_LLVM_DYLIB option handling
authorAndrew Wilkins <axwalk@gmail.com>
Sat, 5 Sep 2015 08:27:33 +0000 (08:27 +0000)
committerAndrew Wilkins <axwalk@gmail.com>
Sat, 5 Sep 2015 08:27:33 +0000 (08:27 +0000)
commitf5148ebe0ac2e89cf991b7d6e01778bbb8d55034
tree190562a8ca3d744031193207a022d2a68fa07ca1
parentd2288b28e16c471f33d09ffc573a2bd6e35d6039
[cmake] rework LLVM_LINK_LLVM_DYLIB option handling

Summary:
This diff attempts to address the concerns raised in
http://reviews.llvm.org/D12488.

We introduce a new USE_SHARED option to llvm_config,
which, if set, causes the target to be linked against
libLLVM.

add_llvm_utility now uniformly disables linking against
libLLVM. These utilities are not intended for distribution,
and this keeps the option handling more centralised.

llvm-shlib is now processes before any other "tools"
subdirectories, ensuring the libLLVM target is defined
before its dependents.

One main difference from what was requested: llvm_config
does not prune LLVM_DYLIB_COMPONENTS from the components
passed into explicit_llvm_config. This is because the "all"
component does something special, adding additional
libraries (namely libLTO). Adding the component libraries
after libLLVM should not be a problem, as symbols will be
resolved in libLLVM first.

Finally, I'm not really happy with the
DISABLE_LLVM_LINK_LLVM option, but I'm not sure of a
better way to get the following:
 - link all tools and shared libraries to libLLVM if
   LLVM_LINK_LLVM_DYLIB is set
 - some way of explicitly *not* doing so for utilities
   and libLLVM itself
Suggestions for improvement here are particularly welcome.

Reviewers: beanz

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D12590

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246918 91177308-0d34-0410-b5e6-96231b3b80d8
CMakeLists.txt
cmake/modules/AddLLVM.cmake
cmake/modules/LLVM-Config.cmake
cmake/modules/TableGen.cmake
tools/llvm-shlib/CMakeLists.txt