FindBullet.cmake 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. # - Try to find the Bullet physics engine
  2. #
  3. # This module defines the following variables
  4. #
  5. # BULLET_FOUND - Was bullet found
  6. # BULLET_INCLUDE_DIRS - the Bullet include directories
  7. # BULLET_LIBRARIES - Link to this, by default it includes
  8. # all bullet components (Dynamics,
  9. # Collision, LinearMath, & SoftBody)
  10. #
  11. # This module accepts the following variables
  12. #
  13. # BULLET_ROOT - Can be set to bullet install path or Windows build path
  14. #
  15. #=============================================================================
  16. # Copyright 2009 Kitware, Inc.
  17. # Copyright 2009 Philip Lowman <[email protected]>
  18. #
  19. # Distributed under the OSI-approved BSD License (the "License");
  20. # see accompanying file Copyright.txt for details.
  21. #
  22. # This software is distributed WITHOUT ANY WARRANTY; without even the
  23. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  24. # See the License for more information.
  25. #=============================================================================
  26. # (To distributed this file outside of CMake, substitute the full
  27. # License text for the above reference.)
  28. macro(_FIND_BULLET_LIBRARY _var)
  29. find_library(${_var}
  30. NAMES
  31. ${ARGN}
  32. PATHS
  33. ${BULLET_ROOT}
  34. ${BULLET_ROOT}/out/release8/libs
  35. ${BULLET_ROOT}/out/debug8/libs
  36. PATH_SUFFIXES lib
  37. )
  38. mark_as_advanced(${_var})
  39. endmacro()
  40. macro(_BULLET_APPEND_LIBRARIES _list _release)
  41. set(_debug ${_release}_DEBUG)
  42. if(${_debug})
  43. set(${_list} ${${_list}} optimized ${${_release}} debug ${${_debug}})
  44. else()
  45. set(${_list} ${${_list}} ${${_release}})
  46. endif()
  47. endmacro()
  48. find_path(BULLET_INCLUDE_DIR NAMES btBulletCollisionCommon.h
  49. PATHS
  50. ${BULLET_ROOT}/include
  51. ${BULLET_ROOT}/src
  52. )
  53. # Find the libraries
  54. _FIND_BULLET_LIBRARY(BULLET_DYNAMICS_LIBRARY BulletDynamics)
  55. _FIND_BULLET_LIBRARY(BULLET_DYNAMICS_LIBRARY_DEBUG BulletDynamics_d)
  56. _FIND_BULLET_LIBRARY(BULLET_COLLISION_LIBRARY BulletCollision)
  57. _FIND_BULLET_LIBRARY(BULLET_COLLISION_LIBRARY_DEBUG BulletCollision_d)
  58. _FIND_BULLET_LIBRARY(BULLET_MATH_LIBRARY LinearMath BulletMath)
  59. _FIND_BULLET_LIBRARY(BULLET_MATH_LIBRARY_DEBUG LinearMath_d BulletMath_d)
  60. _FIND_BULLET_LIBRARY(BULLET_SOFTBODY_LIBRARY BulletSoftBody)
  61. _FIND_BULLET_LIBRARY(BULLET_SOFTBODY_LIBRARY_DEBUG BulletSoftBody_d)
  62. # handle the QUIETLY and REQUIRED arguments and set BULLET_FOUND to TRUE if
  63. # all listed variables are TRUE
  64. include(FindPackageHandleStandardArgs)
  65. FIND_PACKAGE_HANDLE_STANDARD_ARGS(Bullet DEFAULT_MSG
  66. BULLET_DYNAMICS_LIBRARY BULLET_COLLISION_LIBRARY BULLET_MATH_LIBRARY
  67. BULLET_SOFTBODY_LIBRARY BULLET_INCLUDE_DIR)
  68. set(BULLET_INCLUDE_DIRS ${BULLET_INCLUDE_DIR})
  69. if(BULLET_FOUND)
  70. _BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_DYNAMICS_LIBRARY)
  71. _BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_COLLISION_LIBRARY)
  72. _BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_MATH_LIBRARY)
  73. _BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_SOFTBODY_LIBRARY)
  74. endif()