cmake: added FindOpenJPEG module.
[blender.git] / build_files / cmake / Modules / FindOpenEXR.cmake
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 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   /sw # Fink
51   /opt/local # DarwinPorts
52   /opt/csw # Blastwave
53 )
54
55 FIND_PATH(OPENEXR_INCLUDE_DIR ImfXdr.h
56   HINTS
57     ${_openexr_SEARCH_DIRS}
58   PATH_SUFFIXES
59     include/OpenEXR
60 )
61
62 SET(_openexr_LIBRARIES)
63 FOREACH(COMPONENT ${_openexr_FIND_COMPONENTS})
64   STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
65
66   FIND_LIBRARY(OPENEXR_${UPPERCOMPONENT}_LIBRARY
67       NAMES ${COMPONENT}
68       HINTS ${_openexr_SEARCH_DIRS}
69       PATH_SUFFIXES lib64 lib
70       )
71   LIST(APPEND _openexr_LIBRARIES "${OPENEXR_${UPPERCOMPONENT}_LIBRARY}")
72 ENDFOREACH()
73
74 # handle the QUIETLY and REQUIRED arguments and set OPENEXR_FOUND to TRUE if 
75 # all listed variables are TRUE
76 INCLUDE(FindPackageHandleStandardArgs)
77 FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenEXR  DEFAULT_MSG
78     _openexr_LIBRARIES OPENEXR_INCLUDE_DIR)
79
80 IF(OPENEXR_FOUND)
81   SET(OPENEXR_LIBRARIES ${_openexr_LIBRARIES})
82   SET(OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_DIR})
83 ENDIF()
84
85 MARK_AS_ADVANCED(OPENEXR_INCLUDE_DIR)
86 FOREACH(COMPONENT ${_openexr_FIND_COMPONENTS})
87   STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
88   MARK_AS_ADVANCED(OPENEXR_${UPPERCOMPONENT}_LIBRARY)
89 ENDFOREACH()