FindZLIB.cmake 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. ################################################################################
  2. # HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. ################################################################################
  16. # - Try to find the ZLib compression library
  17. # Once done this will define
  18. #
  19. # ZLIB_FOUND - system has the ZLib library
  20. # ZLIB_INCLUDE_DIR - the ZLib include directory
  21. # ZLIB_LIBRARIES - The libraries needed to use ZLib
  22. IF (NOT ZLIB_FOUND)
  23. IF (WIN32)
  24. SET (zlib_lib "zlib")
  25. ELSE()
  26. SET (zlib_lib "z")
  27. ENDIF()
  28. IF (NOT "${EXTERNALS_DIRECTORY}" STREQUAL "")
  29. IF (UNIX)
  30. IF (${ARCH64BIT} EQUAL 1)
  31. SET (osdir "linux64_gcc4.1.1")
  32. ELSE()
  33. SET (osdir "linux32_gcc4.1.1")
  34. ENDIF()
  35. SET (zlibver "1.2.5")
  36. ELSEIF(WIN32)
  37. IF (${ARCH64BIT} EQUAL 1)
  38. SET (osdir "Win64")
  39. ELSE()
  40. SET (osdir "Win32")
  41. ENDIF()
  42. SET (zlibver "1.2.8")
  43. ELSE()
  44. SET (osdir "unknown")
  45. SET (zlibver "unknown")
  46. ENDIF()
  47. IF (NOT ("${osdir}" STREQUAL "unknown"))
  48. FIND_PATH (ZLIB_INCLUDE_DIR NAMES zlib.h PATHS "${EXTERNALS_DIRECTORY}/zlib/${zlibver}/include" NO_DEFAULT_PATH)
  49. FIND_LIBRARY (ZLIB_LIBRARIES NAMES ${zlib_lib} PATHS "${EXTERNALS_DIRECTORY}/zlib/${zlibver}/lib/${osdir}" NO_DEFAULT_PATH)
  50. ENDIF()
  51. ENDIF()
  52. if (USE_NATIVE_LIBRARIES)
  53. # if we didn't find in externals, look in system include path
  54. FIND_PATH (ZLIB_INCLUDE_DIR NAMES zlib.h)
  55. FIND_LIBRARY (ZLIB_LIBRARIES NAMES ${zlib_lib})
  56. endif()
  57. include(FindPackageHandleStandardArgs)
  58. find_package_handle_standard_args(ZLib DEFAULT_MSG
  59. ZLIB_LIBRARIES
  60. ZLIB_INCLUDE_DIR
  61. )
  62. MARK_AS_ADVANCED(ZLIB_INCLUDE_DIR ZLIB_LIBRARIES)
  63. ENDIF()