Merge pull request #24741 from FantasqueX:fix-zlib-version-parse

Fix zlib version parse
This commit is contained in:
Alexander Smorkalov 2023-12-22 14:56:43 +03:00 committed by GitHub
commit a050285058
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -34,7 +34,7 @@ if(NOT ZLIB_FOUND)
set(ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR})
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")
endif()
# --- libavif (optional) ---

View File

@ -1430,6 +1430,18 @@ macro(ocv_parse_header2 LIBNAME HDR_PATH VARNAME)
endif()
endmacro()
# set ${LIBNAME}_VERSION_STRING to ${LIBNAME}_VERSION without quotes
macro(ocv_parse_header_version LIBNAME HDR_PATH)
ocv_clear_vars(${LIBNAME}_VERSION_STRING)
set(${LIBNAME}_H "")
if(EXISTS "${HDR_PATH}")
file(STRINGS "${HDR_PATH}" ${LIBNAME}_H REGEX "^#define[ \t]+${LIBNAME}_VERSION[ \t]+\"[^\"]*\".*$" LIMIT_COUNT 1)
endif()
if(${LIBNAME}_H)
string(REGEX REPLACE "^.*[ \t]${LIBNAME}_VERSION[ \t]+\"([0-9\.]+)\"$" "\\1" ${LIBNAME}_VERSION_STRING "${${LIBNAME}_H}")
endif()
endmacro()
################################################################################################
# short command to setup source group
function(ocv_source_group group)