2 # - Find minizip libraries
4 # MINIZIP_INCLUDE_DIRS - where to find minizip headers.
5 # MINIZIP_LIBRARIES - List of libraries when using minizip.
6 # MINIZIP_FOUND - True if minizip is found.
7 # MINIZIP_DLL_DIR - (Windows) Path to the minizip DLL.
8 # MINIZIP_DLL - (Windows) Name of the minizip DLL.
10 FindWSWinLibs("minizip-[0-9]" "MINIZIP_HINTS")
12 if(NOT USE_REPOSITORY)
13 find_package(PkgConfig QUIET)
14 pkg_search_module(MINIZIP QUIET minizip)
17 find_path(MINIZIP_INCLUDE_DIR
22 ${MINIZIP_INCLUDE_DIRS}
23 "${MINIZIP_HINTS}/include"
26 get_filename_component(MINIZIP_PARENT_DIR ${MINIZIP_INCLUDE_DIR} DIRECTORY)
27 if(EXISTS "${MINIZIP_PARENT_DIR}/minizip/unzip.h")
28 set(MINIZIP_INCLUDE_DIR "${MINIZIP_PARENT_DIR}")
31 find_library(MINIZIP_LIBRARY
35 ${MINIZIP_LIBRARY_DIRS}
36 "${MINIZIP_HINTS}/lib"
39 include(FindPackageHandleStandardArgs)
40 find_package_handle_standard_args(Minizip
41 REQUIRED_VARS MINIZIP_LIBRARY MINIZIP_INCLUDE_DIR
42 VERSION_VAR MINIZIP_VERSION)
45 set(MINIZIP_LIBRARIES ${MINIZIP_LIBRARY})
46 set(MINIZIP_INCLUDE_DIRS ${MINIZIP_INCLUDE_DIR})
49 # Some distributions have minizip-ng code instead of the original zlib contrib
50 # library but keep the old minizip name (because minizip-ng is
51 # better maintained and provides a compatibility layer). However the
52 # minizip-ng compatibility layer has some issues. We need to check
53 # for renamed struct members to avoid an endless game of whack-a-mole.
54 include(CheckStructHasMember)
55 check_struct_has_member("zip_fileinfo" "dos_date" "minizip/zip.h" HAVE_MZCOMPAT_DOS_DATE)
58 set(MINIZIP_DLL_DIR "${MINIZIP_HINTS}/bin"
59 CACHE PATH "Path to Minizip DLL"
61 file(GLOB _minizip_dll RELATIVE "${MINIZIP_DLL_DIR}"
62 "${MINIZIP_DLL_DIR}/minizip.dll"
64 set(MINIZIP_DLL ${_minizip_dll}
65 CACHE FILEPATH "Minizip DLL file name"
67 file(GLOB _minizip_pdb RELATIVE "${MINIZIP_DLL_DIR}"
68 "${MINIZIP_DLL_DIR}/minizip.pdb"
70 set(MINIZIP_PDB ${_minizip_pdb}
71 CACHE FILEPATH "Minizip PDB file name"
73 mark_as_advanced(MINIZIP_DLL_DIR MINIZIP_DLL MINIZIP_PDB)
76 set(MINIZIP_LIBRARIES)
77 set(MINIZIP_INCLUDE_DIRS)
82 mark_as_advanced(MINIZIP_LIBRARIES MINIZIP_INCLUDE_DIRS)