[cmake] Make dependencies of lldb libraries private, take 2
Summary:
The dependencies of our libraries (only liblldb, really) we marked as public, which caused all
their dependencies to be repeated when linking any executables to them. This is a problem because
then all the .a files could end up being linked twice, once to liblldb and once
again to to the executable linking against liblldb (lldb, lldb-mi). As it turns out,
our build actually depends on this behavior:
- on windows, lldb does not have getopt, so it pulls it from inside liblldb, even
though getopt is not a part of the exported interface of liblldb (maybe some of
the bsd variants have this problem as well)
- lldb-mi uses llvm, which again is not exported by liblldb
This change does not actually fix these problems (that is going to be a hard
one), but it does make them explicit by moving this magic from add_lldb_library
to the places the executable targets are defined. That way, I can link the
additional .a files only on targets that really need it, and the other targets
can build cleanly and make sure we don't regress further. It also fixes the
LLVM_LINK_LLVM_DYLIB build on linux.
Reviewers: zturner, beanz
Subscribers: ki.stfu, lldb-commits, mgorny
Differential Revision: https://reviews.llvm.org/D25680
llvm-svn: 284466
2016-10-18 10:26:57 +00:00
|
|
|
include(${LLDB_PROJECT_ROOT}/cmake/LLDBDependencies.cmake)
|
|
|
|
|
2017-01-31 20:43:05 +00:00
|
|
|
if ((CMAKE_SYSTEM_NAME MATCHES "Windows") OR
|
|
|
|
(CMAKE_SYSTEM_NAME MATCHES "NetBSD" ))
|
|
|
|
# These targets do not have getopt support, so they rely on the one provided by
|
|
|
|
# liblldb. However, getopt is not a part of the liblldb interface, so we have
|
|
|
|
# to link against the constituent libraries manually. Note that this is
|
|
|
|
# extremely scary as it introduces ODR violations, and it should go away as
|
|
|
|
# soon as possible.
|
|
|
|
set(host_lib lldbHost)
|
|
|
|
endif()
|
|
|
|
|
2016-12-15 22:01:17 +00:00
|
|
|
add_lldb_tool(lldb
|
2013-09-25 10:37:32 +00:00
|
|
|
Driver.cpp
|
2013-10-15 15:46:40 +00:00
|
|
|
Platform.cpp
|
2017-01-31 20:43:05 +00:00
|
|
|
|
|
|
|
LINK_LIBS
|
|
|
|
liblldb
|
|
|
|
${host_lib}
|
|
|
|
|
|
|
|
LINK_COMPONENTS
|
|
|
|
Support
|
2013-09-25 10:37:32 +00:00
|
|
|
)
|
|
|
|
|
2014-03-03 15:50:36 +00:00
|
|
|
if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
|
2015-02-24 22:17:57 +00:00
|
|
|
add_definitions( -DIMPORT_LIBLLDB )
|
2014-03-03 15:50:36 +00:00
|
|
|
endif()
|
|
|
|
|
2015-09-16 15:34:06 +00:00
|
|
|
# Add lldb dependency on lldb-server if we can use it.
|
|
|
|
if ( LLDB_CAN_USE_LLDB_SERVER )
|
|
|
|
add_dependencies(lldb lldb-server)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Add lldb dependency on debugserver if we can use it.
|
|
|
|
if ( LLDB_CAN_USE_DEBUGSERVER )
|
|
|
|
add_dependencies(lldb debugserver)
|
|
|
|
endif()
|