Refine logic of parsing PNG version#24754
Conversation
|
I don't know why there is a cmake warning. How can I reproduce the warning? |
They are CI internal checks that build configuration is not changed by mistake. Need to investigate if could remove that from everywhere. |
Currently, if `PNG_FOUND`, cmake scripts will check include and parse header while we can use `PNG_VERSION_STRING` conveniently. If `BUILD_PNG`, parse version from `PNG_LIBPNG_VER_STRING` directly is more convenient than parsing major, minor and patch and concatenate them. The comment of png.h also supports this. ``` /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ ``` https://github.com/glennrp/libpng/blob/libpng16/png.h#L287 This patch also modifies `ocv_parse_header_version` macro to receive another parameter to make it more general. The reason why changing `PNG_VERSION` to `PNG_VERSION_STRING` is to be consistent with cmake's FindPNG. This patch removes `HAVE_LIBPNG_PNG_H` variable because `PNG_INCLUDE_DIR` is where to find png.h, etc according to https://cmake.org/cmake/help/latest/module/FindPNG.html. This patch also removes `PNG_PNG_INCLUDE_DIR` variable which is an advanced variable used in cmake's FindPNG and is not used in opencv.
c8ef35f to
4546f40
Compare
|
@opencv-alalek Thanks for the review. I think we can safely remove This patch removes |
opencv-alalek
left a comment
There was a problem hiding this comment.
LGTM 👍 Thank you for contribution!
Currently, if
PNG_FOUND, cmake scripts will check include and parse header while we can usePNG_VERSION_STRINGconveniently. IfBUILD_PNG, parse version fromPNG_LIBPNG_VER_STRINGdirectly is more convenient than parsing major, minor and patch and concatenate them.The comment of png.h also supports this.
https://github.com/glennrp/libpng/blob/libpng16/png.h#L287
This patch also modifies
ocv_parse_header_versionmacro to receive another parameter to make it more general.The reason why changing
PNG_VERSIONtoPNG_VERSION_STRINGis to be consistent with cmake's FindPNG.Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.