prefer openssl and zlib targets over library paths
diff --git a/lib/c_glib/CMakeLists.txt b/lib/c_glib/CMakeLists.txt
index 218f7dd..3557123 100644
--- a/lib/c_glib/CMakeLists.txt
+++ b/lib/c_glib/CMakeLists.txt
@@ -97,10 +97,16 @@
# 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