Merge branch 'master' into blender2.8
[blender.git] / build_files / cmake / Modules / FindOpenCOLLADA.cmake
1 # - Find OpenCOLLADA library
2 # Find the native OpenCOLLADA includes and library
3 # This module defines
4 #  OPENCOLLADA_INCLUDE_DIRS, where to find COLLADABaseUtils/ and
5 #                 COLLADAFramework/, Set when OPENCOLLADA_INCLUDE_DIR is found.
6 #  OPENCOLLADA_LIBRARIES, libraries to link against to use OpenCOLLADA.
7 #  OPENCOLLADA_ROOT_DIR, The base directory to search for OpenCOLLADA.
8 #                    This can also be an environment variable.
9 #  OPENCOLLADA_FOUND, If false, do not try to use OpenCOLLADA.
10 #
11 # also defined, but not for general use are
12 #  OPENCOLLADA_LIBRARY, where to find the OpenCOLLADA 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 # note about include paths, there are 2 ways includes are set
26 #
27 # Where '/usr/include/opencollada' is the root dir:
28 #   /usr/include/opencollada/COLLADABaseUtils/COLLADABUPlatform.h
29 #
30 # Where '/opt/opencollada' is the base dir:
31 # /opt/opencollada/COLLADABaseUtils/include/COLLADABUPlatform.h
32
33 # If OPENCOLLADA_ROOT_DIR was defined in the environment, use it.
34 IF(NOT OPENCOLLADA_ROOT_DIR AND NOT $ENV{OPENCOLLADA_ROOT_DIR} STREQUAL "")
35   SET(OPENCOLLADA_ROOT_DIR $ENV{OPENCOLLADA_ROOT_DIR})
36 ENDIF()
37
38 SET(_opencollada_FIND_INCLUDES
39   COLLADAStreamWriter
40   COLLADABaseUtils
41   COLLADAFramework
42   COLLADASaxFrameworkLoader
43   GeneratedSaxParser
44 )
45
46 SET(_opencollada_FIND_COMPONENTS
47   OpenCOLLADAStreamWriter
48   OpenCOLLADASaxFrameworkLoader
49   OpenCOLLADAFramework
50   OpenCOLLADABaseUtils
51   GeneratedSaxParser
52   MathMLSolver
53 )
54
55 # Fedora openCOLLADA package links these statically
56 # note that order is important here ot it wont link
57 SET(_opencollada_FIND_STATIC_COMPONENTS
58   buffer
59   ftoa
60   UTF
61 )
62
63 SET(_opencollada_SEARCH_DIRS
64   ${OPENCOLLADA_ROOT_DIR}
65   /usr/local
66   /sw # Fink
67   /opt/local # DarwinPorts
68   /opt/lib/opencollada
69 )
70
71 SET(_opencollada_INCLUDES)
72 FOREACH(COMPONENT ${_opencollada_FIND_INCLUDES})
73   STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
74
75   # need to use this even thouh we are looking for a dir
76   FIND_FILE(OPENCOLLADA_${UPPERCOMPONENT}_INCLUDE_DIR
77     NAMES
78       ${COMPONENT}/include
79       ${COMPONENT}
80       # Ubuntu ppa needs this.
81       # Alternative would be to suffix all members of search path
82       # but this is less trouble, just looks strange.
83       include/opencollada/${COMPONENT}
84       include/${COMPONENT}/include
85       include/${COMPONENT}
86     HINTS
87       ${_opencollada_SEARCH_DIRS}
88     )
89   MARK_AS_ADVANCED(OPENCOLLADA_${UPPERCOMPONENT}_INCLUDE_DIR)
90   LIST(APPEND _opencollada_INCLUDES "${OPENCOLLADA_${UPPERCOMPONENT}_INCLUDE_DIR}")
91 ENDFOREACH()
92
93
94 SET(_opencollada_LIBRARIES)
95 FOREACH(COMPONENT ${_opencollada_FIND_COMPONENTS})
96   STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
97
98   FIND_LIBRARY(OPENCOLLADA_${UPPERCOMPONENT}_LIBRARY
99     NAMES
100       ${COMPONENT}
101     HINTS
102       ${_opencollada_SEARCH_DIRS}
103     PATH_SUFFIXES
104       lib64 lib
105       # Ubuntu ppa needs this.
106       lib64/opencollada lib/opencollada
107     )
108   MARK_AS_ADVANCED(OPENCOLLADA_${UPPERCOMPONENT}_LIBRARY)
109   LIST(APPEND _opencollada_LIBRARIES "${OPENCOLLADA_${UPPERCOMPONENT}_LIBRARY}")
110 ENDFOREACH()
111
112 FOREACH(COMPONENT ${_opencollada_FIND_STATIC_COMPONENTS})
113   STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
114
115   FIND_LIBRARY(OPENCOLLADA_${UPPERCOMPONENT}_LIBRARY
116     NAMES
117       ${COMPONENT}
118     HINTS
119       ${_opencollada_SEARCH_DIRS}
120     PATH_SUFFIXES
121       lib64 lib
122       # Ubuntu ppa needs this.
123       lib64/opencollada lib/opencollada
124     )
125   MARK_AS_ADVANCED(OPENCOLLADA_${UPPERCOMPONENT}_LIBRARY)
126   IF(OPENCOLLADA_${UPPERCOMPONENT}_LIBRARY)
127     LIST(APPEND _opencollada_LIBRARIES "${OPENCOLLADA_${UPPERCOMPONENT}_LIBRARY}")
128   ENDIF()
129 ENDFOREACH()
130
131
132 # handle the QUIETLY and REQUIRED arguments and set OPENCOLLADA_FOUND to TRUE if
133 # all listed variables are TRUE
134 INCLUDE(FindPackageHandleStandardArgs)
135 FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenCOLLADA  DEFAULT_MSG
136     _opencollada_LIBRARIES _opencollada_INCLUDES)
137
138
139 IF(OPENCOLLADA_FOUND)
140   SET(OPENCOLLADA_LIBRARIES ${_opencollada_LIBRARIES})
141   SET(OPENCOLLADA_INCLUDE_DIRS ${_opencollada_INCLUDES})
142 ENDIF(OPENCOLLADA_FOUND)
143
144 UNSET(COMPONENT)
145 UNSET(UPPERCOMPONENT)
146 UNSET(_opencollada_LIBRARIES)
147 UNSET(_opencollada_INCLUDES)