CMake: Auto find ZLIB from package config if nedded

This commit is contained in:
Konstantin Podsvirov 2016-08-02 22:37:36 +03:00
parent 33d2b2a04f
commit eefd1fdd48
2 changed files with 5 additions and 0 deletions

View File

@ -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)

View File

@ -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")