opencv-4.8.1-libpng16.patch 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. From: Paul Zander <negril.nx+gentoo@gmail.com>
  2. Gentoo installs libpng as libpng16, so adjust the detection.
  3. diff --git a/cmake/OpenCVFindLibsGrfmt.cmake b/cmake/OpenCVFindLibsGrfmt.cmake
  4. index 46b5108..0ff88ea 100644
  5. --- a/cmake/OpenCVFindLibsGrfmt.cmake
  6. +++ b/cmake/OpenCVFindLibsGrfmt.cmake
  7. @@ -245,9 +245,9 @@ if(NOT HAVE_SPNG AND WITH_PNG)
  8. include(FindPNG)
  9. if(PNG_FOUND)
  10. include(CheckIncludeFile)
  11. - check_include_file("${PNG_PNG_INCLUDE_DIR}/libpng/png.h" HAVE_LIBPNG_PNG_H)
  12. - if(HAVE_LIBPNG_PNG_H)
  13. - ocv_parse_header("${PNG_PNG_INCLUDE_DIR}/libpng/png.h" PNG_VERSION_LINES PNG_LIBPNG_VER_MAJOR PNG_LIBPNG_VER_MINOR PNG_LIBPNG_VER_RELEASE)
  14. + check_include_file("${PNG_PNG_INCLUDE_DIR}/libpng16/png.h" HAVE_LIBPNG16_PNG_H)
  15. + if(HAVE_LIBPNG16_PNG_H)
  16. + ocv_parse_header("${PNG_PNG_INCLUDE_DIR}/libpng16/png.h" PNG_VERSION_LINES PNG_LIBPNG_VER_MAJOR PNG_LIBPNG_VER_MINOR PNG_LIBPNG_VER_RELEASE)
  17. else()
  18. ocv_parse_header("${PNG_PNG_INCLUDE_DIR}/png.h" PNG_VERSION_LINES PNG_LIBPNG_VER_MAJOR PNG_LIBPNG_VER_MINOR PNG_LIBPNG_VER_RELEASE)
  19. endif()
  20. @@ -255,7 +255,7 @@ if(NOT HAVE_SPNG AND WITH_PNG)
  21. endif()
  22. if(NOT PNG_FOUND)
  23. - ocv_clear_vars(PNG_LIBRARY PNG_LIBRARIES PNG_INCLUDE_DIR PNG_PNG_INCLUDE_DIR HAVE_LIBPNG_PNG_H PNG_DEFINITIONS)
  24. + ocv_clear_vars(PNG_LIBRARY PNG_LIBRARIES PNG_INCLUDE_DIR PNG_PNG_INCLUDE_DIR HAVE_LIBPNG16_PNG_H PNG_DEFINITIONS)
  25. set(PNG_LIBRARY libpng CACHE INTERNAL "")
  26. set(PNG_LIBRARIES ${PNG_LIBRARY})
  27. diff --git a/cmake/templates/cvconfig.h.in b/cmake/templates/cvconfig.h.in
  28. index d6c7875..005e9b3 100644
  29. --- a/cmake/templates/cvconfig.h.in
  30. +++ b/cmake/templates/cvconfig.h.in
  31. @@ -79,7 +79,7 @@
  32. #cmakedefine HAVE_JPEG
  33. /* libpng/png.h needs to be included */
  34. -#cmakedefine HAVE_LIBPNG_PNG_H
  35. +#cmakedefine HAVE_LIBPNG16_PNG_H
  36. /* GDCM DICOM codec */
  37. #cmakedefine HAVE_GDCM
  38. diff --git a/modules/imgcodecs/src/grfmt_png.cpp b/modules/imgcodecs/src/grfmt_png.cpp
  39. index 388a3fc..4dde181 100644
  40. --- a/modules/imgcodecs/src/grfmt_png.cpp
  41. +++ b/modules/imgcodecs/src/grfmt_png.cpp
  42. @@ -58,8 +58,8 @@
  43. # define _FILE_OFFSET_BITS 0
  44. #endif
  45. -#ifdef HAVE_LIBPNG_PNG_H
  46. -#include <libpng/png.h>
  47. +#ifdef HAVE_LIBPNG16_PNG_H
  48. +#include <libpng16/png.h>
  49. #else
  50. #include <png.h>
  51. #endif