FindBullet.cmake 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #[=======================================================================[.rst:
  4. FindBullet
  5. ----------
  6. Try to find the Bullet physics engine
  7. ::
  8. This module defines the following variables
  9. ::
  10. BULLET_FOUND - Was bullet found
  11. BULLET_INCLUDE_DIRS - the Bullet include directories
  12. BULLET_LIBRARIES - Link to this, by default it includes
  13. all bullet components (Dynamics,
  14. Collision, LinearMath, & SoftBody)
  15. ::
  16. This module accepts the following variables
  17. ::
  18. BULLET_ROOT - Can be set to bullet install path or Windows build path
  19. #]=======================================================================]
  20. macro(_FIND_BULLET_LIBRARY _var)
  21. find_library(${_var}
  22. NAMES
  23. ${ARGN}
  24. HINTS
  25. ${BULLET_ROOT}
  26. ${BULLET_ROOT}/lib/Release
  27. ${BULLET_ROOT}/lib/Debug
  28. ${BULLET_ROOT}/out/release8/libs
  29. ${BULLET_ROOT}/out/debug8/libs
  30. PATH_SUFFIXES lib
  31. )
  32. mark_as_advanced(${_var})
  33. endmacro()
  34. macro(_BULLET_APPEND_LIBRARIES _list _release)
  35. set(_debug ${_release}_DEBUG)
  36. if(${_debug})
  37. set(${_list} ${${_list}} optimized ${${_release}} debug ${${_debug}})
  38. else()
  39. set(${_list} ${${_list}} ${${_release}})
  40. endif()
  41. endmacro()
  42. find_path(BULLET_INCLUDE_DIR NAMES btBulletCollisionCommon.h
  43. HINTS
  44. ${BULLET_ROOT}/include
  45. ${BULLET_ROOT}/src
  46. PATH_SUFFIXES bullet
  47. )
  48. # Find the libraries
  49. _FIND_BULLET_LIBRARY(BULLET_DYNAMICS_LIBRARY BulletDynamics)
  50. _FIND_BULLET_LIBRARY(BULLET_DYNAMICS_LIBRARY_DEBUG BulletDynamics_Debug BulletDynamics_d)
  51. _FIND_BULLET_LIBRARY(BULLET_COLLISION_LIBRARY BulletCollision)
  52. _FIND_BULLET_LIBRARY(BULLET_COLLISION_LIBRARY_DEBUG BulletCollision_Debug BulletCollision_d)
  53. _FIND_BULLET_LIBRARY(BULLET_MATH_LIBRARY BulletMath LinearMath)
  54. _FIND_BULLET_LIBRARY(BULLET_MATH_LIBRARY_DEBUG BulletMath_Debug BulletMath_d LinearMath_Debug LinearMath_d)
  55. _FIND_BULLET_LIBRARY(BULLET_SOFTBODY_LIBRARY BulletSoftBody)
  56. _FIND_BULLET_LIBRARY(BULLET_SOFTBODY_LIBRARY_DEBUG BulletSoftBody_Debug BulletSoftBody_d)
  57. include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  58. FIND_PACKAGE_HANDLE_STANDARD_ARGS(Bullet DEFAULT_MSG
  59. BULLET_DYNAMICS_LIBRARY BULLET_COLLISION_LIBRARY BULLET_MATH_LIBRARY
  60. BULLET_SOFTBODY_LIBRARY BULLET_INCLUDE_DIR)
  61. set(BULLET_INCLUDE_DIRS ${BULLET_INCLUDE_DIR})
  62. if(BULLET_FOUND)
  63. _BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_DYNAMICS_LIBRARY)
  64. _BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_COLLISION_LIBRARY)
  65. _BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_MATH_LIBRARY)
  66. _BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_SOFTBODY_LIBRARY)
  67. endif()