opencv / opencv

Open Source Computer Vision Library
https://opencv.org
Apache License 2.0
76.54k stars 55.64k forks source link

Fix zlib-ng version parse #25577

Closed FantasqueX closed 1 month ago

FantasqueX commented 1 month ago

Currently, zlib-ng version is 'zlib ver #define ZLIB_VERSION "1.3.0.zlib-ng"'. Because ocv_parse_header_version only accepts dot and numbers and doesn't accepts 1.3.0.zlib-ng. This patch changes ocv_parse_header_version to accept all characters between parentheses.

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

sturkmen72 commented 1 month ago

-- Media I/O: -- ZLib-Ng: build (zlib ver #define ZLIB_VERSION "1.3.0.zlib-ng", zlib-ng ver 2.1.6) -- JPEG: build-libjpeg-turbo (ver 2.1.3-62) -- SIMD Support Request: YES -- SIMD Support: YES -- PNG: build (ver 1.6.37) -- HDR: YES -- SUNRASTER: YES -- PXM: YES -- PFM: YES

currently cmake output seems like above. is this PR fix this?

FantasqueX commented 1 month ago

-- Media I/O: -- ZLib-Ng: build (zlib ver #define ZLIB_VERSION "1.3.0.zlib-ng", zlib-ng ver 2.1.6) -- JPEG: build-libjpeg-turbo (ver 2.1.3-62) -- SIMD Support Request: YES -- SIMD Support: YES -- PNG: build (ver 1.6.37) -- HDR: YES -- SUNRASTER: YES -- PXM: YES -- PFM: YES

currently cmake output seems like above. is this PR fix this?

Yes

sturkmen72 commented 1 month ago

-- Media I/O: -- ZLib-Ng: build (zlib ver 1.3.0.zlib-ng, zlib-ng ver 2.1.6) -- JPEG: build-libjpeg-turbo (ver 2.1.3-62) -- SIMD Support Request: YES -- SIMD Support: YES -- PNG: build (ver 1.6.37) -- TIFF: build (ver 42 - 4.6.0) -- HDR: YES -- SUNRASTER: YES -- PXM: YES -- PFM: YES

output after patch

sturkmen72 commented 1 month ago

just a note:

define ZLIB_VERSION "1.3.1"

define ZLIB_VERNUM 0x1310

define ZLIB_VER_MAJOR 1

define ZLIB_VER_MINOR 3

define ZLIB_VER_REVISION 1

define ZLIB_VER_SUBREVISION 0

FantasqueX commented 1 month ago

-- Media I/O: -- ZLib-Ng: build (zlib ver 1.3.0.zlib-ng, zlib-ng ver 2.1.6) -- JPEG: build-libjpeg-turbo (ver 2.1.3-62) -- SIMD Support Request: YES -- SIMD Support: YES -- PNG: build (ver 1.6.37) -- TIFF: build (ver 42 - 4.6.0) -- HDR: YES -- SUNRASTER: YES -- PXM: YES -- PFM: YES

output after patch

Great, as expected.

asmorkalov commented 1 month ago

@FantasqueX please provide cmake options and platform how you got the issue. The patch looks reasonable, but I cannot repoduce the original issue.

FantasqueX commented 1 month ago

@FantasqueX please provide cmake options and platform how you got the issue. The patch looks reasonable, but I cannot repoduce the original issue.

cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_ZLIB_NG=ON .. I noticed this issue on Windows 11. However, I cannot reproduce it on ArchLinux :( Windows 11: -- ZLib-Ng: build (zlib ver #define ZLIB_VERSION "1.3.0.zlib-ng", zlib-ng ver 2.1.6) ArchLinux: -- ZLib-Ng: build (zlib ver 1.3.0, zlib-ng ver 2.1.6)

FantasqueX commented 1 month ago

I successfully reproduced on ArchLinux. The reason is that other find_package commands after ocv_parse_header_version(ZLIB "${${ZLIB_LIBRARY}_SOURCE_DIR}/zlib.h.in" ZLIB_VERSION) include find_package(ZLIB) which results in ZLIB_VERSION_STRING changed. Here is the reproducing command: cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_ZLIB_NG=ON -DWITH_PNG=ON -DBUILD_PNG=ON -DWITH_TIFF=OFF -DWITH_OPENEXR=OFF -DWITH_VTK=OFF ..