浏览代码

CMake: Link to ZLIB only if protobuf_WITH_ZLIB enabled

Konstantin Podsvirov 9 年之前
父节点
当前提交
38c5f2f3e6
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      cmake/libprotobuf.cmake

+ 4 - 1
cmake/libprotobuf.cmake

@@ -56,7 +56,10 @@ set(libprotobuf_files
 
 
 add_library(libprotobuf ${protobuf_SHARED_OR_STATIC}
 add_library(libprotobuf ${protobuf_SHARED_OR_STATIC}
   ${libprotobuf_lite_files} ${libprotobuf_files})
   ${libprotobuf_lite_files} ${libprotobuf_files})
-target_link_libraries(libprotobuf ${CMAKE_THREAD_LIBS_INIT} ${ZLIB_LIBRARIES})
+target_link_libraries(libprotobuf ${CMAKE_THREAD_LIBS_INIT})
+if(protobuf_WITH_ZLIB)
+    target_link_libraries(libprotobuf ${ZLIB_LIBRARIES})
+endif()
 target_include_directories(libprotobuf PUBLIC ${protobuf_source_dir}/src)
 target_include_directories(libprotobuf PUBLIC ${protobuf_source_dir}/src)
 if(MSVC AND protobuf_BUILD_SHARED_LIBS)
 if(MSVC AND protobuf_BUILD_SHARED_LIBS)
   target_compile_definitions(libprotobuf
   target_compile_definitions(libprotobuf