2016-09-27 19:01:08 +00:00
|
|
|
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
# file Copyright.txt or https://cmake.org/licensing for details.
|
|
|
|
|
2013-10-15 15:17:36 +00:00
|
|
|
#.rst:
|
|
|
|
# FindLibArchive
|
|
|
|
# --------------
|
|
|
|
#
|
|
|
|
# Find libarchive library and headers
|
|
|
|
#
|
2010-07-29 13:52:59 +00:00
|
|
|
# The module defines the following variables:
|
|
|
|
#
|
2013-10-15 15:17:36 +00:00
|
|
|
# ::
|
|
|
|
#
|
|
|
|
# LibArchive_FOUND - true if libarchive was found
|
|
|
|
# LibArchive_INCLUDE_DIRS - include search path
|
|
|
|
# LibArchive_LIBRARIES - libraries to link
|
|
|
|
# LibArchive_VERSION - libarchive 3-component version number
|
2010-07-29 13:52:59 +00:00
|
|
|
|
|
|
|
find_path(LibArchive_INCLUDE_DIR
|
|
|
|
NAMES archive.h
|
|
|
|
PATHS
|
|
|
|
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\LibArchive;InstallPath]/include"
|
|
|
|
)
|
|
|
|
|
|
|
|
find_library(LibArchive_LIBRARY
|
|
|
|
NAMES archive libarchive
|
|
|
|
PATHS
|
|
|
|
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\LibArchive;InstallPath]/lib"
|
|
|
|
)
|
|
|
|
|
|
|
|
mark_as_advanced(LibArchive_INCLUDE_DIR LibArchive_LIBRARY)
|
|
|
|
|
|
|
|
# Extract the version number from the header.
|
|
|
|
if(LibArchive_INCLUDE_DIR AND EXISTS "${LibArchive_INCLUDE_DIR}/archive.h")
|
2016-06-03 15:37:03 +00:00
|
|
|
# The version string appears in one of three known formats in the header:
|
2010-07-29 13:52:59 +00:00
|
|
|
# #define ARCHIVE_LIBRARY_VERSION "libarchive 2.4.12"
|
|
|
|
# #define ARCHIVE_VERSION_STRING "libarchive 2.8.4"
|
2016-06-03 15:37:03 +00:00
|
|
|
# #define ARCHIVE_VERSION_ONLY_STRING "3.2.0"
|
|
|
|
# Match any format.
|
|
|
|
set(_LibArchive_VERSION_REGEX "^#define[ \t]+ARCHIVE[_A-Z]+VERSION[_A-Z]*[ \t]+\"(libarchive +)?([0-9]+)\\.([0-9]+)\\.([0-9]+)[^\"]*\".*$")
|
2010-07-29 13:52:59 +00:00
|
|
|
file(STRINGS "${LibArchive_INCLUDE_DIR}/archive.h" _LibArchive_VERSION_STRING LIMIT_COUNT 1 REGEX "${_LibArchive_VERSION_REGEX}")
|
|
|
|
if(_LibArchive_VERSION_STRING)
|
2016-06-03 15:37:03 +00:00
|
|
|
string(REGEX REPLACE "${_LibArchive_VERSION_REGEX}" "\\2.\\3.\\4" LibArchive_VERSION "${_LibArchive_VERSION_STRING}")
|
2010-07-29 13:52:59 +00:00
|
|
|
endif()
|
|
|
|
unset(_LibArchive_VERSION_REGEX)
|
|
|
|
unset(_LibArchive_VERSION_STRING)
|
|
|
|
endif()
|
|
|
|
|
2016-11-22 20:58:09 +00:00
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
2012-01-25 16:42:00 +00:00
|
|
|
find_package_handle_standard_args(LibArchive
|
|
|
|
REQUIRED_VARS LibArchive_LIBRARY LibArchive_INCLUDE_DIR
|
|
|
|
VERSION_VAR LibArchive_VERSION
|
2010-07-29 13:52:59 +00:00
|
|
|
)
|
|
|
|
unset(LIBARCHIVE_FOUND)
|
|
|
|
|
|
|
|
if(LibArchive_FOUND)
|
|
|
|
set(LibArchive_INCLUDE_DIRS ${LibArchive_INCLUDE_DIR})
|
|
|
|
set(LibArchive_LIBRARIES ${LibArchive_LIBRARY})
|
|
|
|
endif()
|