FindBZip2.cmake 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # - Try to find BZip2
  2. # Once done this will define
  3. #
  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)
  9. #=============================================================================
  10. # Copyright 2006-2012 Kitware, Inc.
  11. # Copyright 2006 Alexander Neundorf <[email protected]>
  12. # Copyright 2012 Rolf Eike Beer <[email protected]>
  13. #
  14. # Distributed under the OSI-approved BSD License (the "License");
  15. # see accompanying file Copyright.txt for details.
  16. #
  17. # This software is distributed WITHOUT ANY WARRANTY; without even the
  18. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  19. # See the License for more information.
  20. #=============================================================================
  21. # (To distribute this file outside of CMake, substitute the full
  22. # License text for the above reference.)
  23. SET(_BZIP2_PATHS PATHS
  24. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Bzip2;InstallPath]"
  25. )
  26. FIND_PATH(BZIP2_INCLUDE_DIR bzlib.h ${_BZIP2_PATHS} PATH_SUFFIXES include)
  27. IF (NOT BZIP2_LIBRARIES)
  28. FIND_LIBRARY(BZIP2_LIBRARY_RELEASE NAMES bz2 bzip2 ${_BZIP2_PATHS} PATH_SUFFIXES lib)
  29. FIND_LIBRARY(BZIP2_LIBRARY_DEBUG NAMES bzip2d ${_BZIP2_PATHS} PATH_SUFFIXES lib)
  30. INCLUDE(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
  31. SELECT_LIBRARY_CONFIGURATIONS(BZIP2)
  32. ENDIF (NOT BZIP2_LIBRARIES)
  33. IF (BZIP2_INCLUDE_DIR AND EXISTS "${BZIP2_INCLUDE_DIR}/bzlib.h")
  34. FILE(STRINGS "${BZIP2_INCLUDE_DIR}/bzlib.h" BZLIB_H REGEX "bzip2/libbzip2 version [0-9]+\\.[^ ]+ of [0-9]+ ")
  35. STRING(REGEX REPLACE ".* bzip2/libbzip2 version ([0-9]+\\.[^ ]+) of [0-9]+ .*" "\\1" BZIP2_VERSION_STRING "${BZLIB_H}")
  36. ENDIF (BZIP2_INCLUDE_DIR AND EXISTS "${BZIP2_INCLUDE_DIR}/bzlib.h")
  37. # handle the QUIETLY and REQUIRED arguments and set BZip2_FOUND to TRUE if
  38. # all listed variables are TRUE
  39. INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  40. FIND_PACKAGE_HANDLE_STANDARD_ARGS(BZip2
  41. REQUIRED_VARS BZIP2_LIBRARIES BZIP2_INCLUDE_DIR
  42. VERSION_VAR BZIP2_VERSION_STRING)
  43. IF (BZIP2_FOUND)
  44. INCLUDE(CheckLibraryExists)
  45. CHECK_LIBRARY_EXISTS("${BZIP2_LIBRARIES}" BZ2_bzCompressInit "" BZIP2_NEED_PREFIX)
  46. ENDIF (BZIP2_FOUND)
  47. MARK_AS_ADVANCED(BZIP2_INCLUDE_DIR)