79bc01276740cdfa4cbc3bc2705edaeffb0bba0d
[blender.git] / build_files / cmake / Modules / FindOpenColorIO.cmake
1 # - Find OpenColorIO library
2 # Find the native OpenColorIO includes and library
3 # This module defines
4 #  OPENCOLORIO_INCLUDE_DIRS, where to find OpenColorIO.h, Set when
5 #                            OPENCOLORIO_INCLUDE_DIR is found.
6 #  OPENCOLORIO_LIBRARIES, libraries to link against to use OpenColorIO.
7 #  OPENCOLORIO_ROOT_DIR, The base directory to search for OpenColorIO.
8 #                        This can also be an environment variable.
9 #  OPENCOLORIO_FOUND, If false, do not try to use OpenColorIO.
10 #
11 # also defined, but not for general use are
12 #  OPENCOLORIO_LIBRARY, where to find the OpenColorIO library.
13
14 #=============================================================================
15 # Copyright 2012 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 OPENCOLORIO_ROOT_DIR was defined in the environment, use it.
26 IF(NOT OPENCOLORIO_ROOT_DIR AND NOT $ENV{OPENCOLORIO_ROOT_DIR} STREQUAL "")
27   SET(OPENCOLORIO_ROOT_DIR $ENV{OPENCOLORIO_ROOT_DIR})
28 ENDIF()
29
30 SET(_opencolorio_FIND_COMPONENTS
31   OpenColorIO
32   yaml-cpp
33   tinyxml
34 )
35
36 SET(_opencolorio_SEARCH_DIRS
37   ${OPENCOLORIO_ROOT_DIR}
38   /usr/local
39   /sw # Fink
40   /opt/local # DarwinPorts
41   /opt/csw # Blastwave
42 )
43
44 FIND_PATH(OPENCOLORIO_INCLUDE_DIR
45   NAMES
46     OpenColorIO/OpenColorIO.h
47   HINTS
48     ${_opencolorio_SEARCH_DIRS}
49   PATH_SUFFIXES
50     include
51 )
52
53 SET(_opencolorio_LIBRARIES)
54 FOREACH(COMPONENT ${_opencolorio_FIND_COMPONENTS})
55   STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
56
57   FIND_LIBRARY(OPENCOLORIO_${UPPERCOMPONENT}_LIBRARY
58     NAMES
59       ${COMPONENT}
60     HINTS
61       ${_opencolorio_SEARCH_DIRS}
62     PATH_SUFFIXES
63       lib64 lib
64     )
65   if(OPENCOLORIO_${UPPERCOMPONENT}_LIBRARY)
66     LIST(APPEND _opencolorio_LIBRARIES "${OPENCOLORIO_${UPPERCOMPONENT}_LIBRARY}")
67   endif()
68 ENDFOREACH()
69
70 # handle the QUIETLY and REQUIRED arguments and set OPENCOLORIO_FOUND to TRUE if 
71 # all listed variables are TRUE
72 INCLUDE(FindPackageHandleStandardArgs)
73 FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenColorIO DEFAULT_MSG
74     _opencolorio_LIBRARIES OPENCOLORIO_INCLUDE_DIR)
75
76 IF(OPENCOLORIO_FOUND)
77   SET(OPENCOLORIO_LIBRARIES ${_opencolorio_LIBRARIES})
78   SET(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO_INCLUDE_DIR})
79 ENDIF(OPENCOLORIO_FOUND)
80
81 MARK_AS_ADVANCED(
82   OPENCOLORIO_INCLUDE_DIR
83   OPENCOLORIO_LIBRARY
84 )
85