Initial implementation of a script for automatic dependencies installer/builder
[blender.git] / build_files / cmake / Modules / FindOpenImageIO.cmake
1 # - Find OpenImageIO library
2 # Find the native OpenImageIO includes and library
3 # This module defines
4 #  OPENIMAGEIO_INCLUDE_DIRS, where to find openimageio.h, Set when
5 #                            OPENIMAGEIO_INCLUDE_DIR is found.
6 #  OPENIMAGEIO_LIBRARIES, libraries to link against to use OpenImageIO.
7 #  OPENIMAGEIO_ROOT_DIR, The base directory to search for OpenImageIO.
8 #                        This can also be an environment variable.
9 #  OPENIMAGEIO_FOUND, If false, do not try to use OpenImageIO.
10 #
11 # also defined, but not for general use are
12 #  OPENIMAGEIO_LIBRARY, where to find the OpenImageIO library.
13
14 #=============================================================================
15 # Copyright 2011 Blender Foundation.
16 #
17 # Distributed under the OSI-approved BSD License (the "License");
18 # see accompanying file Copyright.txt for details.
19 #
20 # This software is distributed WITHOUT ANY WARRANTY; without even the
21 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22 # See the License for more information.
23 #=============================================================================
24
25 # If OPENIMAGEIO_ROOT_DIR was defined in the environment, use it.
26 IF(NOT OPENIMAGEIO_ROOT_DIR AND NOT $ENV{OPENIMAGEIO_ROOT_DIR} STREQUAL "")
27   SET(OPENIMAGEIO_ROOT_DIR $ENV{OPENIMAGEIO_ROOT_DIR})
28 ENDIF()
29
30 SET(_openimageio_SEARCH_DIRS
31   ${OPENIMAGEIO_ROOT_DIR}
32   /usr/local
33   /sw # Fink
34   /opt/local # DarwinPorts
35   /opt/csw # Blastwave
36   /opt/lib/oiio
37 )
38
39 FIND_PATH(OPENIMAGEIO_INCLUDE_DIR
40   NAMES
41     OpenImageIO/imageio.h
42   HINTS
43     ${_openimageio_SEARCH_DIRS}
44   PATH_SUFFIXES
45     include
46 )
47
48 FIND_LIBRARY(OPENIMAGEIO_LIBRARY
49   NAMES
50     OpenImageIO
51   HINTS
52     ${_openimageio_SEARCH_DIRS}
53   PATH_SUFFIXES
54     lib64 lib
55   )
56
57 # handle the QUIETLY and REQUIRED arguments and set OPENIMAGEIO_FOUND to TRUE if 
58 # all listed variables are TRUE
59 INCLUDE(FindPackageHandleStandardArgs)
60 FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenImageIO DEFAULT_MSG
61     OPENIMAGEIO_LIBRARY OPENIMAGEIO_INCLUDE_DIR)
62
63 IF(OPENIMAGEIO_FOUND)
64   SET(OPENIMAGEIO_LIBRARIES ${OPENIMAGEIO_LIBRARY})
65   SET(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO_INCLUDE_DIR})
66 ENDIF(OPENIMAGEIO_FOUND)
67
68 MARK_AS_ADVANCED(
69   OPENIMAGEIO_INCLUDE_DIR
70   OPENIMAGEIO_LIBRARY
71 )