mirror of
https://github.com/opencv/opencv.git
synced 2025-06-11 19:59:08 +08:00
Fix zlib version parse
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.
This commit is contained in:
parent
8fc31ee9df
commit
3a600db4ab
@ -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) ---
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user