1 diff --git a/cmake/OpenCVFindLibsGrfmt.cmake b/cmake/OpenCVFindLibsGrfmt.cmake
2 index 00886cc131..e412771322 100644
3 --- a/cmake/OpenCVFindLibsGrfmt.cmake
4 +++ b/cmake/OpenCVFindLibsGrfmt.cmake
5 @@ -257,23 +257,12 @@ endif()
6 # --- OpenEXR (optional) ---
8 ocv_clear_vars(HAVE_OPENEXR)
9 - if(NOT BUILD_OPENEXR)
10 - ocv_clear_internal_cache_vars(OPENEXR_INCLUDE_PATHS OPENEXR_LIBRARIES OPENEXR_ILMIMF_LIBRARY OPENEXR_VERSION)
11 - include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindOpenEXR.cmake")
13 + pkg_check_modules(OPENEXR OpenEXR)
18 - ocv_clear_vars(OPENEXR_INCLUDE_PATHS OPENEXR_LIBRARIES OPENEXR_ILMIMF_LIBRARY OPENEXR_VERSION)
20 - set(OPENEXR_LIBRARIES IlmImf)
21 - add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/openexr")
22 - if(OPENEXR_VERSION) # check via TARGET doesn't work
23 - set(BUILD_OPENEXR ON)
24 - set(HAVE_OPENEXR YES)
25 - set(BUILD_OPENEXR ON)
27 + set(OPENEXR_INCLUDE_PATHS ${OPENEXR_INCLUDE_DIRS})
28 + set(OPENEXR_LIBRARIES ${OPENEXR_LIBRARIES})