From 8141a5026ca6b9add5d50c2b741eeff8f93a280a Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Fri, 24 Feb 2012 13:53:22 +0000 Subject: [PATCH] Refactored cmake for 3rdparty libs --- 3rdparty/CMakeLists.txt | 14 +---- 3rdparty/libjasper/CMakeLists.txt | 32 +++++------ 3rdparty/libjpeg/CMakeLists.txt | 25 ++++----- 3rdparty/libpng/CMakeLists.txt | 23 ++++---- 3rdparty/libtiff/CMakeLists.txt | 33 +++++------ 3rdparty/zlib/CMakeLists.txt | 2 +- CMakeLists.txt | 114 +++++++++++--------------------------- cmake/OpenCVIOLibs.cmake | 94 +++++++++++++++++++++++++++++++ cmake/OpenCVLegacyOptions.cmake | 9 +++ modules/core/CMakeLists.txt | 2 +- modules/highgui/CMakeLists.txt | 54 ++++++------------ 11 files changed, 204 insertions(+), 198 deletions(-) create mode 100644 cmake/OpenCVIOLibs.cmake diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index f02adf9..1f0f886 100644 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -1,15 +1,3 @@ -if(WITH_JASPER AND NOT JASPER_FOUND) - add_subdirectory(libjasper) -endif() -if(WITH_JPEG AND NOT JPEG_FOUND) - add_subdirectory(libjpeg) -endif() -if(WITH_PNG AND NOT PNG_FOUND) - add_subdirectory(libpng) -endif() -if(WITH_TIFF AND NOT TIFF_FOUND) - add_subdirectory(libtiff) -endif() if(WIN32) - add_subdirectory(ffmpeg) + add_subdirectory(ffmpeg) endif() diff --git a/3rdparty/libjasper/CMakeLists.txt b/3rdparty/libjasper/CMakeLists.txt index a381dbe..ca0a6f9 100644 --- a/3rdparty/libjasper/CMakeLists.txt +++ b/3rdparty/libjasper/CMakeLists.txt @@ -2,7 +2,7 @@ # CMake file for libjasper. See root CMakeLists.txt # # ---------------------------------------------------------------------------- -project(libjasper) +project(${JASPER_LIBRARY}) add_definitions(-DEXCLUDE_MIF_SUPPORT -DEXCLUDE_PNM_SUPPORT -DEXCLUDE_BMP_SUPPORT -DEXCLUDE_RAS_SUPPORT -DEXCLUDE_JPG_SUPPORT -DEXCLUDE_PGX_SUPPORT) @@ -19,40 +19,36 @@ file(GLOB lib_ext_hdrs jasper/*.h) # Define the library target: # ---------------------------------------------------------------------------------- -set(the_target "libjasper") - -add_library(${the_target} STATIC ${lib_srcs} ${lib_hdrs} ${lib_ext_hdrs}) +add_library(${JASPER_LIBRARY} STATIC ${lib_srcs} ${lib_hdrs} ${lib_ext_hdrs}) if(MSVC) - string(REPLACE "/W3" "/W0" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") - string(REPLACE "/W4" "/W0" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - add_definitions(-DJAS_WIN_MSVC_BUILD) + string(REPLACE "/W3" "/W0" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + string(REPLACE "/W4" "/W0" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + add_definitions(-DJAS_WIN_MSVC_BUILD) endif() if(UNIX) - if(CMAKE_COMPILER_IS_GNUCXX OR CV_ICC) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") - endif() + if(CMAKE_COMPILER_IS_GNUCXX OR CV_ICC) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") + endif() endif() if(CMAKE_COMPILER_IS_GNUCXX) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-implicit-function-declaration -Wno-unused") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-implicit-function-declaration -Wno-unused") endif() - - -set_target_properties(${the_target} +set_target_properties(${JASPER_LIBRARY} PROPERTIES - OUTPUT_NAME "${the_target}" + OUTPUT_NAME ${JASPER_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(${JASPER_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 ${JASPER_LIBRARY} ARCHIVE DESTINATION share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH} COMPONENT main) endif() + diff --git a/3rdparty/libjpeg/CMakeLists.txt b/3rdparty/libjpeg/CMakeLists.txt index b432701..a8d1cb3 100644 --- a/3rdparty/libjpeg/CMakeLists.txt +++ b/3rdparty/libjpeg/CMakeLists.txt @@ -2,7 +2,7 @@ # CMake file for libjpeg. See root CMakeLists.txt # # ---------------------------------------------------------------------------- -project(libjpeg) +project(${JPEG_LIBRARY}) # List of C++ files: @@ -16,35 +16,32 @@ file(GLOB lib_hdrs *.h) # Define the library target: # ---------------------------------------------------------------------------------- -set(the_target "libjpeg") - -add_library(${the_target} STATIC ${lib_srcs} ${lib_hdrs}) +add_library(${JPEG_LIBRARY} STATIC ${lib_srcs} ${lib_hdrs}) if(MSVC) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3") endif() if(UNIX) - if(CMAKE_COMPILER_IS_GNUCXX OR CV_ICC) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") - endif() + if(CMAKE_COMPILER_IS_GNUCXX OR CV_ICC) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") + endif() endif() if(CMAKE_COMPILER_IS_GNUCXX) - set_source_files_properties(jcdctmgr.c PROPERTIES COMPILE_FLAGS "-O1") + set_source_files_properties(jcdctmgr.c PROPERTIES COMPILE_FLAGS "-O1") endif() -set_target_properties(${the_target} - PROPERTIES OUTPUT_NAME "${the_target}" +set_target_properties(${JPEG_LIBRARY} + PROPERTIES OUTPUT_NAME ${JPEG_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(${JPEG_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 ${JPEG_LIBRARY} ARCHIVE DESTINATION share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH} COMPONENT main) endif() diff --git a/3rdparty/libpng/CMakeLists.txt b/3rdparty/libpng/CMakeLists.txt index bd578ca..e6592cf 100644 --- a/3rdparty/libpng/CMakeLists.txt +++ b/3rdparty/libpng/CMakeLists.txt @@ -2,7 +2,7 @@ # CMake file for libpng. See root CMakeLists.txt # # ---------------------------------------------------------------------------- -project(libpng) +project(${PNG_LIBRARY}) # List of C++ files: @@ -16,31 +16,28 @@ file(GLOB lib_hdrs *.h) # Define the library target: # ---------------------------------------------------------------------------------- -set(the_target "libpng") - -add_library(${the_target} STATIC ${lib_srcs} ${lib_hdrs}) +add_library(${PNG_LIBRARY} STATIC ${lib_srcs} ${lib_hdrs}) if(MSVC) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3") endif() if(UNIX) - if(CMAKE_COMPILER_IS_GNUCXX OR CV_ICC) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") - endif() + if(CMAKE_COMPILER_IS_GNUCXX OR CV_ICC) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") + endif() endif() -set_target_properties(${the_target} - PROPERTIES OUTPUT_NAME "${the_target}" +set_target_properties(${PNG_LIBRARY} + PROPERTIES OUTPUT_NAME ${PNG_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(${PNG_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 ${PNG_LIBRARY} ARCHIVE DESTINATION share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH} COMPONENT main) endif() diff --git a/3rdparty/libtiff/CMakeLists.txt b/3rdparty/libtiff/CMakeLists.txt index ce2904a..6f08910 100644 --- a/3rdparty/libtiff/CMakeLists.txt +++ b/3rdparty/libtiff/CMakeLists.txt @@ -2,7 +2,7 @@ # CMake file for libtiff. See root CMakeLists.txt # # ---------------------------------------------------------------------------- -project(libtiff) +project(${TIFF_LIBRARY}) # List of C++ files: @@ -13,7 +13,7 @@ add_definitions(-DHAVE_STRING_H=1) # The .cpp files: set(lib_srcs - t4.h + t4.h tiffio.hxx tiffiop.h tif_aux.c @@ -60,50 +60,47 @@ set(lib_srcs ) if(UNIX) - set(lib_srcs ${lib_srcs} tif_unix.c) + set(lib_srcs ${lib_srcs} tif_unix.c) endif() if(WIN32) - set(lib_srcs ${lib_srcs} tif_win32.c) + set(lib_srcs ${lib_srcs} tif_win32.c) endif(WIN32) #if(APPLE) -# set(lib_srcs ${lib_srcs} tif_apple.c) +# set(lib_srcs ${lib_srcs} tif_apple.c) #endif(APPLE) file(GLOB lib_hdrs *.h*) -set(the_target "libtiff") - if(MSVC) - string(REPLACE "/W4" "/W0" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") - string(REPLACE "/W4" "/W0" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + string(REPLACE "/W4" "/W0" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + string(REPLACE "/W4" "/W0" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") endif() if(UNIX) - if(CMAKE_COMPILER_IS_GNUCXX OR CV_ICC) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") - endif() + if(CMAKE_COMPILER_IS_GNUCXX OR CV_ICC) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") + endif() endif() -add_library(${the_target} STATIC ${lib_srcs} ${lib_hdrs}) +add_library(${TIFF_LIBRARY} STATIC ${lib_srcs} ${lib_hdrs}) if(CMAKE_COMPILER_IS_GNUCXX) set_source_files_properties(tif_stream.cxx PROPERTIES COMPILE_FLAGS "-Wno-sign-compare") endif() -set_target_properties(${the_target} +set_target_properties(${TIFF_LIBRARY} PROPERTIES - OUTPUT_NAME "${the_target}" + OUTPUT_NAME "${TIFF_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(${TIFF_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 ${TIFF_LIBRARY} ARCHIVE DESTINATION share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH} COMPONENT main) endif() diff --git a/3rdparty/zlib/CMakeLists.txt b/3rdparty/zlib/CMakeLists.txt index 6dcd2a7..26903bd 100644 --- a/3rdparty/zlib/CMakeLists.txt +++ b/3rdparty/zlib/CMakeLists.txt @@ -3,7 +3,7 @@ # # ---------------------------------------------------------------------------- -project(zlib C) +project(${ZLIB_LIBRARY} C) include(CheckTypeSize) include(CheckFunctionExists) diff --git a/CMakeLists.txt b/CMakeLists.txt index ce4c72d..9c9ef0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -148,15 +148,12 @@ 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() - # Build 3rdparty libraries under unix - set(OPENCV_BUILD_3RDPARTY_LIBS FALSE CACHE BOOL "Build 3rd party libraries") -endif() +# 3rd party libs +OCV_OPTION(BUILD_ZLIB "Build zlib from source" WIN32 OR IOS ) +OCV_OPTION(BUILD_TIFF "Build libtiff from source" WIN32 OR IOS OR ANDROID ) +OCV_OPTION(BUILD_JASPER "Build libjasper from source" WIN32 OR IOS OR ANDROID ) +OCV_OPTION(BUILD_JPEG "Build libjpeg from source" WIN32 OR IOS OR ANDROID ) +OCV_OPTION(BUILD_PNG "Build libpng from source" WIN32 OR IOS OR ANDROID ) # OpenCV installation options # =================================================== @@ -424,75 +421,9 @@ if(UNIX) add_definitions(-DHAVE_ALLOCA -DHAVE_ALLOCA_H -DHAVE_LIBPTHREAD -DHAVE_UNISTD_H) endif() endif() -if (UNIX OR WIN32) - if(NOT OPENCV_BUILD_3RDPARTY_LIBS) - message(STATUS "NOT OPENCV_BUILD_3RDPARTY_LIBS **************************************************") - if(WITH_PNG) - include(FindPNG) - if(PNG_FOUND) - CHECK_INCLUDE_FILE(${PNG_PNG_INCLUDE_DIR}/png.h HAVE_PNG_H) - CHECK_INCLUDE_FILE(${PNG_PNG_INCLUDE_DIR}/libpng/png.h HAVE_LIBPNG_PNG_H) - endif() - else() - set(PNG_FOUND FALSE) - endif() - if(WITH_TIFF) - include(FindTIFF) - else() - set(TIFF_FOUND FALSE) - endif() - if(WITH_JASPER) - include(FindJasper) - else() - set(JASPER_FOUND FALSE) - endif() - if(WITH_JPEG) - include(FindJPEG) - else() - set(JPEG_FOUND FALSE) - endif() - endif() -endif() - -if(WITH_PNG AND NOT PNG_FOUND) - set(PNG_LIBRARIES libpng) -endif() - -if(WITH_JPEG AND NOT JPEG_FOUND) - set(JPEG_LIBRARIES libjpeg) -endif() - -if(WITH_TIFF AND NOT TIFF_FOUND) - set(TIFF_LIBRARIES libtiff) -endif() - -if(WITH_JASPER AND NOT JASPER_FOUND) - set(JASPER_LIBRARIES libjasper) -endif() -################### 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() - -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() +# IO libraries +include(cmake/OpenCVIOLibs.cmake REQUIRED) #################### LATEX for dpf documentation ################## if(BUILD_DOCS) @@ -791,13 +722,30 @@ status(" OpenGL support:" HAVE_OPENGL THEN YES ELSE NO) # media status("") status(" Media I/O: ") -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) -status(" JPEG 2000:" NOT WITH_JASPER OR JASPER_FOUND THEN ${JASPER_FOUND} ELSE build) -status(" OpenEXR:" WITH_OPENEXR AND OPENEXR_FOUND THEN YES ELSE NO) +status(" ZLib:" ZLIB_FOUND THEN "${ZLIB_LIBRARY}" ELSE build) +if(WITH_JPEG) + status(" JPEG:" JPEG_FOUND THEN "${JPEG_LIBRARY}" ELSE build) +else() + status(" JPEG:" "NO") +endif() +if(WITH_PNG) + status(" PNG:" PNG_FOUND THEN "${PNG_LIBRARY}" ELSE build) +else() + status(" PNG:" "NO") +endif() +if(WITH_TIFF) + status(" TIFF:" TIFF_FOUND THEN "${TIFF_LIBRARY}" ELSE build) +else() + status(" TIFF:" "NO") +endif() +if(WITH_JASPER) + status(" JPEG 2000:" JASPER_FOUND THEN "${JASPER_LIBRARY}" ELSE build) +else() + status(" JPEG 2000:" "NO") +endif() + +status(" OpenEXR:" WITH_OPENEXR AND OPENEXR_FOUND THEN YES ELSE NO) status(" OpenNI:" HAVE_OPENNI THEN YES ELSE NO) status(" OpenNI PrimeSensor Modules:" HAVE_OPENNI_PRIME_SENSOR_MODULE THEN YES ELSE NO) diff --git a/cmake/OpenCVIOLibs.cmake b/cmake/OpenCVIOLibs.cmake new file mode 100644 index 0000000..913291c --- /dev/null +++ b/cmake/OpenCVIOLibs.cmake @@ -0,0 +1,94 @@ +################### zlib - required +if(BUILD_ZLIB) + set(ZLIB_FOUND FALSE) +else() + if(ANDROID) + set(ZLIB_FOUND TRUE) + set(ZLIB_LIBRARY z) + set(ZLIB_LIBRARIES ${ZLIB_LIBRARY}) + set(ZLIB_INCLUDE_DIR "") + else() + include(FindZLIB) + endif() +endif() + +if(NOT ZLIB_FOUND) + set(ZLIB_LIBRARY zlib) + set(ZLIB_LIBRARIES ${ZLIB_LIBRARY}) + add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/zlib") + set(ZLIB_INCLUDE_DIR "${${ZLIB_LIBRARY}_SOURCE_DIR}" "${${ZLIB_LIBRARY}_BINARY_DIR}") +endif() + +################### libtiff - optional +if(WITH_TIFF) + if(BUILD_TIFF) + set(TIFF_FOUND FALSE) + else() + include(FindTIFF) + endif() +endif() + +if(WITH_TIFF AND NOT TIFF_FOUND) + set(TIFF_LIBRARY libtiff) + set(TIFF_LIBRARIES ${TIFF_LIBRARY}) + add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libtiff") + set(TIFF_INCLUDE_DIR "${${TIFF_LIBRARY}_SOURCE_DIR}") +endif() + +################### libjpeg - optional +if(WITH_JPEG) + if(BUILD_JPEG) + set(JPEG_FOUND FALSE) + else() + include(FindJPEG) + endif() +endif() + +if(WITH_JPEG AND NOT JPEG_FOUND) + set(JPEG_LIBRARY libjpeg) + set(JPEG_LIBRARIES ${JPEG_LIBRARY}) + add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libjpeg") + set(JPEG_INCLUDE_DIR "${${JPEG_LIBRARY}_SOURCE_DIR}") +endif() + +################### libjasper - optional (should be searched after libjpeg) +if(WITH_JASPER) + if(BUILD_JASPER) + set(JASPER_FOUND FALSE) + else() + include(FindJasper) + endif() +endif() + +if(WITH_JASPER AND NOT JASPER_FOUND) + set(JASPER_LIBRARY libjasper) + set(JASPER_LIBRARIES ${JASPER_LIBRARY}) + add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libjasper") + set(JASPER_INCLUDE_DIR "${${JASPER_LIBRARY}_SOURCE_DIR}") +endif() + +################### libpng - optional +if(WITH_PNG) + if(BUILD_PNG) + set(PNG_FOUND FALSE) + else() + include(FindPNG) + if(PNG_FOUND) + check_include_file(${PNG_PNG_INCLUDE_DIR}/png.h HAVE_PNG_H) + check_include_file(${PNG_PNG_INCLUDE_DIR}/libpng/png.h HAVE_LIBPNG_PNG_H) + endif() + endif() +endif() + +if(WITH_PNG AND NOT PNG_FOUND) + set(PNG_LIBRARY libpng) + set(PNG_LIBRARIES ${PNG_LIBRARY}) + add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libpng") + set(PNG_INCLUDE_DIR "${${PNG_LIBRARY}_SOURCE_DIR}") + set(PNG_DEFINITIONS "") +endif() + +################### OpenEXR - optional +if(WITH_OPENEXR) + include(cmake/OpenCVFindOpenEXR.cmake) +endif() diff --git a/cmake/OpenCVLegacyOptions.cmake b/cmake/OpenCVLegacyOptions.cmake index 924a476..a34c9e5 100644 --- a/cmake/OpenCVLegacyOptions.cmake +++ b/cmake/OpenCVLegacyOptions.cmake @@ -13,3 +13,12 @@ ocv_legacy_option(BUILD_NEW_PYTHON_SUPPORT BUILD_opencv_python) ocv_legacy_option(BUILD_JAVA_SUPPORT BUILD_opencv_java) ocv_legacy_option(WITH_ANDROID_CAMERA BUILD_opencv_androidcamera) +if(DEFINED OPENCV_BUILD_3RDPARTY_LIBS) + set(BUILD_ZLIB ${OPENCV_BUILD_3RDPARTY_LIBS} CACHE BOOL "Set via depricated OPENCV_BUILD_3RDPARTY_LIBS" FORCE) + set(BUILD_TIFF ${OPENCV_BUILD_3RDPARTY_LIBS} CACHE BOOL "Set via depricated OPENCV_BUILD_3RDPARTY_LIBS" FORCE) + set(BUILD_JASPER ${OPENCV_BUILD_3RDPARTY_LIBS} CACHE BOOL "Set via depricated OPENCV_BUILD_3RDPARTY_LIBS" FORCE) + set(BUILD_JPEG ${OPENCV_BUILD_3RDPARTY_LIBS} CACHE BOOL "Set via depricated OPENCV_BUILD_3RDPARTY_LIBS" FORCE) + set(BUILD_PNG ${OPENCV_BUILD_3RDPARTY_LIBS} CACHE BOOL "Set via depricated OPENCV_BUILD_3RDPARTY_LIBS" FORCE) + unset(OPENCV_BUILD_3RDPARTY_LIBS CACHE) +endif() + diff --git a/modules/core/CMakeLists.txt b/modules/core/CMakeLists.txt index d18792d..88a05f3 100644 --- a/modules/core/CMakeLists.txt +++ b/modules/core/CMakeLists.txt @@ -1,5 +1,5 @@ set(the_description "The Core Functionality") -ocv_add_module(core ${ZLIB_LIBRARY}) +ocv_add_module(core ${ZLIB_LIBRARIES}) ocv_module_include_directories(${ZLIB_INCLUDE_DIR}) if(HAVE_CUDA) diff --git a/modules/highgui/CMakeLists.txt b/modules/highgui/CMakeLists.txt index 97ebd08..1d7dc50 100644 --- a/modules/highgui/CMakeLists.txt +++ b/modules/highgui/CMakeLists.txt @@ -11,58 +11,38 @@ set(GRFMT_LIBS "") if(WITH_PNG OR WITH_TIFF OR WITH_OPENEXR) include_directories(${ZLIB_INCLUDE_DIR}) - set(GRFMT_LIBS ${GRFMT_LIBS} ${ZLIB_LIBRARY}) + set(GRFMT_LIBS ${GRFMT_LIBS} ${ZLIB_LIBRARIES}) endif() if(WITH_JPEG) - add_definitions(-DHAVE_JPEG) - if(JPEG_FOUND) - include_directories(${JPEG_INCLUDE_DIR}) - set(GRFMT_LIBS ${GRFMT_LIBS} ${JPEG_LIBRARIES}) - else() - include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/libjpeg") - set(GRFMT_LIBS ${GRFMT_LIBS} libjpeg) - endif() + add_definitions(-DHAVE_JPEG) + include_directories(${JPEG_INCLUDE_DIR}) + set(GRFMT_LIBS ${GRFMT_LIBS} ${JPEG_LIBRARIES}) endif() if(WITH_PNG) - add_definitions(-DHAVE_PNG) - if(PNG_FOUND) - add_definitions(${PNG_DEFINITIONS}) - include_directories(${PNG_INCLUDE_DIR}) - set(GRFMT_LIBS ${GRFMT_LIBS} ${PNG_LIBRARIES}) - else() - include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/libpng") - set(GRFMT_LIBS ${GRFMT_LIBS} libpng) - endif() + add_definitions(-DHAVE_PNG) + add_definitions(${PNG_DEFINITIONS}) + include_directories(${PNG_INCLUDE_DIR}) + set(GRFMT_LIBS ${GRFMT_LIBS} ${PNG_LIBRARIES}) endif() if(WITH_TIFF) - add_definitions(-DHAVE_TIFF) - if(TIFF_FOUND) - include_directories(${TIFF_INCLUDE_DIR}) - set(GRFMT_LIBS ${GRFMT_LIBS} ${TIFF_LIBRARIES}) - else() - include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/libtiff") - set(GRFMT_LIBS ${GRFMT_LIBS} libtiff) - endif() + add_definitions(-DHAVE_TIFF) + include_directories(${TIFF_INCLUDE_DIR}) + set(GRFMT_LIBS ${GRFMT_LIBS} ${TIFF_LIBRARIES}) endif() if(WITH_JASPER) - add_definitions(-DHAVE_JASPER) - if(JASPER_FOUND) - include_directories(${JASPER_INCLUDE_DIR}) - set(GRFMT_LIBS ${GRFMT_LIBS} ${JASPER_LIBRARIES}) - else() - include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/libjasper") - set(GRFMT_LIBS ${GRFMT_LIBS} libjasper) - endif() + add_definitions(-DHAVE_JASPER) + include_directories(${JASPER_INCLUDE_DIR}) + set(GRFMT_LIBS ${GRFMT_LIBS} ${JASPER_LIBRARIES}) endif() if(WITH_OPENEXR AND OPENEXR_FOUND) - add_definitions(-DHAVE_OPENEXR) - include_directories(${OPENEXR_INCLUDE_PATHS}) - set(GRFMT_LIBS ${GRFMT_LIBS} ${OPENEXR_LIBRARIES}) + add_definitions(-DHAVE_OPENEXR) + include_directories(${OPENEXR_INCLUDE_PATHS}) + set(GRFMT_LIBS ${GRFMT_LIBS} ${OPENEXR_LIBRARIES}) endif() file(GLOB grfmt_hdrs src/grfmt*.hpp) -- 2.7.4