Merge branch 'master' into blender2.8
[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/lib/ocio
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 lib64/static lib/static
64     )
65   IF(OPENCOLORIO_${UPPERCOMPONENT}_LIBRARY)
66     LIST(APPEND _opencolorio_LIBRARIES "${OPENCOLORIO_${UPPERCOMPONENT}_LIBRARY}")
67   ENDIF()
68 ENDFOREACH()
69
70
71 # handle the QUIETLY and REQUIRED arguments and set OPENCOLORIO_FOUND to TRUE if
72 # all listed variables are TRUE
73 INCLUDE(FindPackageHandleStandardArgs)
74 FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenColorIO DEFAULT_MSG
75     _opencolorio_LIBRARIES OPENCOLORIO_INCLUDE_DIR)
76
77 IF(OPENCOLORIO_FOUND)
78   SET(OPENCOLORIO_LIBRARIES ${_opencolorio_LIBRARIES})
79   SET(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO_INCLUDE_DIR})
80 ENDIF(OPENCOLORIO_FOUND)
81
82 MARK_AS_ADVANCED(
83   OPENCOLORIO_INCLUDE_DIR
84   OPENCOLORIO_LIBRARY
85   OPENCOLORIO_OPENCOLORIO_LIBRARY
86   OPENCOLORIO_TINYXML_LIBRARY
87   OPENCOLORIO_YAML-CPP_LIBRARY
88 )
89
90 UNSET(COMPONENT)
91 UNSET(UPPERCOMPONENT)
92 UNSET(_opencolorio_FIND_COMPONENTS)
93 UNSET(_opencolorio_LIBRARIES)
94 UNSET(_opencolorio_SEARCH_DIRS)