2010-07-09 19:00:26 +08:00
# The script is taken from http://code.google.com/p/nvidia-texture-tools/
2010-07-04 20:32:31 +08:00
#
# Try to find OpenEXR's libraries, and include path.
# Once done this will define:
#
2012-01-03 21:48:12 +08:00
# OPENEXR_FOUND = OpenEXR found.
2010-07-04 20:32:31 +08:00
# OPENEXR_INCLUDE_PATHS = OpenEXR include directories.
# OPENEXR_LIBRARIES = libraries that are needed to use OpenEXR.
2012-01-03 21:48:12 +08:00
#
2010-07-04 20:32:31 +08:00
2012-02-27 14:23:14 +08:00
SET ( OPENEXR_LIBRARIES "" )
SET ( OPENEXR_LIBSEARCH_SUFFIXES "" )
file ( TO_CMAKE_PATH "$ENV{ProgramFiles}" ProgramFiles_ENV_PATH )
if ( WIN32 )
SET ( OPENEXR_ROOT "C:/Deploy" CACHE STRING "Path to the OpenEXR \" Deploy\ " folder" )
2019-12-11 06:35:36 +08:00
if ( X86_64 )
2012-02-27 14:23:14 +08:00
SET ( OPENEXR_LIBSEARCH_SUFFIXES x64/Release x64 x64/Debug )
elseif ( MSVC )
SET ( OPENEXR_LIBSEARCH_SUFFIXES Win32/Release Win32 Win32/Debug )
endif ( )
2020-01-06 21:52:40 +08:00
elseif ( UNIX )
SET ( OPENEXR_LIBSEARCH_SUFFIXES ${ CMAKE_LIBRARY_ARCHITECTURE } )
2012-02-27 14:23:14 +08:00
endif ( )
2010-07-09 19:00:26 +08:00
2019-11-05 17:13:21 +08:00
SET ( SEARCH_PATHS
" $ { O P E N E X R _ R O O T } "
/ u s r
/ u s r / l o c a l
/ s w
/ o p t
" $ { P r o g r a m F i l e s _ E N V _ P A T H } / O p e n E X R " )
2010-07-04 20:32:31 +08:00
2019-11-05 17:13:21 +08:00
MACRO ( FIND_OPENEXR_LIBRARY LIBRARY_NAME LIBRARY_SUFFIX )
string ( TOUPPER "${LIBRARY_NAME}" LIBRARY_NAME_UPPER )
FIND_LIBRARY ( OPENEXR_ ${ LIBRARY_NAME_UPPER } _LIBRARY
N A M E S $ { L I B R A R Y _ N A M E } $ { L I B R A R Y _ S U F F I X }
P A T H _ S U F F I X E S $ { O P E N E X R _ L I B S E A R C H _ S U F F I X E S }
N O _ D E F A U L T _ P A T H
P A T H S " $ { S E A R C H _ P A T H } / l i b " " $ { S E A R C H _ P A T H } / l i b / s t a t i c " )
ENDMACRO ( )
2010-07-04 20:32:31 +08:00
2020-01-06 21:52:40 +08:00
MACRO ( ocv_find_openexr LIBRARY_SUFFIX )
IF ( NOT OPENEXR_FOUND )
FIND_OPENEXR_LIBRARY ( "Half" "${LIBRARY_SUFFIX}" )
FIND_OPENEXR_LIBRARY ( "Iex" "${LIBRARY_SUFFIX}" )
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 AND OPENEXR_ILMTHREAD_LIBRARY )
SET ( OPENEXR_FOUND TRUE )
ELSE ( )
UNSET ( OPENEXR_IMATH_LIBRARY )
UNSET ( OPENEXR_ILMIMF_LIBRARY )
UNSET ( OPENEXR_IEX_LIBRARY )
UNSET ( OPENEXR_ILMTHREAD_LIBRARY )
UNSET ( OPENEXR_HALF_LIBRARY )
ENDIF ( )
ENDIF ( )
ENDMACRO ( )
2019-11-05 17:13:21 +08:00
FOREACH ( SEARCH_PATH ${ SEARCH_PATHS } )
FIND_PATH ( OPENEXR_INCLUDE_PATH ImfRgbaFile.h
P A T H _ S U F F I X E S O p e n E X R
N O _ D E F A U L T _ P A T H
P A T H S
" $ { S E A R C H _ P A T H } / i n c l u d e " )
2012-10-17 15:12:04 +08:00
2019-11-05 17:13:21 +08:00
IF ( OPENEXR_INCLUDE_PATH )
SET ( OPENEXR_VERSION_FILE "${OPENEXR_INCLUDE_PATH}/OpenEXRConfig.h" )
IF ( EXISTS ${ OPENEXR_VERSION_FILE } )
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 ( )
2010-07-04 20:32:31 +08:00
2019-11-05 17:13:21 +08:00
IF ( OPENEXR_VERSION_MAJOR AND OPENEXR_VERSION_MINOR )
set ( OPENEXR_VERSION "${OPENEXR_VERSION_MAJOR}_${OPENEXR_VERSION_MINOR}" )
ENDIF ( )
2010-07-04 20:32:31 +08:00
2020-01-06 21:52:40 +08:00
ocv_find_openexr ( "-${OPENEXR_VERSION}" )
ocv_find_openexr ( "-${OPENEXR_VERSION}_s" )
ocv_find_openexr ( "-${OPENEXR_VERSION}_d" )
2020-06-13 02:59:43 +08:00
ocv_find_openexr ( "-${OPENEXR_VERSION}_s_d" )
2020-01-06 21:52:40 +08:00
ocv_find_openexr ( "" )
ocv_find_openexr ( "_s" )
ocv_find_openexr ( "_d" )
ocv_find_openexr ( "_s_d" )
2010-07-04 20:32:31 +08:00
2019-11-05 17:13:21 +08:00
IF ( OPENEXR_FOUND )
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 )
2012-02-27 14:23:14 +08:00
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 )
2010-07-09 19:00:26 +08:00
ENDIF ( )
2010-07-04 20:32:31 +08:00
IF ( OPENEXR_FOUND )
2012-04-14 05:50:59 +08:00
IF ( NOT OPENEXR_FIND_QUIETLY )
MESSAGE ( STATUS "Found OpenEXR: ${OPENEXR_ILMIMF_LIBRARY}" )
ENDIF ( )
if ( PKG_CONFIG_FOUND AND NOT OPENEXR_VERSION )
get_filename_component ( OPENEXR_LIB_PATH "${OPENEXR_ILMIMF_LIBRARY}" PATH )
if ( EXISTS "${OPENEXR_LIB_PATH}/pkgconfig/OpenEXR.pc" )
execute_process ( COMMAND ${ PKG_CONFIG_EXECUTABLE } --modversion "${OPENEXR_LIB_PATH}/pkgconfig/OpenEXR.pc"
R E S U L T _ V A R I A B L E P K G _ C O N F I G _ P R O C E S S
O U T P U T _ V A R I A B L E O P E N E X R _ V E R S I O N
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E E R R O R _ Q U I E T )
if ( NOT PKG_CONFIG_PROCESS EQUAL 0 )
SET ( OPENEXR_VERSION "Unknown" )
endif ( )
endif ( )
endif ( )
if ( NOT OPENEXR_VERSION )
SET ( OPENEXR_VERSION "Unknown" )
endif ( )
2010-07-09 19:00:26 +08:00
ELSE ( )
2012-04-14 05:50:59 +08:00
IF ( OPENEXR_FIND_REQUIRED )
MESSAGE ( FATAL_ERROR "Could not find OpenEXR library" )
ENDIF ( )
2010-07-09 19:00:26 +08:00
ENDIF ( )
2010-07-04 20:32:31 +08:00
MARK_AS_ADVANCED (
2012-10-17 15:12:04 +08:00
O P E N E X R _ I N C L U D E _ P A T H S
O P E N E X R _ L I B R A R I E S
O P E N E X R _ I L M I M F _ L I B R A R Y
O P E N E X R _ I M A T H _ L I B R A R Y
O P E N E X R _ I E X _ L I B R A R Y
O P E N E X R _ H A L F _ L I B R A R Y
2012-04-14 05:50:59 +08:00
O P E N E X R _ I L M T H R E A D _ L I B R A R Y )