FindZLIB.cmake 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # - Find zlib
  2. # Find the native ZLIB includes and library
  3. #
  4. # ZLIB_INCLUDE_DIRS - where to find zlib.h, etc.
  5. # ZLIB_LIBRARIES - List of libraries when using zlib.
  6. # ZLIB_FOUND - True if zlib found.
  7. #
  8. # ZLIB_VERSION_STRING - The version of zlib found (x.y.z)
  9. # ZLIB_MAJOR_VERSION - the major version of zlib
  10. # ZLIB_MINOR_VERSION - The minor version of zlib
  11. # ZLIB_PATCH_VERSION - The patch version of zlib
  12. #=============================================================================
  13. # Copyright 2001-2009 Kitware, Inc.
  14. #
  15. # Distributed under the OSI-approved BSD License (the "License");
  16. # see accompanying file Copyright.txt for details.
  17. #
  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 distributed this file outside of CMake, substitute the full
  23. # License text for the above reference.)
  24. FIND_PATH(ZLIB_INCLUDE_DIR zlib.h
  25. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]/include"
  26. )
  27. SET(ZLIB_NAMES z zlib zdll)
  28. FIND_LIBRARY(ZLIB_LIBRARY
  29. NAMES
  30. ${ZLIB_NAMES}
  31. PATHS
  32. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]/lib"
  33. )
  34. MARK_AS_ADVANCED(ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
  35. IF (ZLIB_INCLUDE_DIR)
  36. FILE(READ "${ZLIB_INCLUDE_DIR}/zlib.h" ZLIB_H)
  37. STRING(REGEX REPLACE ".*#define ZLIB_VERSION \"([0-9]+)\\.([0-9]+)\\.([0-9]+)\".*" "\\1.\\2.\\3" ZLIB_VERSION_STRING "${ZLIB_H}")
  38. ENDIF()
  39. # Per-recommendation
  40. SET(ZLIB_INCLUDE_DIRS "${ZLIB_INCLUDE_DIR}")
  41. SET(ZLIB_LIBRARIES "${ZLIB_LIBRARY}")
  42. # handle the QUIETLY and REQUIRED arguments and set ZLIB_FOUND to TRUE if
  43. # all listed variables are TRUE
  44. INCLUDE(FindPackageHandleStandardArgs)
  45. FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZLIB DEFAULT_MSG ZLIB_LIBRARIES ZLIB_INCLUDE_DIRS)