- fix FindOpenEXR to respect OPENEXR_ROOT

Signed-off-by: SSE4 <tomskside@gmail.com>
pull/15159/head
SSE4 5 years ago
parent 2693ed9b22
commit 2e20f06f8e
  1. 114
      cmake/OpenCVFindOpenEXR.cmake

@ -20,55 +20,89 @@ if(WIN32)
elseif(MSVC) elseif(MSVC)
SET(OPENEXR_LIBSEARCH_SUFFIXES Win32/Release Win32 Win32/Debug) SET(OPENEXR_LIBSEARCH_SUFFIXES Win32/Release Win32 Win32/Debug)
endif() endif()
else()
set(OPENEXR_ROOT "")
endif() endif()
SET(LIBRARY_PATHS SET(SEARCH_PATHS
/usr/lib "${OPENEXR_ROOT}"
/usr/local/lib /usr
/sw/lib /usr/local
/opt/local/lib /sw
"${ProgramFiles_ENV_PATH}/OpenEXR/lib/static" /opt
"${OPENEXR_ROOT}/lib") "${ProgramFiles_ENV_PATH}/OpenEXR")
FIND_PATH(OPENEXR_INCLUDE_PATH ImfRgbaFile.h MACRO(FIND_OPENEXR_LIBRARY LIBRARY_NAME LIBRARY_SUFFIX)
PATH_SUFFIXES OpenEXR string(TOUPPER "${LIBRARY_NAME}" LIBRARY_NAME_UPPER)
PATHS FIND_LIBRARY(OPENEXR_${LIBRARY_NAME_UPPER}_LIBRARY
/usr/include NAMES ${LIBRARY_NAME}${LIBRARY_SUFFIX}
/usr/local/include PATH_SUFFIXES ${OPENEXR_LIBSEARCH_SUFFIXES}
/sw/include NO_DEFAULT_PATH
/opt/local/include PATHS "${SEARCH_PATH}/lib" "${SEARCH_PATH}/lib/static")
"${ProgramFiles_ENV_PATH}/OpenEXR/include" ENDMACRO()
"${OPENEXR_ROOT}/include")
FIND_LIBRARY(OPENEXR_HALF_LIBRARY FOREACH(SEARCH_PATH ${SEARCH_PATHS})
NAMES Half FIND_PATH(OPENEXR_INCLUDE_PATH ImfRgbaFile.h
PATH_SUFFIXES ${OPENEXR_LIBSEARCH_SUFFIXES} PATH_SUFFIXES OpenEXR
PATHS ${LIBRARY_PATHS}) NO_DEFAULT_PATH
PATHS
"${SEARCH_PATH}/include")
FIND_LIBRARY(OPENEXR_IEX_LIBRARY IF (OPENEXR_INCLUDE_PATH)
NAMES Iex SET(OPENEXR_VERSION_FILE "${OPENEXR_INCLUDE_PATH}/OpenEXRConfig.h")
PATH_SUFFIXES ${OPENEXR_LIBSEARCH_SUFFIXES} IF (EXISTS ${OPENEXR_VERSION_FILE})
PATHS ${LIBRARY_PATHS}) FILE (STRINGS ${OPENEXR_VERSION_FILE} contents REGEX "#define OPENEXR_VERSION_MAJOR ")
IF (${contents} MATCHES "#define OPENEXR_VERSION_MAJOR ([0-9]+)")
SET(OPENEXR_VERSION_MAJOR "${CMAKE_MATCH_1}")
ENDIF ()
FILE (STRINGS ${OPENEXR_VERSION_FILE} contents REGEX "#define OPENEXR_VERSION_MINOR ")
IF (${contents} MATCHES "#define OPENEXR_VERSION_MINOR ([0-9]+)")
SET(OPENEXR_VERSION_MINOR "${CMAKE_MATCH_1}")
ENDIF ()
ENDIF ()
ENDIF ()
FIND_LIBRARY(OPENEXR_IMATH_LIBRARY IF (OPENEXR_VERSION_MAJOR AND OPENEXR_VERSION_MINOR)
NAMES Imath set(OPENEXR_VERSION "${OPENEXR_VERSION_MAJOR}_${OPENEXR_VERSION_MINOR}")
PATH_SUFFIXES ${OPENEXR_LIBSEARCH_SUFFIXES} ENDIF ()
PATHS ${LIBRARY_PATHS})
FIND_LIBRARY(OPENEXR_ILMIMF_LIBRARY SET(LIBRARY_SUFFIXES
NAMES IlmImf "-${OPENEXR_VERSION}"
PATH_SUFFIXES ${OPENEXR_LIBSEARCH_SUFFIXES} "-${OPENEXR_VERSION}_s"
PATHS ${LIBRARY_PATHS}) "-${OPENEXR_VERSION}_d"
"-${OPEXEXR_VERSION}_s_d"
""
"_s"
"_d"
"_s_d")
FIND_LIBRARY(OPENEXR_ILMTHREAD_LIBRARY FOREACH(LIBRARY_SUFFIX ${LIBRARY_SUFFIXES})
NAMES IlmThread FIND_OPENEXR_LIBRARY("Half" ${LIBRARY_SUFFIX})
PATH_SUFFIXES ${OPENEXR_LIBSEARCH_SUFFIXES} FIND_OPENEXR_LIBRARY("Iex" ${LIBRARY_SUFFIX})
PATHS ${LIBRARY_PATHS}) FIND_OPENEXR_LIBRARY("Imath" ${LIBRARY_SUFFIX})
FIND_OPENEXR_LIBRARY("IlmImf" ${LIBRARY_SUFFIX})
FIND_OPENEXR_LIBRARY("IlmThread" ${LIBRARY_SUFFIX})
IF (OPENEXR_INCLUDE_PATH AND OPENEXR_IMATH_LIBRARY AND OPENEXR_ILMIMF_LIBRARY AND OPENEXR_IEX_LIBRARY AND OPENEXR_HALF_LIBRARY)
SET(OPENEXR_FOUND TRUE)
BREAK()
ENDIF()
UNSET(OPENEXR_IMATH_LIBRARY)
UNSET(OPENEXR_ILMIMF_LIBRARY)
UNSET(OPENEXR_IEX_LIBRARY)
UNSET(OPENEXR_ILMTHREAD_LIBRARY)
UNSET(OPENEXR_HALF_LIBRARY)
ENDFOREACH()
IF (OPENEXR_INCLUDE_PATH AND OPENEXR_IMATH_LIBRARY AND OPENEXR_ILMIMF_LIBRARY AND OPENEXR_IEX_LIBRARY AND OPENEXR_HALF_LIBRARY) IF (OPENEXR_FOUND)
SET(OPENEXR_FOUND TRUE) BREAK()
ENDIF()
UNSET(OPENEXR_INCLUDE_PATH)
UNSET(OPENEXR_VERSION_FILE)
UNSET(OPENEXR_VERSION_MAJOR)
UNSET(OPENEXR_VERSION_MINOR)
UNSET(OPENEXR_VERSION)
ENDFOREACH()
IF (OPENEXR_FOUND)
SET(OPENEXR_INCLUDE_PATHS ${OPENEXR_INCLUDE_PATH} CACHE PATH "The include paths needed to use OpenEXR") SET(OPENEXR_INCLUDE_PATHS ${OPENEXR_INCLUDE_PATH} CACHE PATH "The include paths needed to use OpenEXR")
SET(OPENEXR_LIBRARIES ${OPENEXR_IMATH_LIBRARY} ${OPENEXR_ILMIMF_LIBRARY} ${OPENEXR_IEX_LIBRARY} ${OPENEXR_HALF_LIBRARY} ${OPENEXR_ILMTHREAD_LIBRARY} CACHE STRING "The libraries needed to use OpenEXR" FORCE) SET(OPENEXR_LIBRARIES ${OPENEXR_IMATH_LIBRARY} ${OPENEXR_ILMIMF_LIBRARY} ${OPENEXR_IEX_LIBRARY} ${OPENEXR_HALF_LIBRARY} ${OPENEXR_ILMTHREAD_LIBRARY} CACHE STRING "The libraries needed to use OpenEXR" FORCE)
ENDIF () ENDIF ()

Loading…
Cancel
Save