cmake: use find_package(OpenEXR) to support OpenEXR 3+

This commit is contained in:
Alexander Alekhin 2021-12-23 10:39:43 +00:00
parent 19ac54277b
commit f43fec7ee6
4 changed files with 25 additions and 2 deletions

View File

@ -224,7 +224,7 @@ OCV_OPTION(BUILD_TIFF "Build libtiff from source" (WIN32
OCV_OPTION(BUILD_JASPER "Build libjasper from source" (WIN32 OR ANDROID OR APPLE OR OPENCV_FORCE_3RDPARTY_BUILD) )
OCV_OPTION(BUILD_JPEG "Build libjpeg from source" (WIN32 OR ANDROID OR APPLE OR OPENCV_FORCE_3RDPARTY_BUILD) )
OCV_OPTION(BUILD_PNG "Build libpng from source" (WIN32 OR ANDROID OR APPLE OR OPENCV_FORCE_3RDPARTY_BUILD) )
OCV_OPTION(BUILD_OPENEXR "Build openexr from source" (((WIN32 OR ANDROID OR APPLE) AND NOT WINRT) OR OPENCV_FORCE_3RDPARTY_BUILD) )
OCV_OPTION(BUILD_OPENEXR "Build openexr from source" (OPENCV_FORCE_3RDPARTY_BUILD) )
OCV_OPTION(BUILD_WEBP "Build WebP from source" (((WIN32 OR ANDROID OR APPLE) AND NOT WINRT) OR OPENCV_FORCE_3RDPARTY_BUILD) )
OCV_OPTION(BUILD_TBB "Download and build TBB from source" (ANDROID OR OPENCV_FORCE_3RDPARTY_BUILD) )
OCV_OPTION(BUILD_IPP_IW "Build IPP IW from source" (NOT MINGW OR OPENCV_FORCE_3RDPARTY_BUILD) IF (X86_64 OR X86) AND NOT WINRT )
@ -306,7 +306,7 @@ OCV_OPTION(WITH_JPEG "Include JPEG support" ON
OCV_OPTION(WITH_WEBP "Include WebP support" ON
VISIBLE_IF NOT WINRT
VERIFY HAVE_WEBP)
OCV_OPTION(WITH_OPENEXR "Include ILM support via OpenEXR" BUILD_OPENEXR OR NOT CMAKE_CROSSCOMPILING
OCV_OPTION(WITH_OPENEXR "Include ILM support via OpenEXR" ((WIN32 OR ANDROID OR APPLE) OR BUILD_OPENEXR) OR NOT CMAKE_CROSSCOMPILING
VISIBLE_IF NOT APPLE_FRAMEWORK AND NOT WINRT
VERIFY HAVE_OPENEXR)
OCV_OPTION(WITH_OPENGL "Include OpenGL support" OFF

View File

@ -241,6 +241,7 @@ if(WITH_OPENEXR)
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/openexr")
if(OPENEXR_VERSION) # check via TARGET doesn't work
set(HAVE_OPENEXR YES)
set(BUILD_OPENEXR ON)
endif()
endif()
endif()

View File

@ -9,6 +9,27 @@
# OPENEXR_LIBRARIES = libraries that are needed to use OpenEXR.
#
if(NOT HAVE_CXX11)
message(STATUS "OpenEXR: enable C++11 to use external OpenEXR")
return()
endif()
if(NOT OPENCV_SKIP_OPENEXR_FIND_PACKAGE)
find_package(OpenEXR 3 QUIET)
#ocv_cmake_dump_vars(EXR)
if(OpenEXR_FOUND)
if(TARGET OpenEXR::OpenEXR) # OpenEXR 3+
set(OPENEXR_LIBRARIES OpenEXR::OpenEXR)
set(OPENEXR_INCLUDE_PATHS "")
set(OPENEXR_VERSION "${OpenEXR_VERSION}")
set(OPENEXR_FOUND 1)
return()
else()
message(STATUS "Unsupported find_package(OpenEXR) - missing OpenEXR::OpenEXR target (version ${OpenEXR_VERSION})")
endif()
endif()
endif()
SET(OPENEXR_LIBRARIES "")
SET(OPENEXR_LIBSEARCH_SUFFIXES "")
file(TO_CMAKE_PATH "$ENV{ProgramFiles}" ProgramFiles_ENV_PATH)

View File

@ -53,6 +53,7 @@
#include <ImfInputFile.h>
#include <ImfChannelList.h>
#include <ImathBox.h>
#include <ImfRgbaFile.h>
#include "grfmt_base.hpp"
namespace cv