From 38c5f2f3e6130ba79056480ce0f5149aa5dca38e Mon Sep 17 00:00:00 2001 From: Konstantin Podsvirov Date: Thu, 28 Jul 2016 01:28:49 +0300 Subject: CMake: Link to ZLIB only if protobuf_WITH_ZLIB enabled --- cmake/libprotobuf.cmake | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmake/libprotobuf.cmake b/cmake/libprotobuf.cmake index 8930c1ca..26e1f356 100644 --- a/cmake/libprotobuf.cmake +++ b/cmake/libprotobuf.cmake @@ -56,7 +56,10 @@ set(libprotobuf_files add_library(libprotobuf ${protobuf_SHARED_OR_STATIC} ${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) if(MSVC AND protobuf_BUILD_SHARED_LIBS) target_compile_definitions(libprotobuf -- cgit v1.2.3 From 33d2b2a04fba0f54a29b03f83f78b3a0c2000bd1 Mon Sep 17 00:00:00 2001 From: Konstantin Podsvirov Date: Thu, 28 Jul 2016 01:32:32 +0300 Subject: CMake: Bugfix for protobuf_MODULE_COMPATIBLE Removed excess endif() --- cmake/protobuf-module.cmake.in | 1 - 1 file changed, 1 deletion(-) diff --git a/cmake/protobuf-module.cmake.in b/cmake/protobuf-module.cmake.in index 6e0bcf90..614e4c04 100644 --- a/cmake/protobuf-module.cmake.in +++ b/cmake/protobuf-module.cmake.in @@ -147,7 +147,6 @@ function(_protobuf_find_libraries name filename) LOCATION_RELEASE) get_target_property(${name}_LIBRARY_DEBUG protobuf::lib${filename} LOCATION_DEBUG) - endif() select_library_configurations(${name}) set(${name}_LIBRARY ${${name}_LIBRARY} PARENT_SCOPE) -- cgit v1.2.3 From eefd1fdd488eba88834a41d1008e0a8f1ae2a41c Mon Sep 17 00:00:00 2001 From: Konstantin Podsvirov Date: Tue, 2 Aug 2016 22:37:36 +0300 Subject: CMake: Auto find ZLIB from package config if nedded --- cmake/CMakeLists.txt | 2 ++ cmake/protobuf-config.cmake.in | 3 +++ 2 files changed, 5 insertions(+) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 07b176d9..f947b741 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -86,6 +86,7 @@ if (CMAKE_USE_PTHREADS_INIT) add_definitions(-DHAVE_PTHREAD) endif (CMAKE_USE_PTHREADS_INIT) +set(_protobuf_FIND_ZLIB) if (protobuf_WITH_ZLIB) find_package(ZLIB) if (ZLIB_FOUND) @@ -96,6 +97,7 @@ if (protobuf_WITH_ZLIB) # Using imported target if exists if (TARGET ZLIB::ZLIB) set(ZLIB_LIBRARIES ZLIB::ZLIB) + set(_protobuf_FIND_ZLIB "if(NOT ZLIB_FOUND)\n find_package(ZLIB)\nendif()") endif (TARGET ZLIB::ZLIB) else (ZLIB_FOUND) set(HAVE_ZLIB 0) diff --git a/cmake/protobuf-config.cmake.in b/cmake/protobuf-config.cmake.in index 37315510..a044fe5c 100644 --- a/cmake/protobuf-config.cmake.in +++ b/cmake/protobuf-config.cmake.in @@ -1,6 +1,9 @@ # User options include("${CMAKE_CURRENT_LIST_DIR}/protobuf-options.cmake") +# Depend packages +@_protobuf_FIND_ZLIB@ + # Imported targets include("${CMAKE_CURRENT_LIST_DIR}/protobuf-targets.cmake") -- cgit v1.2.3