aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Podsvirov <konstantin@podsvirov.pro>2016-08-02 22:37:36 +0300
committerKonstantin Podsvirov <konstantin@podsvirov.pro>2016-08-02 22:37:36 +0300
commiteefd1fdd488eba88834a41d1008e0a8f1ae2a41c (patch)
tree89bcece5ca1169a18d993beb77d57c8eb4a15d37
parent33d2b2a04fba0f54a29b03f83f78b3a0c2000bd1 (diff)
downloadprotobuf-eefd1fdd488eba88834a41d1008e0a8f1ae2a41c.tar.gz
protobuf-eefd1fdd488eba88834a41d1008e0a8f1ae2a41c.tar.bz2
protobuf-eefd1fdd488eba88834a41d1008e0a8f1ae2a41c.zip
CMake: Auto find ZLIB from package config if nedded
-rw-r--r--cmake/CMakeLists.txt2
-rw-r--r--cmake/protobuf-config.cmake.in3
2 files changed, 5 insertions, 0 deletions
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")