[lldb][CMake] Fix linking of gdb-remote when LLVM_ENABLE_ZLIB is ON
authorMariusz Ceier <mceier+llvm@gmail.com>
Tue, 8 Feb 2022 07:26:22 +0000 (23:26 -0800)
committerFangrui Song <i@maskray.me>
Tue, 8 Feb 2022 07:26:22 +0000 (23:26 -0800)
When LLVM_ENABLE_ZLIB is ON gdb-remote should link against ZLIB::ZLIB.

This fixes
```
/mnt/b/yoe/master/build/tmp/hosttools/ld: lib/liblldbPluginProcessGDBRemote.a(GDBRemoteCommunication.cpp.o): in function `lldb_private::process_gdb_remote::GDBRemoteCommunication::DecompressPacket() [clone .localalias]':
GDBRemoteCommunication.cpp:(.text._ZN12lldb_private18process_gdb_remote22GDBRemoteCommunication16DecompressPacketEv+0x59a): undefined reference to `inflateInit2_'
/mnt/b/yoe/master/build/tmp/hosttools/ld: GDBRemoteCommunication.cpp:(.text._ZN12lldb_private18process_gdb_remote22GDBRemoteCommunication16DecompressPacketEv+0x5af): undefined reference to `inflate'
```

Reviewed By: JDevlieghere, MaskRay

Differential Revision: https://reviews.llvm.org/D119186

lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt

index 3a1a0e4..e0c7981 100644 (file)
@@ -15,6 +15,10 @@ if(HAVE_LIBCOMPRESSION)
   set(LIBCOMPRESSION compression)
 endif()
 
+if(LLVM_ENABLE_ZLIB)
+  list(APPEND LLDB_SYSTEM_LIBS ZLIB::ZLIB)
+endif()
+
 add_lldb_library(lldbPluginProcessGDBRemote PLUGIN
   GDBRemoteClientBase.cpp
   GDBRemoteCommunication.cpp
@@ -39,6 +43,7 @@ add_lldb_library(lldbPluginProcessGDBRemote PLUGIN
     lldbSymbol
     lldbTarget
     lldbUtility
+    ${LLDB_SYSTEM_LIBS}
     ${LLDB_PLUGINS}
     ${LIBCOMPRESSION}
   LINK_COMPONENTS