comparison cmake/FindZIP.cmake @ 281:88f9d8b406c6

Add Zip, safe wrapper around libzip
author David Demelier <markand@malikania.fr>
date Tue, 11 Nov 2014 14:03:42 +0100
parents
children
comparison
equal deleted inserted replaced
280:91eb0583df52 281:88f9d8b406c6
1 find_package(ZLIB QUIET)
2
3 find_path(
4 ZIP_INCLUDE_DIR
5 NAMES zip.h
6 )
7
8 find_library(
9 ZIP_LIBRARY
10 NAMES zip libzip
11 )
12
13 find_path(
14 ZIPCONF_INCLUDE_DIR
15 NAMES zipconf.h
16 )
17
18 if (NOT ZIPCONF_INCLUDE_DIR)
19 # zipconf.h is sometimes directly in the include/ folder but on some systems
20 # like Windows, it is installed in the lib/ directory.
21 get_filename_component(_ZIP_PRIVATE_LIBRARY "${ZIP_LIBRARY}" DIRECTORY)
22
23 find_path(
24 ZIPCONF_INCLUDE_DIR
25 NAMES zipconf.h
26 PATHS "${_ZIP_PRIVATE_LIBRARY}/libzip/include"
27 )
28 endif ()
29
30 include(FindPackageHandleStandardArgs)
31
32 find_package_handle_standard_args(
33 ZIP
34 REQUIRED_VARS ZLIB_LIBRARIES ZLIB_INCLUDE_DIRS ZIP_LIBRARY ZIP_INCLUDE_DIR ZIPCONF_INCLUDE_DIR
35 )
36
37 if (ZIP_FOUND)
38 set(ZIP_LIBRARIES ${ZIP_LIBRARY} ${ZLIB_LIBRARIES})
39 set(ZIP_INCLUDE_DIRS ${ZIP_INCLUDE_DIR} ${ZIPCONF_INCLUDE_DIR} ${ZLIB_INCLUDE_DIRS})
40 endif ()
41
42 mark_as_advanced(ZIP_LIBRARY ZIP_INCLUDE_DIR ZIPCONF_INCLUDE_DIR)