One more fix for zlib search #1902
This commit is contained in:
parent
6d3db49932
commit
c474e27c1d
3
3rdparty/zlib/CMakeLists.txt
vendored
3
3rdparty/zlib/CMakeLists.txt
vendored
@ -97,6 +97,3 @@ endif()
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
install(TARGETS ${ZLIB_LIBRARY} ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT main)
|
||||
endif()
|
||||
|
||||
ocv_parse_header2(ZLIB "${CMAKE_CURRENT_SOURCE_DIR}/zlib.h" ZLIB_VERSION PARENT_SCOPE)
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
if(${CMAKE_VERSION} VERSION_LESS "2.8.3")
|
||||
message(STATUS WITH_CUDA flag requires CMake 2.8.3. CUDA support is disabled.)
|
||||
message(STATUS "WITH_CUDA flag requires CMake 2.8.3 or newer. CUDA support is disabled.")
|
||||
return()
|
||||
endif()
|
||||
|
||||
|
@ -7,13 +7,6 @@ if(BUILD_ZLIB)
|
||||
ocv_clear_vars(ZLIB_FOUND)
|
||||
else()
|
||||
include(FindZLIB)
|
||||
if(ZLIB_VERSION_STRING)
|
||||
#cmake 2.8.2 bug - it fails to determine zlib version
|
||||
unset(ZLIB_VERSION_STRING CACHE)
|
||||
endif()
|
||||
if(ZLIB_FOUND)
|
||||
ocv_parse_header2(ZLIB "${ZLIB_INCLUDE_DIR}/zlib.h" ZLIB_VERSION "")
|
||||
endif()
|
||||
if(ZLIB_FOUND AND ANDROID)
|
||||
if(ZLIB_LIBRARY STREQUAL "${ANDROID_SYSROOT}/usr/lib/libz.so")
|
||||
set(ZLIB_LIBRARY z)
|
||||
@ -29,6 +22,8 @@ if(NOT ZLIB_FOUND)
|
||||
set(ZLIB_LIBRARIES ${ZLIB_LIBRARY})
|
||||
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/zlib")
|
||||
set(ZLIB_INCLUDE_DIR "${${ZLIB_LIBRARY}_SOURCE_DIR}" "${${ZLIB_LIBRARY}_BINARY_DIR}")
|
||||
|
||||
ocv_parse_header2(ZLIB "${${ZLIB_LIBRARY}_SOURCE_DIR}/zlib.h" ZLIB_VERSION)
|
||||
endif()
|
||||
|
||||
# --- libtiff (optional, should be searched after zlib) ---
|
||||
@ -149,3 +144,8 @@ set(PNG_VERSION "${PNG_LIBPNG_VER_MAJOR}.${PNG_LIBPNG_VER_MINOR}.${PNG_LIBPNG_VE
|
||||
if(WITH_OPENEXR)
|
||||
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindOpenEXR.cmake")
|
||||
endif()
|
||||
|
||||
#cmake 2.8.2 bug - it fails to determine zlib version
|
||||
if(ZLIB_FOUND)
|
||||
ocv_parse_header2(ZLIB "${ZLIB_INCLUDE_DIR}/zlib.h" ZLIB_VERSION)
|
||||
endif()
|
@ -468,32 +468,36 @@ macro(ocv_parse_header FILENAME FILE_VAR)
|
||||
endmacro()
|
||||
|
||||
# read single version define from the header file
|
||||
macro(ocv_parse_header2 LIBNAME HDR_PATH VARNAME SCOPE)
|
||||
macro(ocv_parse_header2 LIBNAME HDR_PATH VARNAME)
|
||||
ocv_clear_vars(${LIBNAME}_VERSION_MAJOR
|
||||
${LIBNAME}_VERSION_MAJOR
|
||||
${LIBNAME}_VERSION_MINOR
|
||||
${LIBNAME}_VERSION_PATCH
|
||||
${LIBNAME}_VERSION_TWEAK
|
||||
${LIBNAME}_VERSION_STRING)
|
||||
set(${LIBNAME}_H "")
|
||||
if(EXISTS "${HDR_PATH}")
|
||||
file(STRINGS "${HDR_PATH}" ${LIBNAME}_H REGEX "^#define[ \t]+${VARNAME}[ \t]+\"[^\"]*\".*$" LIMIT_COUNT 1)
|
||||
endif()
|
||||
|
||||
if(${LIBNAME}_H)
|
||||
string(REGEX REPLACE "^.*[ \t]${VARNAME}[ \t]+\"([0-9]+).*$" "\\1" ${LIBNAME}_VERSION_MAJOR "${${LIBNAME}_H}")
|
||||
string(REGEX REPLACE "^.*[ \t]${VARNAME}[ \t]+\"[0-9]+\\.([0-9]+).*$" "\\1" ${LIBNAME}_VERSION_MINOR "${${LIBNAME}_H}")
|
||||
string(REGEX REPLACE "^.*[ \t]${VARNAME}[ \t]+\"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" ${LIBNAME}_VERSION_PATCH "${${LIBNAME}_H}")
|
||||
set(${LIBNAME}_VERSION_MAJOR ${${LIBNAME}_VERSION_MAJOR} ${SCOPE})
|
||||
set(${LIBNAME}_VERSION_MINOR ${${LIBNAME}_VERSION_MINOR} ${SCOPE})
|
||||
set(${LIBNAME}_VERSION_PATCH ${${LIBNAME}_VERSION_PATCH} ${SCOPE})
|
||||
set(${LIBNAME}_VERSION_STRING "${${LIBNAME}_VERSION_MAJOR}.${${LIBNAME}_VERSION_MINOR}.${${LIBNAME}_VERSION_PATCH}" ${SCOPE})
|
||||
set(${LIBNAME}_VERSION_MAJOR ${${LIBNAME}_VERSION_MAJOR} ${ARGN})
|
||||
set(${LIBNAME}_VERSION_MINOR ${${LIBNAME}_VERSION_MINOR} ${ARGN})
|
||||
set(${LIBNAME}_VERSION_PATCH ${${LIBNAME}_VERSION_PATCH} ${ARGN})
|
||||
set(${LIBNAME}_VERSION_STRING "${${LIBNAME}_VERSION_MAJOR}.${${LIBNAME}_VERSION_MINOR}.${${LIBNAME}_VERSION_PATCH}")
|
||||
|
||||
# append a TWEAK version if it exists:
|
||||
set(${LIBNAME}_VERSION_TWEAK "")
|
||||
if("${${LIBNAME}_H}" MATCHES "^.*[ \t]${VARNAME}[ \t]+\"[0-9]+\\.[0-9]+\\.[0-9]+\\.([0-9]+).*$")
|
||||
set(${LIBNAME}_VERSION_TWEAK "${CMAKE_MATCH_1}" ${SCOPE})
|
||||
set(${LIBNAME}_VERSION_STRING "${${LIBNAME}_VERSION_STRING}.${${LIBNAME}_VERSION_TWEAK}" ${SCOPE})
|
||||
set(${LIBNAME}_VERSION_TWEAK "${CMAKE_MATCH_1}" ${ARGN})
|
||||
endif()
|
||||
if(${LIBNAME}_VERSION_TWEAK)
|
||||
set(${LIBNAME}_VERSION_STRING "${${LIBNAME}_VERSION_STRING}.${${LIBNAME}_VERSION_TWEAK}" ${ARGN})
|
||||
else()
|
||||
set(${LIBNAME}_VERSION_STRING "${${LIBNAME}_VERSION_STRING}" ${ARGN})
|
||||
endif()
|
||||
else()
|
||||
ocv_clear_vars(${LIBNAME}_VERSION_MAJOR
|
||||
${LIBNAME}_VERSION_MAJOR
|
||||
${LIBNAME}_VERSION_MINOR
|
||||
${LIBNAME}_VERSION_PATCH
|
||||
${LIBNAME}_VERSION_TWEAK
|
||||
${LIBNAME}_VERSION_STRING)
|
||||
endif()
|
||||
endmacro()
|
||||
|
Loading…
x
Reference in New Issue
Block a user