fixed: compile issue
[opensg.git] / CMake / FindCollada.cmake
blobf46049ff3e3bf2cb1052d333604f5314db5e11e3
1 # - Find collada dom libraries
2 # Find the collada dom libraries and headers
4 # This module specifies the following variables:
5 #  COLLADA_INCLUDE_DIRS
6 #  COLLADA_LIBRARIES
7 #  COLLADA_LIBRARY_DIRS
9 # Additionally the following more specialized variables are defined:
10 #  COLLADA_DAE_INCLUDE_DIR      DAE header files
11 #  COLLADA_DOM_INCLUDE_DIR      DOM header files
12 #  COLLADA_LIBRARY_DEBUG        debug library
13 #  COLLADA_LIBRARY_RELEASE      release library
15 #  You can control where this module attempts to locate libraries and headers:
16 #  COLLADA_ROOT_DIR
17 #  COLLADA_INCLUDE_DIR
18 #  COLLADA_LIBRARY_DIR
21 # default include search paths
22 SET(__COLLADA_INCLUDE_SEARCH_DIRS
23     ~/Library/Frameworks
24     /Library/Frameworks
25     /usr/local/include
26     /usr/local/include/colladadom
27     /usr/local/include/collada-dom
28     /usr/include
29     /usr/include/colladadom
30     /usr/include/collada-dom
31     /sw/include
32     /opt/local/include
33     /opt/local/include/colladadom
34     /opt/local/include/collada-dom
35     /opt/include
36     /opt/include/colladadom
37     /opt/include/collada-dom)
39 # default library search paths
40 SET(__COLLADA_LIBRARY_SEARCH_DIRS
41     ~/Library/Frameworks
42     /Library/Frameworks
43     /usr/local/lib
44     /usr/local/lib64
45     /usr/lib
46     /usr/lib64
47     /sw/lib
48     /opt/local/lib
49     /opt/local/lib64
50     /opt/lib
51     /opt/lib64)
53 SET(COLLADA_ROOT_DIR_ENV "$ENV{COLLADA_ROOT_DIR}")
55 IF(NOT COLLADA_ROOT_DIR AND COLLADA_ROOT_DIR_ENV)
56     SET(COLLADA_ROOT_DIR "${COLLADA_ROOT_DIR_ENV}")
57 ENDIF(NOT COLLADA_ROOT_DIR AND COLLADA_ROOT_DIR_ENV)
59 # handle COLLADA_ROOT_DIR input variable
60 IF(COLLADA_ROOT_DIR)
61     FILE(TO_CMAKE_PATH ${COLLADA_ROOT_DIR} COLLADA_ROOT_DIR)
63     SET(__COLLADA_INCLUDE_SEARCH_DIRS "${COLLADA_ROOT_DIR}/include"
64                                       "${COLLADA_ROOT_DIR}/include/colladadom"
65                                       "${COLLADA_ROOT_DIR}/include/collada-dom"
66                                       "${__COLLADA_INCLUDE_SEARCH_DIRS}")
67     SET(__COLLADA_LIBRARY_SEARCH_DIRS "${COLLADA_ROOT_DIR}/lib"
68                                       "${COLLADA_ROOT_DIR}/lib64"
69                                       "${__COLLADA_LIBRARY_SEARCH_DIRS}")
70 ENDIF(COLLADA_ROOT_DIR)
72 IF(OSG_SUPPORT_ROOT AND OSG_USE_OSGSUPPORT_LIBS)
73     FILE(TO_CMAKE_PATH ${OSG_SUPPORT_ROOT} _OSG_SUPPORT_ROOT)
75     SET(__COLLADA_INCLUDE_SEARCH_DIRS "${_OSG_SUPPORT_ROOT}/include"
76                                       "${_OSG_SUPPORT_ROOT}/include/colladadom"
77                                       "${_OSG_SUPPORT_ROOT}/include/collada-dom"
78                                       "${__COLLADA_INCLUDE_SEARCH_DIRS}")
79     SET(__COLLADA_LIBRARY_SEARCH_DIRS "${_OSG_SUPPORT_ROOT}/lib"
80                                       "${_OSG_SUPPORT_ROOT}/lib64"
81                                       "${__COLLADA_LIBRARY_SEARCH_DIRS}")
82 ENDIF(OSG_SUPPORT_ROOT AND OSG_USE_OSGSUPPORT_LIBS)
85 # handle COLLADA_INCLUDE_DIR input variable
86 IF(COLLADA_INCLUDE_DIR)
87     FILE(TO_CMAKE_PATH ${COLLADA_INCLUDE_DIR} COLLADA_INCLUDE_DIR)
88     SET(__COLLADA_INCLUDE_SEARCH_DIRS "${COLLADA_INCLUDE_DIR}"
89                                       "${__COLLADA_INCLUDE_SEARCH_DIRS}")
90 ENDIF(COLLADA_INCLUDE_DIR)
92 # handle COLLADA_LIBRARY_DIR input variable
93 IF(COLLADA_LIBRARY_DIR)
94     FILE(TO_CMAKE_PATH ${COLLADA_LIBRARY_DIR} COLLADA_LIBRARY_DIR)
95     SET(__COLLADA_LIBRARY_SEARCH_DIRS "${COLLADA_LIBRARY_DIR}"
96                                       "${__COLLADA_LIBRARY_SEARCH_DIRS}")
97 ENDIF(COLLADA_LIBRARY_DIR)
100 # locate headers
101 FIND_PATH(COLLADA_DAE_INCLUDE_DIR dae.h
102     PATHS ${__COLLADA_INCLUDE_SEARCH_DIRS})
104 FIND_PATH(COLLADA_DOM_INCLUDE_DIR "dom/domNode.h"
105     PATHS ${__COLLADA_INCLUDE_SEARCH_DIRS}
106     PATH_SUFFIXES "1.4")
108 IF(OSG_USE_OSGSUPPORT_LIBS)
109 # locate libraries 
110 FIND_LIBRARY(COLLADA_LIBRARY_RELEASE
111     NAMES osgcollada14dom22 osgcollada14dom22lib collada_dom collada14dom libcollada14dom21
112     PATHS ${__COLLADA_LIBRARY_SEARCH_DIRS})
114 FIND_LIBRARY(COLLADA_LIBRARY_DEBUG
115     NAMES osgcollada14dom22 osgcollada14dom22lib collada_dom-d collada14dom-d libcollada14dom21-d
116     PATH_SUFFIXES debug
117     PATHS ${__COLLADA_LIBRARY_SEARCH_DIRS})
118 ELSE()
119 # locate libraries
120 FIND_LIBRARY(COLLADA_LIBRARY_RELEASE
121     NAMES collada_dom collada14dom libcollada14dom21
122     PATHS ${__COLLADA_LIBRARY_SEARCH_DIRS})
124 FIND_LIBRARY(COLLADA_LIBRARY_DEBUG
125     NAMES collada_dom-d collada14dom-d libcollada14dom21-d
126     PATHS ${__COLLADA_LIBRARY_SEARCH_DIRS})
127 ENDIF()
129 # handle the QUIETLY and REQUIRED arguments and set COLLADA_FOUND to TRUE if 
130 # all listed variables are TRUE
131 INCLUDE(FindPackageHandleStandardArgs)
132 FIND_PACKAGE_HANDLE_STANDARD_ARGS(COLLADA DEFAULT_MSG COLLADA_LIBRARY_RELEASE
133                                                       COLLADA_DAE_INCLUDE_DIR
134                                                       COLLADA_DOM_INCLUDE_DIR)
136 # if only the debug or release lib was found, use it for both configurations,
137 # except on windows where the runtimes have to match
138 IF(NOT WIN32)
139     IF(COLLADA_LIBRARY_RELEASE AND NOT COLLADA_LIBRARY_DEBUG)
140         SET(COLLADA_LIBRARY_DEBUG "${COLLADA_LIBRARY_RELEASE}")
141     ELSEIF(COLLADA_LIBRARY_DEBUG AND NOT COLLADA_LIBRARY_RELEASE)
142         SET(COLLADA_LIBRARY_RELEASE "${COLLADA_LIBRARY_DEBUG}")
143     ENDIF(COLLADA_LIBRARY_RELEASE AND NOT COLLADA_LIBRARY_DEBUG)
144 ENDIF(NOT WIN32)
146 # set output variables
147 IF(COLLADA_FOUND)
148     GET_FILENAME_COMPONENT(__COLLADA_LIB_DIR_RELEASE "${COLLADA_LIBRARY_RELEASE}" PATH)
149     GET_FILENAME_COMPONENT(__COLLADA_LIB_DIR_DEBUG   "${COLLADA_LIBRARY_DEBUG}"   PATH)
151     SET(COLLADA_LIBRARY_DIRS "${__COLLADA_LIB_DIR_RELEASE}"
152                              "${__COLLADA_LIB_DIR_DEBUG}"  )
153     SET(COLLADA_INCLUDE_DIRS "${COLLADA_DAE_INCLUDE_DIR}"
154                              "${COLLADA_DOM_INCLUDE_DIR}"  )
155     
156     SET(COLLADA_LIBRARIES "${COLLADA_LIBRARY_RELEASE}")
157 ENDIF(COLLADA_FOUND)