[CMake] Change lldbAPI to be a CMake OBJECT library.
authorZachary Turner <zturner@google.com>
Tue, 24 Feb 2015 20:58:39 +0000 (20:58 +0000)
committerZachary Turner <zturner@google.com>
Tue, 24 Feb 2015 20:58:39 +0000 (20:58 +0000)
commitf4f8740eb059d74f7bdaa2a9106d910c8d12322b
tree0eb8ae2b089a4fb706df52c1ef684d1cd59173c8
parentc50508fe81ad1d0c296b93f60e4a9fe740fdb6d5
[CMake] Change lldbAPI to be a CMake OBJECT library.

An OBJECT library is a special type of CMake library that produces
no archive, has no link interface, and no link inputs.  It is like
a regular archive, just without the physical output.  To link
against an OBJECT library, you reference it in the *source* file
list of a library using the special syntax $<TARGET_OBJECTS:lldbAPI>.
This will cause every object file to be passed to the linker
independently, as opposed to a single archive being passed to the
linker.

This is *extremely* important on Windows.  lldbAPI exports all of the
SB classes using __declspec(dllexport).  Unfortunately for technical
reasons it is not possible (well, extremely difficult) to get the
linker to propagate a __declspec(dllexport) attribute from a symbol
in an object file in an archive to a DLL that links against that
archive.  The solution to this is for the DLL to link the object files
directly.  So lldbAPI must be an OBJECT library.

This fixes an issue that has been present since the duplicated
lldbAPI file lists were removed, which would cause linker failures.

As a side effect, this also makes LLDB_DISABLE_PYTHON=1 work again
on Windows, which was previously totally broken.

llvm-svn: 230380
lldb/CMakeLists.txt
lldb/cmake/LLDBDependencies.cmake
lldb/source/API/CMakeLists.txt
lldb/source/CMakeLists.txt
lldb/tools/driver/CMakeLists.txt
lldb/tools/lldb-mi/CMakeLists.txt