You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by em...@apache.org on 2022/09/12 13:27:00 UTC

[thrift] branch master updated: prefer openssl and zlib targets over library paths

This is an automated email from the ASF dual-hosted git repository.

emmenlau pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/thrift.git


The following commit(s) were added to refs/heads/master by this push:
     new fe73972ba prefer openssl and zlib targets over library paths
     new dba7c4326 Merge pull request #2644 from lorteddie/use-openssl-zlib-targets
fe73972ba is described below

commit fe73972ba61ca2c5fd7ebe3df1fb2aa285a09a9c
Author: Tobias Weihs <t....@mint-medical.de>
AuthorDate: Fri Aug 19 10:49:51 2022 +0200

    prefer openssl and zlib targets over library paths
---
 lib/c_glib/CMakeLists.txt | 12 +++++++++---
 lib/cpp/CMakeLists.txt    | 10 ++++++++--
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/lib/c_glib/CMakeLists.txt b/lib/c_glib/CMakeLists.txt
index 218f7dd7d..35571233d 100644
--- a/lib/c_glib/CMakeLists.txt
+++ b/lib/c_glib/CMakeLists.txt
@@ -97,10 +97,16 @@ target_link_libraries(thrift_c_glib PUBLIC ${SYSLIBS})
 
 # If Zlib is not found just ignore the Zlib stuff
 if(WITH_ZLIB)
-    include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
     ADD_LIBRARY_THRIFT(thrift_c_glib_zlib ${thrift_c_glib_zlib_SOURCES})
-    target_link_libraries(thrift_c_glib_zlib ${SYSLIBS} ${ZLIB_LIBRARIES})
-    target_link_libraries(thrift_c_glib_zlib thrift_c_glib)
+    target_link_libraries(thrift_c_glib_zlib PUBLIC ${SYSLIBS})
+    target_link_libraries(thrift_c_glib_zlib PUBLIC thrift_c_glib)
+
+    if(TARGET ZLIB::ZLIB)
+        target_link_libraries(thrift_c_glib_zlib PUBLIC ZLIB::ZLIB)
+    else()
+        include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
+        target_link_libraries(thrift_c_glib_zlib PUBLIC ${ZLIB_LIBRARIES})
+    endif()
 endif()
 
 # Install the headers
diff --git a/lib/cpp/CMakeLists.txt b/lib/cpp/CMakeLists.txt
index 13b41c5c6..6a66e5ad1 100644
--- a/lib/cpp/CMakeLists.txt
+++ b/lib/cpp/CMakeLists.txt
@@ -182,11 +182,17 @@ endif()
 
 if(WITH_ZLIB)
     find_package(ZLIB REQUIRED)
-    include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
 
     ADD_LIBRARY_THRIFT(thriftz ${thriftcppz_SOURCES})
     target_link_libraries(thriftz PUBLIC thrift)
-    target_link_libraries(thriftz PUBLIC ${ZLIB_LIBRARIES})
+
+    if(TARGET ZLIB::ZLIB)
+        target_link_libraries(thriftz PUBLIC ZLIB::ZLIB)
+    else()
+        include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
+        target_link_libraries(thriftz PUBLIC ${ZLIB_LIBRARIES})
+    endif()
+
     ADD_PKGCONFIG_THRIFT(thrift-z)
 endif()