view cmake/FindZIP.cmake @ 641:fcd124e513ea

core: reintroduce VFS
author David Demelier <markand@malikania.fr>
date Sun, 01 Oct 2023 09:18:01 +0200
parents 9850089c9671
children
line wrap: on
line source

# FindZIP
# -------
#
# Find libzip library, this modules defines:
#
# ZIP_INCLUDE_DIRS, where to find zip.h
# ZIP_LIBRARIES, where to find library
# ZIP_FOUND, if it is found
#
# The following imported targets will be available:
#
# ZIP::ZIP, if found.

find_package(ZLIB QUIET)

find_path(
	ZIP_INCLUDE_DIR
	NAMES zip.h
)

find_library(
	ZIP_LIBRARY
	NAMES zip libzip
)

find_path(
	ZIPCONF_INCLUDE_DIR
	NAMES zipconf.h
)

if (NOT ZIPCONF_INCLUDE_DIR)
	# zipconf.h is sometimes directly in the include/ folder but on some systems
	# like Windows, it is installed in the lib/ directory.
	get_filename_component(_ZIP_PRIVATE_LIBRARY "${ZIP_LIBRARY}" DIRECTORY)

	find_path(
		ZIPCONF_INCLUDE_DIR
		NAMES zipconf.h
		PATHS "${_ZIP_PRIVATE_LIBRARY}/libzip/include"
	)
endif ()

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(
	ZIP
	REQUIRED_VARS ZLIB_LIBRARIES ZLIB_INCLUDE_DIRS ZIP_LIBRARY ZIP_INCLUDE_DIR ZIPCONF_INCLUDE_DIR
)

if (ZIP_FOUND)
	set(ZIP_LIBRARIES ${ZIP_LIBRARY} ${ZLIB_LIBRARIES})
	set(ZIP_INCLUDE_DIRS ${ZIP_INCLUDE_DIR} ${ZIPCONF_INCLUDE_DIR} ${ZLIB_INCLUDE_DIRS})

	if (NOT TARGET ZIP::ZIP)
		add_library(ZIP::ZIP UNKNOWN IMPORTED)
		set_target_properties(
			ZIP::ZIP
			PROPERTIES
				IMPORTED_LINK_INTERFACE_LANGUAGES "C"
				IMPORTED_LOCATION "${ZIP_LIBRARY}"
				INTERFACE_INCLUDE_DIRECTORIES "${ZIP_INCLUDE_DIRS}"
		)
	endif ()
endif ()

mark_as_advanced(ZIP_LIBRARY ZIP_INCLUDE_DIR ZIPCONF_INCLUDE_DIR)