FindZLIB.cmake 1.4 KB

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