1# The script is taken from http://code.google.com/p/nvidia-texture-tools/ 2 3# 4# Try to find OpenEXR's libraries, and include path. 5# Once done this will define: 6# 7# OPENEXR_FOUND = OpenEXR found. 8# OPENEXR_INCLUDE_PATHS = OpenEXR include directories. 9# OPENEXR_LIBRARIES = libraries that are needed to use OpenEXR. 10# 11 12SET(OPENEXR_LIBRARIES "") 13SET(OPENEXR_LIBSEARCH_SUFFIXES "") 14file(TO_CMAKE_PATH "$ENV{ProgramFiles}" ProgramFiles_ENV_PATH) 15 16if(WIN32) 17 SET(OPENEXR_ROOT "C:/Deploy" CACHE STRING "Path to the OpenEXR \"Deploy\" folder") 18 if(CMAKE_CL_64) 19 SET(OPENEXR_LIBSEARCH_SUFFIXES x64/Release x64 x64/Debug) 20 elseif(MSVC) 21 SET(OPENEXR_LIBSEARCH_SUFFIXES Win32/Release Win32 Win32/Debug) 22 endif() 23else() 24 set(OPENEXR_ROOT "") 25endif() 26 27SET(LIBRARY_PATHS 28 /usr/lib 29 /usr/local/lib 30 /sw/lib 31 /opt/local/lib 32 "${ProgramFiles_ENV_PATH}/OpenEXR/lib/static" 33 "${OPENEXR_ROOT}/lib") 34 35FIND_PATH(OPENEXR_INCLUDE_PATH ImfRgbaFile.h 36 PATH_SUFFIXES OpenEXR 37 PATHS 38 /usr/include 39 /usr/local/include 40 /sw/include 41 /opt/local/include 42 "${ProgramFiles_ENV_PATH}/OpenEXR/include" 43 "${OPENEXR_ROOT}/include") 44 45FIND_LIBRARY(OPENEXR_HALF_LIBRARY 46 NAMES Half 47 PATH_SUFFIXES ${OPENEXR_LIBSEARCH_SUFFIXES} 48 PATHS ${LIBRARY_PATHS}) 49 50FIND_LIBRARY(OPENEXR_IEX_LIBRARY 51 NAMES Iex 52 PATH_SUFFIXES ${OPENEXR_LIBSEARCH_SUFFIXES} 53 PATHS ${LIBRARY_PATHS}) 54 55FIND_LIBRARY(OPENEXR_IMATH_LIBRARY 56 NAMES Imath 57 PATH_SUFFIXES ${OPENEXR_LIBSEARCH_SUFFIXES} 58 PATHS ${LIBRARY_PATHS}) 59 60FIND_LIBRARY(OPENEXR_ILMIMF_LIBRARY 61 NAMES IlmImf 62 PATH_SUFFIXES ${OPENEXR_LIBSEARCH_SUFFIXES} 63 PATHS ${LIBRARY_PATHS}) 64 65FIND_LIBRARY(OPENEXR_ILMTHREAD_LIBRARY 66 NAMES IlmThread 67 PATH_SUFFIXES ${OPENEXR_LIBSEARCH_SUFFIXES} 68 PATHS ${LIBRARY_PATHS}) 69 70IF (OPENEXR_INCLUDE_PATH AND OPENEXR_IMATH_LIBRARY AND OPENEXR_ILMIMF_LIBRARY AND OPENEXR_IEX_LIBRARY AND OPENEXR_HALF_LIBRARY) 71 SET(OPENEXR_FOUND TRUE) 72 SET(OPENEXR_INCLUDE_PATHS ${OPENEXR_INCLUDE_PATH} CACHE PATH "The include paths needed to use OpenEXR") 73 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) 74ENDIF () 75 76IF(OPENEXR_FOUND) 77 IF(NOT OPENEXR_FIND_QUIETLY) 78 MESSAGE(STATUS "Found OpenEXR: ${OPENEXR_ILMIMF_LIBRARY}") 79 ENDIF() 80 if(PKG_CONFIG_FOUND AND NOT OPENEXR_VERSION) 81 get_filename_component(OPENEXR_LIB_PATH "${OPENEXR_ILMIMF_LIBRARY}" PATH) 82 if(EXISTS "${OPENEXR_LIB_PATH}/pkgconfig/OpenEXR.pc") 83 execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --modversion "${OPENEXR_LIB_PATH}/pkgconfig/OpenEXR.pc" 84 RESULT_VARIABLE PKG_CONFIG_PROCESS 85 OUTPUT_VARIABLE OPENEXR_VERSION 86 OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET) 87 if(NOT PKG_CONFIG_PROCESS EQUAL 0) 88 SET(OPENEXR_VERSION "Unknown") 89 endif() 90 endif() 91 endif() 92 if(NOT OPENEXR_VERSION) 93 SET(OPENEXR_VERSION "Unknown") 94 endif() 95ELSE() 96 IF(OPENEXR_FIND_REQUIRED) 97 MESSAGE(FATAL_ERROR "Could not find OpenEXR library") 98 ENDIF() 99ENDIF() 100 101MARK_AS_ADVANCED( 102 OPENEXR_INCLUDE_PATHS 103 OPENEXR_LIBRARIES 104 OPENEXR_ILMIMF_LIBRARY 105 OPENEXR_IMATH_LIBRARY 106 OPENEXR_IEX_LIBRARY 107 OPENEXR_HALF_LIBRARY 108 OPENEXR_ILMTHREAD_LIBRARY) 109