mirror of
https://github.com/opencv/opencv.git
synced 2026-07-21 19:33:03 +04:00
Refine logic of parsing PNG version
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.
This commit is contained in:
@@ -1430,15 +1430,15 @@ 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)
|
||||
# set ${LIBNAME}_VERSION_STRING to ${LIBVER} without quotes
|
||||
macro(ocv_parse_header_version LIBNAME HDR_PATH LIBVER)
|
||||
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)
|
||||
file(STRINGS "${HDR_PATH}" ${LIBNAME}_H REGEX "^#define[ \t]+${LIBVER}[ \t]+\"[^\"]*\".*$" LIMIT_COUNT 1)
|
||||
endif()
|
||||
if(${LIBNAME}_H)
|
||||
string(REGEX REPLACE "^.*[ \t]${LIBNAME}_VERSION[ \t]+\"([0-9\.]+)\"$" "\\1" ${LIBNAME}_VERSION_STRING "${${LIBNAME}_H}")
|
||||
string(REGEX REPLACE "^.*[ \t]${LIBVER}[ \t]+\"([0-9\.]+)\"$" "\\1" ${LIBNAME}_VERSION_STRING "${${LIBNAME}_H}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user