Conversation
cmake/OpenCVUtils.cmake
Outdated
| ${LIBNAME}_VERSION_PATCH | ||
| ${LIBNAME}_VERSION_TWEAK | ||
| ${LIBNAME}_VERSION_STRING) | ||
| ocv_clear_vars(${LIBNAME}_VERSION_STRING) |
There was a problem hiding this comment.
Keep compatibility!
This macro is used not for ZLIB only.
Create a new one instead, e.g. ocv_parse_header_version and use it.
There was a problem hiding this comment.
Hi, thanks for the review. I add a new macro ocv_parse_header_version . However, I don't think there is compatiblity problem. There are only two libraries zlib and japser using ocv_parse_header2. Zlib and japser only use ${LIBNAME}_VERSION_STRING not ${LIBNAME}_VERSION_MAJOR etc. I think it's safe to delete ocv_parse_header2.
0693eb8 to
6548dfe
Compare
cmake/OpenCVFindLibsGrfmt.cmake
Outdated
| set(ZLIB_LIBRARIES ${ZLIB_LIBRARY}) | ||
|
|
||
| ocv_parse_header2(ZLIB "${${ZLIB_LIBRARY}_SOURCE_DIR}/zlib.h" ZLIB_VERSION) | ||
| ocv_parse_header_version(ZLIB "${${ZLIB_LIBRARY}_SOURCE_DIR}/zlib.h" ZLIB_VERSION) |
There was a problem hiding this comment.
macro has 2 parameters.
Where is specified ZLIB_VERSION?
There was a problem hiding this comment.
We still missing ZLIB_VERSION.
CMake is switching to _VERSION variables. Others are mostly deprecated.
Perhaps we should do the same.
$ grep -R ZLIB_VERSION /usr/share/cmake/
/usr/share/cmake/Modules/FindZLIB.cmake:``ZLIB_VERSION``
/usr/share/cmake/Modules/FindZLIB.cmake: See also legacy variable ``ZLIB_VERSION_STRING``.
/usr/share/cmake/Modules/FindZLIB.cmake:``ZLIB_VERSION_MAJOR``
/usr/share/cmake/Modules/FindZLIB.cmake: Superseded by ``ZLIB_VERSION``.
/usr/share/cmake/Modules/FindZLIB.cmake:``ZLIB_VERSION_MINOR``
/usr/share/cmake/Modules/FindZLIB.cmake: Superseded by ``ZLIB_VERSION``.
/usr/share/cmake/Modules/FindZLIB.cmake:``ZLIB_VERSION_PATCH``
/usr/share/cmake/Modules/FindZLIB.cmake: Superseded by ``ZLIB_VERSION``.
/usr/share/cmake/Modules/FindZLIB.cmake:``ZLIB_VERSION_TWEAK``
/usr/share/cmake/Modules/FindZLIB.cmake: Superseded by ``ZLIB_VERSION``.
/usr/share/cmake/Modules/FindZLIB.cmake:``ZLIB_VERSION_STRING``
/usr/share/cmake/Modules/FindZLIB.cmake: Superseded by ``ZLIB_VERSION``.
/usr/share/cmake/Modules/FindZLIB.cmake: The major version of zlib. Superseded by ``ZLIB_VERSION_MAJOR``.
/usr/share/cmake/Modules/FindZLIB.cmake: The minor version of zlib. Superseded by ``ZLIB_VERSION_MINOR``.
/usr/share/cmake/Modules/FindZLIB.cmake: The patch version of zlib. Superseded by ``ZLIB_VERSION_PATCH``.
/usr/share/cmake/Modules/FindZLIB.cmake: file(STRINGS "${ZLIB_INCLUDE_DIR}/zlib.h" ZLIB_H REGEX "^#define ZLIB_VERSION \"[^\"]*\"$")
/usr/share/cmake/Modules/FindZLIB.cmake: if(ZLIB_H MATCHES "ZLIB_VERSION \"(([0-9]+)\\.([0-9]+)(\\.([0-9]+)(\\.([0-9]+))?)?)")
/usr/share/cmake/Modules/FindZLIB.cmake: set(ZLIB_VERSION_STRING "${CMAKE_MATCH_1}")
/usr/share/cmake/Modules/FindZLIB.cmake: set(ZLIB_VERSION_MAJOR "${CMAKE_MATCH_2}")
/usr/share/cmake/Modules/FindZLIB.cmake: set(ZLIB_VERSION_MINOR "${CMAKE_MATCH_3}")
/usr/share/cmake/Modules/FindZLIB.cmake: set(ZLIB_VERSION_PATCH "${CMAKE_MATCH_5}")
/usr/share/cmake/Modules/FindZLIB.cmake: set(ZLIB_VERSION_TWEAK "${CMAKE_MATCH_7}")
/usr/share/cmake/Modules/FindZLIB.cmake: set(ZLIB_VERSION_STRING "")
/usr/share/cmake/Modules/FindZLIB.cmake: set(ZLIB_VERSION_MAJOR "")
/usr/share/cmake/Modules/FindZLIB.cmake: set(ZLIB_VERSION_MINOR "")
/usr/share/cmake/Modules/FindZLIB.cmake: set(ZLIB_VERSION_PATCH "")
/usr/share/cmake/Modules/FindZLIB.cmake: set(ZLIB_VERSION_TWEAK "")
/usr/share/cmake/Modules/FindZLIB.cmake: set(ZLIB_MAJOR_VERSION "${ZLIB_VERSION_MAJOR}")
/usr/share/cmake/Modules/FindZLIB.cmake: set(ZLIB_MINOR_VERSION "${ZLIB_VERSION_MINOR}")
/usr/share/cmake/Modules/FindZLIB.cmake: set(ZLIB_PATCH_VERSION "${ZLIB_VERSION_PATCH}")
/usr/share/cmake/Modules/FindZLIB.cmake: set(ZLIB_VERSION "${ZLIB_VERSION_STRING}")
/usr/share/cmake/Modules/FindZLIB.cmake: VERSION_VAR ZLIB_VERSION
There was a problem hiding this comment.
Set both ZLIB_VERSION and ZLIB_VERSION_STRING? ZLIB_VERSION is introduced in cmake 3.26 which is quite modern. I'm not sure how much compatibility we should keep. Should we set other variables like ZLIB_MAJOR_VERSION? CMake(master branch)'s FindPNG module doesn't use these version string.
Currently cmake scripttry to use regex to parse VER_MAJOR, VER_MINOR, VER_REVISION from ZLIB_VERSION. However, ZLIB_VERSION is "1.3" which means that there is no VER_REVISION. You can reproduce using "-DBUILD_ZLIB=ON" ``` -- ZLib: zlib (ver 1.3.#define ZLIB_VERSION "1.3") ``` This patch add a new macro ocv_parse_header_version to extract version information.
6548dfe to
3a600db
Compare
Currently cmake scripttry to use regex to parse VER_MAJOR, VER_MINOR, VER_REVISION from ZLIB_VERSION. However, ZLIB_VERSION is "1.3" which means that there is no VER_REVISION.
You ca reproduce using "-DBUILD_ZLIB=ON"
I think it is OK to extract version information from VARNAME.
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.