From: Andrey Kamaev Date: Fri, 24 Feb 2012 12:23:34 +0000 (+0000) Subject: Modified zlib search. Use system zlib on Android by default X-Git-Tag: accepted/tizen/6.0/unified/20201030.111113~5469 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a8f0c93379ab32287f374885f42b8577496c0c62;p=platform%2Fupstream%2Fopencv.git Modified zlib search. Use system zlib on Android by default --- diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index 373df4b..f02adf9 100644 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -1,6 +1,3 @@ -if(NOT ZLIB_FOUND) - add_subdirectory(zlib) -endif() if(WITH_JASPER AND NOT JASPER_FOUND) add_subdirectory(libjasper) endif() diff --git a/3rdparty/libpng/CMakeLists.txt b/3rdparty/libpng/CMakeLists.txt index e7e91da..bd578ca 100644 --- a/3rdparty/libpng/CMakeLists.txt +++ b/3rdparty/libpng/CMakeLists.txt @@ -7,12 +7,7 @@ project(libpng) # List of C++ files: include_directories("${CMAKE_CURRENT_SOURCE_DIR}") - -if(ZLIB_FOUND) - include_directories(${ZLIB_INCLUDE_DIR}) -else() - include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../zlib") -endif() +include_directories(${ZLIB_INCLUDE_DIR}) file(GLOB lib_srcs *.c) file(GLOB lib_hdrs *.h) diff --git a/3rdparty/zlib/CMakeLists.txt b/3rdparty/zlib/CMakeLists.txt index 5e88914..6dcd2a7 100644 --- a/3rdparty/zlib/CMakeLists.txt +++ b/3rdparty/zlib/CMakeLists.txt @@ -37,11 +37,11 @@ if(MSVC) endif() configure_file("${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein" - "${OpenCV_BINARY_DIR}/zconf.h" @ONLY) -include_directories("${CMAKE_CURRENT_SOURCE_DIR}") + "${CMAKE_CURRENT_BINARY_DIR}/zconf.h" @ONLY) +include_directories("${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}") set(ZLIB_PUBLIC_HDRS - "${OpenCV_BINARY_DIR}/zconf.h" + "${CMAKE_CURRENT_BINARY_DIR}/zconf.h" zlib.h ) set(ZLIB_PRIVATE_HDRS @@ -73,10 +73,8 @@ set(ZLIB_SRCS zutil.c ) -set(the_target "zlib") - -add_library(${the_target} STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) -set_target_properties(${the_target} PROPERTIES DEFINE_SYMBOL ZLIB_DLL) +add_library(${ZLIB_LIBRARY} STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) +set_target_properties(${ZLIB_LIBRARY} PROPERTIES DEFINE_SYMBOL ZLIB_DLL) if(UNIX) if(CMAKE_COMPILER_IS_GNUCXX OR CV_ICC) @@ -88,16 +86,16 @@ if(MSVC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4013") endif() -set_target_properties(${the_target} PROPERTIES - OUTPUT_NAME "${the_target}" +set_target_properties(${ZLIB_LIBRARY} PROPERTIES + OUTPUT_NAME ${ZLIB_LIBRARY} DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}" ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/3rdparty/${OPENCV_LIB_INSTALL_PATH}" ) if(ENABLE_SOLUTION_FOLDERS) - set_target_properties(${the_target} PROPERTIES FOLDER "3rdparty") + set_target_properties(${ZLIB_LIBRARY} PROPERTIES FOLDER "3rdparty") endif() if(NOT BUILD_SHARED_LIBS) - install(TARGETS ${the_target} ARCHIVE DESTINATION share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH} COMPONENT main) + install(TARGETS ${ZLIB_LIBRARY} ARCHIVE DESTINATION share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH} COMPONENT main) endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index 721aa45..ce4c72d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -148,6 +148,9 @@ OCV_OPTION(BUILD_TESTS "Build accuracy & regression tests" OCV_OPTION(BUILD_WITH_DEBUG_INFO "Include debug info into debug libs" ON ) OCV_OPTION(BUILD_WITH_STATIC_CRT "Enables use of staticaly linked CRT for staticaly linked OpenCV" ON IF MSVC ) +# 3rdparty libs +OCV_OPTION(BUILD_ZLIB "Build zlib from source instead of installed in the system" WIN32 OR IOS ) + if(WIN32 OR ANDROID) set(OPENCV_BUILD_3RDPARTY_LIBS TRUE CACHE INTERNAL "Build 3rd party libraries") else() @@ -424,7 +427,6 @@ endif() if (UNIX OR WIN32) if(NOT OPENCV_BUILD_3RDPARTY_LIBS) message(STATUS "NOT OPENCV_BUILD_3RDPARTY_LIBS **************************************************") - include(FindZLIB) if(WITH_PNG) include(FindPNG) if(PNG_FOUND) @@ -468,12 +470,26 @@ if(WITH_JASPER AND NOT JASPER_FOUND) set(JASPER_LIBRARIES libjasper) endif() -if(NOT ZLIB_FOUND) - set(ZLIB_LIBRARY zlib) +################### zlib - always required +if(NOT BUILD_ZLIB) + if(ANDROID) + set(ZLIB_FOUND TRUE) + set(ZLIB_LIBRARY z) + set(ZLIB_INCLUDE_DIR "") + else() + include(FindZLIB) + endif() +else() + set(ZLIB_FOUND FALSE) endif() -#message(STATUS "Graphic libraries: ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARIES} ${JASPER_LIBRARIES}") +if(NOT ZLIB_FOUND) + set(ZLIB_LIBRARY zlib) + add_subdirectory(3rdparty/zlib) + set(ZLIB_INCLUDE_DIR "${OpenCV_SOURCE_DIR}/3rdparty/zlib" "${${ZLIB_LIBRARY}_BINARY_DIR}") +endif() +################### OpenEXR if(WITH_OPENEXR) include(cmake/OpenCVFindOpenEXR.cmake) endif() @@ -775,7 +791,7 @@ status(" OpenGL support:" HAVE_OPENGL THEN YES ELSE NO) # media status("") status(" Media I/O: ") -status(" ZLib:" ZLIB_FOUND THEN ${ZLIB_FOUND} ELSE build) +status(" ZLib:" ZLIB_FOUND THEN "${ZLIB_FOUND} - ${ZLIB_LIBRARY}" ELSE build) status(" JPEG:" NOT WITH_JPEG OR JPEG_FOUND THEN ${JPEG_FOUND} ELSE build) status(" PNG:" NOT WITH_PNG OR PNG_FOUND THEN ${PNG_FOUND} ELSE build) status(" TIFF:" NOT WITH_TIFF OR TIFF_FOUND THEN ${TIFF_FOUND} ELSE build) diff --git a/modules/core/CMakeLists.txt b/modules/core/CMakeLists.txt index baf0fa1..d18792d 100644 --- a/modules/core/CMakeLists.txt +++ b/modules/core/CMakeLists.txt @@ -1,9 +1,5 @@ set(the_description "The Core Functionality") ocv_add_module(core ${ZLIB_LIBRARY}) - -if(NOT ZLIB_FOUND) - set(ZLIB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/zlib") -endif() ocv_module_include_directories(${ZLIB_INCLUDE_DIR}) if(HAVE_CUDA) diff --git a/modules/highgui/CMakeLists.txt b/modules/highgui/CMakeLists.txt index 4b59bc0..97ebd08 100644 --- a/modules/highgui/CMakeLists.txt +++ b/modules/highgui/CMakeLists.txt @@ -10,13 +10,8 @@ ocv_add_module(highgui opencv_imgproc OPTIONAL opencv_androidcamera) set(GRFMT_LIBS "") if(WITH_PNG OR WITH_TIFF OR WITH_OPENEXR) - if(ZLIB_FOUND) - include_directories(${ZLIB_INCLUDE_DIR}) - set(GRFMT_LIBS ${GRFMT_LIBS} ${ZLIB_LIBRARIES}) - else() - include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/zlib") - set(GRFMT_LIBS ${GRFMT_LIBS} zlib) - endif() + include_directories(${ZLIB_INCLUDE_DIR}) + set(GRFMT_LIBS ${GRFMT_LIBS} ${ZLIB_LIBRARY}) endif() if(WITH_JPEG)