2 # Once done this will define
4 # BZIP2_FOUND - system has BZip2
5 # BZIP2_INCLUDE_DIR - the BZip2 include directory
6 # BZIP2_LIBRARIES - Link these to use BZip2
7 # BZIP2_NEED_PREFIX - this is set if the functions are prefixed with BZ2_
8 # BZIP2_VERSION_STRING - the version of BZip2 found (since CMake 2.8.8)
10 #=============================================================================
11 # Copyright 2006-2012 Kitware, Inc.
12 # Copyright 2006 Alexander Neundorf <neundorf@kde.org>
13 # Copyright 2012 Rolf Eike Beer <eike@sf-mail.de>
15 # Distributed under the OSI-approved BSD License (the "License");
16 # see accompanying file Copyright.txt for details.
18 # This software is distributed WITHOUT ANY WARRANTY; without even the
19 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 # See the License for more information.
21 #=============================================================================
22 # (To distribute this file outside of CMake, substitute the full
23 # License text for the above reference.)
25 set(_BZIP2_PATHS PATHS
26 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Bzip2;InstallPath]"
29 find_path(BZIP2_INCLUDE_DIR bzlib.h ${_BZIP2_PATHS} PATH_SUFFIXES include)
31 if (NOT BZIP2_LIBRARIES)
32 find_library(BZIP2_LIBRARY_RELEASE NAMES bz2 bzip2 ${_BZIP2_PATHS} PATH_SUFFIXES lib)
33 find_library(BZIP2_LIBRARY_DEBUG NAMES bzip2d ${_BZIP2_PATHS} PATH_SUFFIXES lib)
35 include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
36 SELECT_LIBRARY_CONFIGURATIONS(BZIP2)
39 if (BZIP2_INCLUDE_DIR AND EXISTS "${BZIP2_INCLUDE_DIR}/bzlib.h")
40 file(STRINGS "${BZIP2_INCLUDE_DIR}/bzlib.h" BZLIB_H REGEX "bzip2/libbzip2 version [0-9]+\\.[^ ]+ of [0-9]+ ")
41 string(REGEX REPLACE ".* bzip2/libbzip2 version ([0-9]+\\.[^ ]+) of [0-9]+ .*" "\\1" BZIP2_VERSION_STRING "${BZLIB_H}")
44 # handle the QUIETLY and REQUIRED arguments and set BZip2_FOUND to TRUE if
45 # all listed variables are TRUE
46 include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
47 FIND_PACKAGE_HANDLE_STANDARD_ARGS(BZip2
48 REQUIRED_VARS BZIP2_LIBRARIES BZIP2_INCLUDE_DIR
49 VERSION_VAR BZIP2_VERSION_STRING)
52 include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake)
53 CHECK_LIBRARY_EXISTS("${BZIP2_LIBRARIES}" BZ2_bzCompressInit "" BZIP2_NEED_PREFIX)
56 mark_as_advanced(BZIP2_INCLUDE_DIR)