FindOpenCOLLADA.cmake 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. # Copyright 2011 Blender Foundation.
  15. #
  16. # Distributed under the OSI-approved BSD License (the "License");
  17. # see accompanying file Copyright.txt for details.
  18. #
  19. # This software is distributed WITHOUT ANY WARRANTY; without even the
  20. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  21. # See the License for more information.
  22. #=============================================================================
  23. # note about include paths, there are 2 ways includes are set
  24. #
  25. # Where '/usr/include/opencollada' is the root dir:
  26. # /usr/include/opencollada/COLLADABaseUtils/COLLADABUPlatform.h
  27. #
  28. # Where '/opt/opencollada' is the base dir:
  29. # /opt/opencollada/COLLADABaseUtils/include/COLLADABUPlatform.h
  30. # If OPENCOLLADA_ROOT_DIR was defined in the environment, use it.
  31. IF(NOT OPENCOLLADA_ROOT_DIR AND NOT $ENV{OPENCOLLADA_ROOT_DIR} STREQUAL "")
  32. SET(OPENCOLLADA_ROOT_DIR $ENV{OPENCOLLADA_ROOT_DIR})
  33. ENDIF()
  34. SET(_opencollada_FIND_INCLUDES
  35. COLLADAStreamWriter
  36. COLLADABaseUtils
  37. COLLADAFramework
  38. COLLADASaxFrameworkLoader
  39. GeneratedSaxParser
  40. )
  41. SET(_opencollada_FIND_COMPONENTS
  42. OpenCOLLADAStreamWriter
  43. OpenCOLLADASaxFrameworkLoader
  44. OpenCOLLADAFramework
  45. OpenCOLLADABaseUtils
  46. GeneratedSaxParser
  47. MathMLSolver
  48. )
  49. # Fedora openCOLLADA package links these statically
  50. # note that order is important here ot it wont link
  51. SET(_opencollada_FIND_STATIC_COMPONENTS
  52. buffer
  53. ftoa
  54. UTF
  55. )
  56. SET(_opencollada_SEARCH_DIRS
  57. ${OPENCOLLADA_ROOT_DIR}
  58. /usr/local
  59. /sw # Fink
  60. /opt/local # DarwinPorts
  61. /opt/csw # Blastwave
  62. /opt/lib/opencollada
  63. )
  64. SET(_opencollada_INCLUDES)
  65. FOREACH(COMPONENT ${_opencollada_FIND_INCLUDES})
  66. STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
  67. # need to use this even thouh we are looking for a dir
  68. FIND_FILE(OPENCOLLADA_${UPPERCOMPONENT}_INCLUDE_DIR
  69. NAMES
  70. ${COMPONENT}/include
  71. ${COMPONENT}
  72. # Ubuntu ppa needs this.
  73. # Alternative would be to suffix all members of search path
  74. # but this is less trouble, just looks strange.
  75. include/opencollada/${COMPONENT}
  76. include/${COMPONENT}/include
  77. include/${COMPONENT}
  78. HINTS
  79. ${_opencollada_SEARCH_DIRS}
  80. )
  81. MARK_AS_ADVANCED(OPENCOLLADA_${UPPERCOMPONENT}_INCLUDE_DIR)
  82. LIST(APPEND _opencollada_INCLUDES "${OPENCOLLADA_${UPPERCOMPONENT}_INCLUDE_DIR}")
  83. ENDFOREACH()
  84. SET(_opencollada_LIBRARIES)
  85. FOREACH(COMPONENT ${_opencollada_FIND_COMPONENTS})
  86. STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
  87. FIND_LIBRARY(OPENCOLLADA_${UPPERCOMPONENT}_LIBRARY
  88. NAMES
  89. ${COMPONENT}
  90. HINTS
  91. ${_opencollada_SEARCH_DIRS}
  92. PATH_SUFFIXES
  93. lib64 lib
  94. # Ubuntu ppa needs this.
  95. lib64/opencollada lib/opencollada
  96. )
  97. MARK_AS_ADVANCED(OPENCOLLADA_${UPPERCOMPONENT}_LIBRARY)
  98. LIST(APPEND _opencollada_LIBRARIES "${OPENCOLLADA_${UPPERCOMPONENT}_LIBRARY}")
  99. ENDFOREACH()
  100. FOREACH(COMPONENT ${_opencollada_FIND_STATIC_COMPONENTS})
  101. STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
  102. FIND_LIBRARY(OPENCOLLADA_${UPPERCOMPONENT}_LIBRARY
  103. NAMES
  104. ${COMPONENT}
  105. HINTS
  106. ${_opencollada_SEARCH_DIRS}
  107. PATH_SUFFIXES
  108. lib64 lib
  109. # Ubuntu ppa needs this.
  110. lib64/opencollada lib/opencollada
  111. )
  112. MARK_AS_ADVANCED(OPENCOLLADA_${UPPERCOMPONENT}_LIBRARY)
  113. IF(OPENCOLLADA_${UPPERCOMPONENT}_LIBRARY)
  114. LIST(APPEND _opencollada_LIBRARIES "${OPENCOLLADA_${UPPERCOMPONENT}_LIBRARY}")
  115. ENDIF()
  116. ENDFOREACH()
  117. # handle the QUIETLY and REQUIRED arguments and set OPENCOLLADA_FOUND to TRUE if
  118. # all listed variables are TRUE
  119. INCLUDE(FindPackageHandleStandardArgs)
  120. FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenCOLLADA DEFAULT_MSG
  121. _opencollada_LIBRARIES _opencollada_INCLUDES)
  122. IF(OPENCOLLADA_FOUND)
  123. SET(OPENCOLLADA_LIBRARIES ${_opencollada_LIBRARIES})
  124. SET(OPENCOLLADA_INCLUDE_DIRS ${_opencollada_INCLUDES})
  125. ENDIF(OPENCOLLADA_FOUND)
  126. UNSET(COMPONENT)
  127. UNSET(UPPERCOMPONENT)
  128. UNSET(_opencollada_LIBRARIES)
  129. UNSET(_opencollada_INCLUDES)