Reverting my windows build fix because it breaks the bug fix committed in r40995
[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/csw # Blastwave
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     HINTS
85       ${_opencollada_SEARCH_DIRS}
86     )
87   MARK_AS_ADVANCED(OPENCOLLADA_${UPPERCOMPONENT}_INCLUDE_DIR)
88   LIST(APPEND _opencollada_INCLUDES "${OPENCOLLADA_${UPPERCOMPONENT}_INCLUDE_DIR}")
89 ENDFOREACH()
90
91
92 SET(_opencollada_LIBRARIES)
93 FOREACH(COMPONENT ${_opencollada_FIND_COMPONENTS})
94   STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
95
96   FIND_LIBRARY(OPENCOLLADA_${UPPERCOMPONENT}_LIBRARY
97     NAMES
98       ${COMPONENT}
99     HINTS
100       ${_opencollada_SEARCH_DIRS}
101     PATH_SUFFIXES
102       lib64 lib
103       # Ubuntu ppa needs this.
104       lib64/opencollada lib/opencollada
105     )
106   MARK_AS_ADVANCED(OPENCOLLADA_${UPPERCOMPONENT}_LIBRARY)
107   LIST(APPEND _opencollada_LIBRARIES "${OPENCOLLADA_${UPPERCOMPONENT}_LIBRARY}")
108 ENDFOREACH()
109
110 FOREACH(COMPONENT ${_opencollada_FIND_STATIC_COMPONENTS})
111   STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
112
113   FIND_LIBRARY(OPENCOLLADA_${UPPERCOMPONENT}_LIBRARY
114     NAMES
115       ${COMPONENT}
116     HINTS
117       ${_opencollada_SEARCH_DIRS}
118     PATH_SUFFIXES
119       lib64 lib
120       # Ubuntu ppa needs this.
121       lib64/opencollada lib/opencollada
122     )
123   MARK_AS_ADVANCED(OPENCOLLADA_${UPPERCOMPONENT}_LIBRARY)
124   IF(OPENCOLLADA_${UPPERCOMPONENT}_LIBRARY)
125     LIST(APPEND _opencollada_LIBRARIES "${OPENCOLLADA_${UPPERCOMPONENT}_LIBRARY}")
126   ENDIF()
127 ENDFOREACH()
128
129
130 # handle the QUIETLY and REQUIRED arguments and set OPENCOLLADA_FOUND to TRUE if 
131 # all listed variables are TRUE
132 INCLUDE(FindPackageHandleStandardArgs)
133 FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenCOLLADA  DEFAULT_MSG
134     _opencollada_LIBRARIES _opencollada_INCLUDES)
135
136
137 IF(OPENCOLLADA_FOUND)
138   SET(OPENCOLLADA_LIBRARIES ${_opencollada_LIBRARIES})
139   SET(OPENCOLLADA_INCLUDE_DIRS ${_opencollada_INCLUDES})
140 ENDIF(OPENCOLLADA_FOUND)