Skip to content

Commit

Permalink
Add support for finding zipconf.h in separate location; use include dirs
Browse files Browse the repository at this point in the history
LIBZIP_INCLUDE_DIRS could end up with duplicate entries, but seems to be
the simplest way of supporting headers installed to multiple locations.
  • Loading branch information
dakcarto committed Aug 15, 2017
1 parent 755980f commit 83aa1ad
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
22 changes: 19 additions & 3 deletions cmake/FindLibZip.cmake
Expand Up @@ -3,10 +3,12 @@
# Once done this will define
#
# LIBZIP_FOUND - system has the zip library
# LIBZIP_INCLUDE_DIR - the zip include directory
# LIBZIP_INCLUDE_DIRS - the zip include directories
# LIBZIP_LIBRARY - Link this to use the zip library
#
# Copyright (c) 2017, Paul Blottiere, <paul.blottiere@oslandia.com>
# Copyright (c) 2017, Larry Shaffer, <lshaffer (at) boundlessgeo (dot) com>
# Add support for finding zipconf.h in separate location, e.g. on macOS
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
Expand All @@ -20,6 +22,19 @@ FIND_PATH(LIBZIP_INCLUDE_DIR
"$ENV{INCLUDE}"
)

FIND_PATH(LIBZIP_CONF_INCLUDE_DIR
zipconf.h
PATHS
/usr/local/lib/libzip/include
/usr/lib/libzip/include
"$ENV{LIB_DIR}/lib/libzip/include"
"$ENV{LIB}/lib/libzip/include"
/usr/local/include
/usr/include
"$ENV{LIB_DIR}/include"
"$ENV{INCLUDE}"
)

FIND_LIBRARY(LIBZIP_LIBRARY
NAMES zip
PATHS
Expand All @@ -29,9 +44,10 @@ FIND_LIBRARY(LIBZIP_LIBRARY
"$ENV{LIB}"
)

IF (LIBZIP_LIBRARY AND LIBZIP_INCLUDE_DIR)
IF (LIBZIP_LIBRARY AND LIBZIP_INCLUDE_DIR AND LIBZIP_CONF_INCLUDE_DIR)
SET(LIBZIP_FOUND TRUE)
ENDIF (LIBZIP_LIBRARY AND LIBZIP_INCLUDE_DIR)
SET(LIBZIP_INCLUDE_DIRS ${LIBZIP_INCLUDE_DIR} ${LIBZIP_CONF_INCLUDE_DIR})
ENDIF (LIBZIP_LIBRARY AND LIBZIP_INCLUDE_DIR AND LIBZIP_CONF_INCLUDE_DIR)

IF (LIBZIP_FOUND)
MESSAGE(STATUS "Found libzip: ${LIBZIP_LIBRARY}")
Expand Down
1 change: 1 addition & 0 deletions src/core/CMakeLists.txt
Expand Up @@ -1119,6 +1119,7 @@ INCLUDE_DIRECTORIES(
metadata
)
INCLUDE_DIRECTORIES(SYSTEM
${LIBZIP_INCLUDE_DIRS}
${SPATIALINDEX_INCLUDE_DIR}
${PROJ_INCLUDE_DIR}
${GEOS_INCLUDE_DIR}
Expand Down

0 comments on commit 83aa1ad

Please sign in to comment.