FindLZMA.cmake 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. find_path(LZMA_INCLUDE_DIR
  2. NAMES lzma.h
  3. DOC "lzma include directory")
  4. find_library(LZMA_LIBRARY
  5. NAMES lzma
  6. DOC "lzma library")
  7. if (LZMA_INCLUDE_DIR)
  8. file(STRINGS "${LZMA_INCLUDE_DIR}/lzma/version.h" _lzma_version_lines
  9. REGEX "#define[ \t]+LZMA_VERSION_(MAJOR|MINOR|PATCH)")
  10. string(REGEX REPLACE ".*LZMA_VERSION_MAJOR *\([0-9]*\).*" "\\1" _lzma_version_major "${_lzma_version_lines}")
  11. string(REGEX REPLACE ".*LZMA_VERSION_MINOR *\([0-9]*\).*" "\\1" _lzma_version_minor "${_lzma_version_lines}")
  12. string(REGEX REPLACE ".*LZMA_VERSION_PATCH *\([0-9]*\).*" "\\1" _lzma_version_patch "${_lzma_version_lines}")
  13. set(LZMA_VERSION "${_lzma_version_major}.${_lzma_version_minor}.${_lzma_version_patch}")
  14. unset(_lzma_version_major)
  15. unset(_lzma_version_minor)
  16. unset(_lzma_version_patch)
  17. unset(_lzma_version_lines)
  18. endif ()
  19. include(FindPackageHandleStandardArgs)
  20. find_package_handle_standard_args(LZMA
  21. REQUIRED_VARS LZMA_LIBRARY LZMA_INCLUDE_DIR
  22. VERSION_VAR LZMA_VERSION)
  23. if (LZMA_FOUND)
  24. set(LZMA_LIBRARIES "${LZMA_LIBRARY}")
  25. set(LZMA_INCLUDE_DIRS "${LZMA_INCLUDE_DIR}")
  26. if (NOT TARGET LZMA::LZMA)
  27. include(vtkDetectLibraryType)
  28. vtk_detect_library_type(lzma_library_type
  29. PATH "${LZMA_LIBRARY}")
  30. add_library(LZMA::LZMA "${lzma_library_type}" IMPORTED)
  31. unset(lzma_library_type)
  32. set_target_properties(LZMA::LZMA PROPERTIES
  33. IMPORTED_LOCATION "${LZMA_LIBRARY}"
  34. IMPORTED_IMPLIB "${LZMA_LIBRARY}"
  35. INTERFACE_INCLUDE_DIRECTORIES "${LZMA_INCLUDE_DIR}")
  36. endif ()
  37. endif ()