CMake: Fix detection of idiff program
[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 #  OPENIMAGEIO_PUGIXML_FOUND, Indicates whether OIIO has biltin PuguXML parser.
11 #  OPENIMAGEIO_IDIFF, full path to idiff application if found.
12 #
13 # also defined, but not for general use are
14 #  OPENIMAGEIO_LIBRARY, where to find the OpenImageIO library.
15
16 #=============================================================================
17 # Copyright 2011 Blender Foundation.
18 #
19 # Distributed under the OSI-approved BSD License (the "License");
20 # see accompanying file Copyright.txt for details.
21 #
22 # This software is distributed WITHOUT ANY WARRANTY; without even the
23 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
24 # See the License for more information.
25 #=============================================================================
26
27 # If OPENIMAGEIO_ROOT_DIR was defined in the environment, use it.
28 IF(NOT OPENIMAGEIO_ROOT_DIR AND NOT $ENV{OPENIMAGEIO_ROOT_DIR} STREQUAL "")
29   SET(OPENIMAGEIO_ROOT_DIR $ENV{OPENIMAGEIO_ROOT_DIR})
30 ENDIF()
31
32 SET(_openimageio_SEARCH_DIRS
33   ${OPENIMAGEIO_ROOT_DIR}
34   /usr/local
35   /sw # Fink
36   /opt/local # DarwinPorts
37   /opt/csw # Blastwave
38   /opt/lib/oiio
39 )
40
41 FIND_PATH(OPENIMAGEIO_INCLUDE_DIR
42   NAMES
43     OpenImageIO/imageio.h
44   HINTS
45     ${_openimageio_SEARCH_DIRS}
46   PATH_SUFFIXES
47     include
48 )
49
50 FIND_LIBRARY(OPENIMAGEIO_LIBRARY
51   NAMES
52     OpenImageIO
53   HINTS
54     ${_openimageio_SEARCH_DIRS}
55   PATH_SUFFIXES
56     lib64 lib
57   )
58
59 FIND_FILE(OPENIMAGEIO_IDIFF
60   NAMES
61     idiff
62   HINTS
63     ${_openimageio_SEARCH_DIRS}
64   PATH_SUFFIXES
65     bin
66 )
67
68 # handle the QUIETLY and REQUIRED arguments and set OPENIMAGEIO_FOUND to TRUE if 
69 # all listed variables are TRUE
70 INCLUDE(FindPackageHandleStandardArgs)
71 FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenImageIO DEFAULT_MSG
72     OPENIMAGEIO_LIBRARY OPENIMAGEIO_INCLUDE_DIR)
73
74 IF(OPENIMAGEIO_FOUND)
75   SET(OPENIMAGEIO_LIBRARIES ${OPENIMAGEIO_LIBRARY})
76   SET(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO_INCLUDE_DIR})
77   IF(EXISTS ${OPENIMAGEIO_INCLUDE_DIR}/OpenImageIO/pugixml.hpp)
78     SET(OPENIMAGEIO_PUGIXML_FOUND TRUE)
79   ENDIF()
80 ELSE()
81   SET(OPENIMAGEIO_PUGIXML_FOUND FALSE)
82 ENDIF()
83
84 MARK_AS_ADVANCED(
85   OPENIMAGEIO_INCLUDE_DIR
86   OPENIMAGEIO_LIBRARY
87   OPENIMAGEIO_IDIFF
88 )
89
90 UNSET(_openimageio_SEARCH_DIRS)