1# - Find OpenEXR library 2# Find the native OpenEXR includes and library 3# This module defines 4# OPENEXR_INCLUDE_DIRS, where to find ImfXdr.h, etc. Set when 5# OPENEXR_INCLUDE_DIR is found. 6# OPENEXR_LIBRARIES, libraries to link against to use OpenEXR. 7# OPENEXR_ROOT_DIR, The base directory to search for OpenEXR. 8# This can also be an environment variable. 9# OPENEXR_FOUND, If false, do not try to use OpenEXR. 10# 11# For individual library access these advanced settings are available 12# OPENEXR_HALF_LIBRARY, Path to Half library 13# OPENEXR_IEX_LIBRARY, Path to Half library 14# OPENEXR_ILMIMF_LIBRARY, Path to Ilmimf library 15# OPENEXR_ILMTHREAD_LIBRARY, Path to IlmThread library 16# OPENEXR_IMATH_LIBRARY, Path to Imath library 17# 18# also defined, but not for general use are 19# OPENEXR_LIBRARY, where to find the OpenEXR library. 20 21#============================================================================= 22# Copyright 2011 Blender Foundation. 23# 24# Distributed under the OSI-approved BSD License (the "License"); 25# see accompanying file Copyright.txt for details. 26# 27# This software is distributed WITHOUT ANY WARRANTY; without even the 28# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 29# See the License for more information. 30#============================================================================= 31 32# If OPENEXR_ROOT_DIR was defined in the environment, use it. 33IF(NOT OPENEXR_ROOT_DIR AND NOT $ENV{OPENEXR_ROOT_DIR} STREQUAL "") 34 SET(OPENEXR_ROOT_DIR $ENV{OPENEXR_ROOT_DIR}) 35ENDIF() 36 37SET(_openexr_FIND_COMPONENTS 38 Iex 39 OpenEXR 40 IlmThread 41 Imath 42) 43 44 45SET(_openexr_SEARCH_DIRS 46 ${OPENEXR_ROOT_DIR} 47 /usr/local 48 /sw # Fink 49 /opt/local # DarwinPorts 50 /opt/csw # Blastwave 51 "C:/Program Files (x86)/OpenEXR" # Windows 52) 53 54FIND_PATH(OPENEXR_INCLUDE_DIR 55 NAMES 56 ImfXdr.h 57 HINTS 58 ${_openexr_SEARCH_DIRS} 59 PATH_SUFFIXES 60 include/OpenEXR include 61) 62 63#message( "Include dir: ${OPENEXR_INCLUDE_DIR}" ) 64 65SET(_openexr_LIBRARIES) 66FOREACH(COMPONENT ${_openexr_FIND_COMPONENTS}) 67 STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT) 68 69 FIND_LIBRARY(OPENEXR_${UPPERCOMPONENT}_LIBRARY 70 NAMES 71 ${COMPONENT}-2_2 ${COMPONENT}-2.2 ${COMPONENT}-2.1 ${COMPONENT}-2_1 ${COMPONENT} # The newest version first 72 HINTS 73 ${_openexr_SEARCH_DIRS} 74 PATH_SUFFIXES 75 lib64 lib 76 ) 77 78# message( "Lib: ${OPENEXR_${UPPERCOMPONENT}_LIBRARY}" ) 79 80# IF( NOT "${OPENEXR_${UPPERCOMPONENT}_LIBRARY}" ) 81# message( "Library ${COMPONENT} not found" ) 82# SET( OPENEXR_FOUND "" ) 83# break() 84# ENDIF() 85 86 LIST(APPEND _openexr_LIBRARIES OPENEXR_${UPPERCOMPONENT}_LIBRARY) 87 88ENDFOREACH() 89 90# OpenEXR needs zlib, which could be tricky to locate on Windows 91# You may need to manually do something like this: 92#SET(ZLIB_DIR "e:/zlib/") 93#SET(CMAKE_INCLUDE_PATH ${ZLIB_DIR}/include ${CMAKE_INCLUDE_PATH}) 94#SET(CMAKE_LIBRARY_PATH ${ZLIB_DIR}/ ${ZLIB_DIR}/lib ${CMAKE_LIBRARY_PATH}) 95 96FIND_PACKAGE(ZLIB REQUIRED) 97LIST(APPEND _openexr_LIBRARIES ZLIB_LIBRARY) 98 99# handle the QUIETLY and REQUIRED arguments and set OPENEXR_FOUND to TRUE if 100# all listed variables are TRUE 101INCLUDE(FindPackageHandleStandardArgs) 102 103#FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenEXR DEFAULT_MSG 104# ${_openexr_LIBRARIES} OPENEXR_INCLUDE_DIR) 105 106# message( "${_openexr_LIBRARIES}" ) 107 108# This is a work-around as passing the list does not work in cmake 2.8.11.2 (cygwin) 109FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenEXR DEFAULT_MSG 110 OPENEXR_OPENEXR_LIBRARY OPENEXR_IMATH_LIBRARY ZLIB_LIBRARY OPENEXR_INCLUDE_DIR) 111 112IF(OPENEXR_FOUND) 113 SET(OPENEXR_LIBRARIES ${OPENEXR_ILMTHREAD_LIBRARY} ${OPENEXR_IEX_LIBRARY} ${OPENEXR_OPENEXR_LIBRARY} ${OPENEXR_IMATH_LIBRARY} ${OPENEXR_HALF_LIBRARY} ${ZLIB_LIBRARY}) 114 # Both include paths are needed because of dummy OSL headers mixing #include <OpenEXR/foo.h> and #include <foo.h> :( 115 SET(OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_DIR} ${OPENEXR_INCLUDE_DIR}/OpenEXR ${ZLIB_INCLUDE_DIR}) 116ENDIF() 117 118MARK_AS_ADVANCED(OPENEXR_INCLUDE_DIR) 119FOREACH(COMPONENT ${_openexr_FIND_COMPONENTS}) 120 STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT) 121 MARK_AS_ADVANCED(OPENEXR_${UPPERCOMPONENT}_LIBRARY) 122ENDFOREACH() 123