FindZLIB.cmake 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # Once done these will be defined:
  2. #
  3. # ZLIB_FOUND
  4. # ZLIB_INCLUDE_DIRS
  5. # ZLIB_LIBRARIES
  6. #
  7. find_package(PkgConfig QUIET)
  8. if (PKG_CONFIG_FOUND)
  9. pkg_check_modules(_ZLIB QUIET zlib)
  10. endif()
  11. if(CMAKE_SIZEOF_VOID_P EQUAL 8)
  12. set(_lib_suffix 64)
  13. else()
  14. set(_lib_suffix 32)
  15. endif()
  16. find_path(ZLIB_INCLUDE_DIR
  17. NAMES zlib.h
  18. HINTS
  19. ENV zlibPath${_lib_suffix}
  20. ENV zlibPath
  21. ENV DepsPath${_lib_suffix}
  22. ENV DepsPath
  23. ${zlibPath${_lib_suffix}}
  24. ${zlibPath}
  25. ${DepsPath${_lib_suffix}}
  26. ${DepsPath}
  27. ${_ZLIB_INCLUDE_DIRS}
  28. PATHS
  29. /usr/include /usr/local/include /opt/local/include /sw/include
  30. PATH_SUFFIXES
  31. include)
  32. find_library(ZLIB_LIB
  33. NAMES ${_ZLIB_LIBRARIES} z zlib zdll zlib1 zlibd zlibd1 libzlib libz
  34. HINTS
  35. ENV zlibPath${_lib_suffix}
  36. ENV zlibPath
  37. ENV DepsPath${_lib_suffix}
  38. ENV DepsPath
  39. ${zlibPath${_lib_suffix}}
  40. ${zlibPath}
  41. ${DepsPath${_lib_suffix}}
  42. ${DepsPath}
  43. ${_ZLIB_LIBRARY_DIRS}
  44. PATHS
  45. /usr/lib /usr/local/lib /opt/local/lib /sw/lib
  46. PATH_SUFFIXES
  47. lib${_lib_suffix} lib
  48. libs${_lib_suffix} libs
  49. bin${_lib_suffix} bin
  50. ../lib${_lib_suffix} ../lib
  51. ../libs${_lib_suffix} ../libs
  52. ../bin${_lib_suffix} ../bin)
  53. include(FindPackageHandleStandardArgs)
  54. find_package_handle_standard_args(ZLIB DEFAULT_MSG ZLIB_LIB ZLIB_INCLUDE_DIR)
  55. mark_as_advanced(ZLIB_INCLUDE_DIR ZLIB_LIB)
  56. if(ZLIB_FOUND)
  57. set(ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR})
  58. set(ZLIB_LIBRARIES ${ZLIB_LIB})
  59. endif()