fix to FindOpenEXR pointed out by Sergey Sharybin,
[blender.git] / build_files / cmake / Modules / FindOpenEXR.cmake
1 # - Find OpenEXR library (copied from FindTIFF.cmake, v 2.8.5)
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 indervidual 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 2002-2009 Kitware, Inc.
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 # (To distribute this file outside of CMake, substitute the full
32 #  License text for the above reference.)
33
34 # If OPENEXR_ROOT_DIR was defined in the environment, use it.
35 IF(NOT OPENEXR_ROOT_DIR AND NOT $ENV{OPENEXR_ROOT_DIR} STREQUAL "")
36   SET(OPENEXR_ROOT_DIR $ENV{OPENEXR_ROOT_DIR})
37 ENDIF()
38
39 SET(_openexr_FIND_COMPONENTS
40   Half
41   Iex
42   IlmImf
43   IlmThread
44   Imath
45 )
46
47 SET(_openexr_SEARCH_DIRS
48   ${OPENEXR_ROOT_DIR}
49   /usr/local
50   /opt/csw
51 )
52
53 FIND_PATH(OPENEXR_INCLUDE_DIR ImfXdr.h
54   HINTS
55     ${_openexr_SEARCH_DIRS}
56   PATH_SUFFIXES
57     include/OpenEXR
58 )
59
60 SET(_openexr_LIBRARIES)
61 FOREACH(COMPONENT ${_openexr_FIND_COMPONENTS})
62   STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
63
64   FIND_LIBRARY(OPENEXR_${UPPERCOMPONENT}_LIBRARY NAMES ${COMPONENT}
65       HINTS ${_openexr_SEARCH_DIRS}
66       PATH_SUFFIXES lib
67       )
68   LIST(APPEND _openexr_LIBRARIES "${OPENEXR_${UPPERCOMPONENT}_LIBRARY}")
69 ENDFOREACH()
70
71 # handle the QUIETLY and REQUIRED arguments and set OPENEXR_FOUND to TRUE if 
72 # all listed variables are TRUE
73 INCLUDE(FindPackageHandleStandardArgs)
74 FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenEXR  DEFAULT_MSG
75     _openexr_LIBRARIES OPENEXR_INCLUDE_DIR)
76
77 IF(OPENEXR_FOUND)
78   SET(OPENEXR_LIBRARIES ${_openexr_LIBRARIES})
79   SET(OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_DIR})
80 ENDIF(OPENEXR_FOUND)
81
82 MARK_AS_ADVANCED(OPENEXR_INCLUDE_DIR)
83 FOREACH(COMPONENT ${_openexr_FIND_COMPONENTS})
84   STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
85   MARK_AS_ADVANCED(OPENEXR_${UPPERCOMPONENT}_LIBRARY)
86 ENDFOREACH()