Merge pull request #26678 from Kumataro:fix26673

OpenEXR 2.2 or earlier cannot be used with C++17 or later #26678

Close https://github.com/opencv/opencv/issues/26673
Close https://github.com/opencv/opencv/issues/25313

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
Kumataro 2025-01-24 20:18:29 +09:00 committed by GitHub
parent 9a77bef92b
commit ab77e1cfc8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 21 additions and 7 deletions

View File

@ -214,6 +214,9 @@ if(NOT OPENCV_SKIP_CMAKE_CXX_STANDARD)
if(CMAKE_CXX11_COMPILE_FEATURES)
set(HAVE_CXX11 ON)
endif()
if(CMAKE_CXX17_COMPILE_FEATURES)
set(HAVE_CXX17 ON)
endif()
endif()
if(NOT HAVE_CXX11)
ocv_check_compiler_flag(CXX "" HAVE_CXX11 "${OpenCV_SOURCE_DIR}/cmake/checks/cxx11.cpp")

View File

@ -94,17 +94,20 @@ FOREACH(SEARCH_PATH ${SEARCH_PATHS})
IF (${contents} MATCHES "#define OPENEXR_VERSION_MINOR ([0-9]+)")
SET(OPENEXR_VERSION_MINOR "${CMAKE_MATCH_1}")
ENDIF ()
FILE (STRINGS ${OPENEXR_VERSION_FILE} contents REGEX "#define OPENEXR_VERSION_PATCH ")
IF (${contents} MATCHES "#define OPENEXR_VERSION_PATCH ([0-9]+)")
SET(OPENEXR_VERSION_PATCH "${CMAKE_MATCH_1}")
ENDIF ()
ENDIF ()
ENDIF ()
IF (OPENEXR_VERSION_MAJOR AND OPENEXR_VERSION_MINOR)
set(OPENEXR_VERSION "${OPENEXR_VERSION_MAJOR}_${OPENEXR_VERSION_MINOR}")
ENDIF ()
set(OPENEXR_VERSION_MM "${OPENEXR_VERSION_MAJOR}_${OPENEXR_VERSION_MINOR}")
set(OPENEXR_VERSION "${OPENEXR_VERSION_MAJOR}.${OPENEXR_VERSION_MINOR}.${OPENEXR_VERSION_PATCH}")
ocv_find_openexr("-${OPENEXR_VERSION}")
ocv_find_openexr("-${OPENEXR_VERSION}_s")
ocv_find_openexr("-${OPENEXR_VERSION}_d")
ocv_find_openexr("-${OPENEXR_VERSION}_s_d")
ocv_find_openexr("-${OPENEXR_VERSION_MM}")
ocv_find_openexr("-${OPENEXR_VERSION_MM}_s")
ocv_find_openexr("-${OPENEXR_VERSION_MM}_d")
ocv_find_openexr("-${OPENEXR_VERSION_MM}_s_d")
ocv_find_openexr("")
ocv_find_openexr("_s")
ocv_find_openexr("_d")
@ -118,6 +121,7 @@ FOREACH(SEARCH_PATH ${SEARCH_PATHS})
UNSET(OPENEXR_VERSION_FILE)
UNSET(OPENEXR_VERSION_MAJOR)
UNSET(OPENEXR_VERSION_MINOR)
UNSET(OPENEXR_VERSION_MM)
UNSET(OPENEXR_VERSION)
ENDFOREACH()
@ -144,6 +148,11 @@ IF(OPENEXR_FOUND)
endif()
if(NOT OPENEXR_VERSION)
SET(OPENEXR_VERSION "Unknown")
else()
if(HAVE_CXX17 AND OPENEXR_VERSION VERSION_LESS "2.3.0")
message(STATUS " OpenEXR(ver ${OPENEXR_VERSION}) doesn't support C++17 and higher. Updating OpenEXR 2.3.0+ is required.")
SET(OPENEXR_FOUND FALSE)
endif()
endif()
ELSE()
IF(OPENEXR_FIND_REQUIRED)

View File

@ -317,6 +317,8 @@ All libraries required to read images in these formats are included into OpenCV
@note OpenJPEG have higher priority than JasPer which is deprecated. In order to use JasPer, OpenJPEG must be disabled.
@note (JPEG XL) OpenCV doesn't contain libjxl source code, so `BUILD_JPEGXL` is not supported.
@warning OpenEXR ver 2.2 or earlier cannot be used in combination with C++17 or later. In this case, updating OpenEXR ver 2.3.0 or later is required.
### GDAL integration
`WITH_GDAL` (default: _OFF_)