diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 18:07:22 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 18:07:22 +0000 |
commit | c04dcc2e7d834218ef2d4194331e383402495ae1 (patch) | |
tree | 7333e38d10d75386e60f336b80c2443c1166031d /cmake/modules/FindLibZip.cmake | |
parent | Initial commit. (diff) | |
download | kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.tar.xz kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.zip |
Adding upstream version 2:20.4+dfsg.upstream/2%20.4+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'cmake/modules/FindLibZip.cmake')
-rw-r--r-- | cmake/modules/FindLibZip.cmake | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/cmake/modules/FindLibZip.cmake b/cmake/modules/FindLibZip.cmake new file mode 100644 index 0000000..df2d042 --- /dev/null +++ b/cmake/modules/FindLibZip.cmake @@ -0,0 +1,74 @@ +#.rst: +# FindLibZip +# ----------- +# Finds the LibZip library +# +# This will define the following variables:: +# +# LIBZIP_FOUND - system has LibZip +# LIBZIP_INCLUDE_DIRS - the LibZip include directory +# LIBZIP_LIBRARIES - the LibZip libraries +# +# and the following imported targets: +# +# libzip::zip - The LibZip library + +include(cmake/scripts/common/ModuleHelpers.cmake) + +set(MODULE_LC libzip) +SETUP_BUILD_VARS() + +# Check for existing lib +find_package(LIBZIP CONFIG QUIET) + +if(NOT LIBZIP_FOUND OR LIBZIP_VERSION VERSION_LESS ${${MODULE}_VER}) + # Check for dependencies + find_package(GnuTLS MODULE REQUIRED) + + # Eventually we will want Find modules for the following deps + # bzip2 + # ZLIB + + set(CMAKE_ARGS -DBUILD_DOC=OFF + -DBUILD_EXAMPLES=OFF + -DBUILD_REGRESS=OFF + -DBUILD_SHARED_LIBS=OFF + -DBUILD_TOOLS=OFF) + + set(LIBZIP_VERSION ${${MODULE}_VER}) + + BUILD_DEP_TARGET() +else() + find_path(LIBZIP_INCLUDE_DIR NAMES zip.h) + + find_library(LIBZIP_LIBRARY NAMES zip) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LibZip + REQUIRED_VARS LIBZIP_LIBRARY LIBZIP_INCLUDE_DIR + VERSION_VAR LIBZIP_VERSION) + +if(LIBZIP_FOUND) + set(LIBZIP_LIBRARIES ${LIBZIP_LIBRARY}) + set(LIBZIP_INCLUDE_DIRS ${LIBZIP_INCLUDE_DIR}) + + if(NOT TARGET libzip::zip) + add_library(libzip::zip UNKNOWN IMPORTED) + + set_target_properties(libzip::zip PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${LIBZIP_INCLUDE_DIR}" + IMPORTED_LOCATION "${LIBZIP_LIBRARY}") + + if(TARGET libzip) + add_dependencies(libzip::zip libzip) + endif() + endif() + set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP libzip::zip) +else() + if(LIBZIP_FIND_REQUIRED) + message(FATAL_ERROR "LibZip not found.") + endif() +endif() + +mark_as_advanced(LIBZIP_INCLUDE_DIR LIBZIP_LIBRARY) |