FindZLIB.cmake 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. ################################################################################
  2. # Copyright (C) 2011 HPCC Systems.
  3. #
  4. # All rights reserved. This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU Affero General Public License as
  6. # published by the Free Software Foundation, either version 3 of the
  7. # License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU Affero General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU Affero General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. ################################################################################
  17. # - Try to find the ZLib compression library
  18. # Once done this will define
  19. #
  20. # ZLIB_FOUND - system has the ZLib library
  21. # ZLIB_INCLUDE_DIR - the ZLib include directory
  22. # ZLIB_LIBRARIES - The libraries needed to use ZLib
  23. IF (NOT ZLIB_FOUND)
  24. IF (WIN32)
  25. SET (zlib_lib "zlib")
  26. ELSE()
  27. SET (zlib_lib "z")
  28. ENDIF()
  29. IF (NOT ${EXTERNALS_DIRECTORY} STREQUAL "")
  30. IF (UNIX)
  31. IF (${ARCH64BIT} EQUAL 1)
  32. SET (osdir "linux64_gcc4.1.1")
  33. ELSE()
  34. SET (osdir "linux32_gcc4.1.1")
  35. ENDIF()
  36. SET (zlibver "1.2.5")
  37. ELSEIF(WIN32)
  38. IF (${ARCH64BIT} EQUAL 1)
  39. SET (osdir "win64")
  40. SET (zlibver "1.2.5")
  41. ELSE()
  42. SET (osdir "")
  43. SET (zlibver "1.2.1")
  44. ENDIF()
  45. ELSE()
  46. SET (osdir "unknown")
  47. SET (zlibver "unknown")
  48. ENDIF()
  49. IF (NOT ("${osdir}" STREQUAL "unknown"))
  50. FIND_PATH (ZLIB_INCLUDE_DIR NAMES zlib.h PATHS "${EXTERNALS_DIRECTORY}/zlib/${zlibver}/include" NO_DEFAULT_PATH)
  51. FIND_LIBRARY (ZLIB_LIBRARIES NAMES ${zlib_lib} PATHS "${EXTERNALS_DIRECTORY}/zlib/${zlibver}/lib/${osdir}" NO_DEFAULT_PATH)
  52. ENDIF()
  53. ENDIF()
  54. if (USE_NATIVE_LIBRARIES)
  55. # if we didn't find in externals, look in system include path
  56. FIND_PATH (ZLIB_INCLUDE_DIR NAMES zlib.h)
  57. FIND_LIBRARY (ZLIB_LIBRARIES NAMES ${zlib_lib})
  58. endif()
  59. include(FindPackageHandleStandardArgs)
  60. find_package_handle_standard_args(ZLib DEFAULT_MSG
  61. ZLIB_LIBRARIES
  62. ZLIB_INCLUDE_DIR
  63. )
  64. MARK_AS_ADVANCED(ZLIB_INCLUDE_DIR ZLIB_LIBRARIES)
  65. ENDIF()