Merge topic 'cpack-innosetup-linux'
[kiteware-cmake.git] / Modules / FindBullet.cmake
blob6d6418521eb4870e9a76e6b5331ee5cd19d69e89
1 # Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2 # file Copyright.txt or https://cmake.org/licensing for details.
4 #[=======================================================================[.rst:
5 FindBullet
6 ----------
8 Try to find the Bullet physics engine
14   This module defines the following variables
20   BULLET_FOUND - Was bullet found
21   BULLET_INCLUDE_DIRS - the Bullet include directories
22   BULLET_LIBRARIES - Link to this, by default it includes
23                      all bullet components (Dynamics,
24                      Collision, LinearMath, & SoftBody)
30   This module accepts the following variables
36   BULLET_ROOT - Can be set to bullet install path or Windows build path
37 #]=======================================================================]
39 macro(_FIND_BULLET_LIBRARY _var)
40   find_library(${_var}
41      NAMES
42         ${ARGN}
43      HINTS
44         ${BULLET_ROOT}
45         ${BULLET_ROOT}/lib/Release
46         ${BULLET_ROOT}/lib/Debug
47         ${BULLET_ROOT}/out/release8/libs
48         ${BULLET_ROOT}/out/debug8/libs
49      PATH_SUFFIXES lib
50   )
51   mark_as_advanced(${_var})
52 endmacro()
54 macro(_BULLET_APPEND_LIBRARIES _list _release)
55   set(_debug ${_release}_DEBUG)
56   if(${_debug})
57     set(${_list} ${${_list}} optimized ${${_release}} debug ${${_debug}})
58   else()
59     set(${_list} ${${_list}} ${${_release}})
60   endif()
61 endmacro()
63 find_path(BULLET_INCLUDE_DIR NAMES btBulletCollisionCommon.h
64   HINTS
65     ${BULLET_ROOT}/include
66     ${BULLET_ROOT}/src
67   PATH_SUFFIXES bullet
70 # Find the libraries
72 _FIND_BULLET_LIBRARY(BULLET_DYNAMICS_LIBRARY        BulletDynamics)
73 _FIND_BULLET_LIBRARY(BULLET_DYNAMICS_LIBRARY_DEBUG  BulletDynamics_Debug BulletDynamics_d)
74 _FIND_BULLET_LIBRARY(BULLET_COLLISION_LIBRARY       BulletCollision)
75 _FIND_BULLET_LIBRARY(BULLET_COLLISION_LIBRARY_DEBUG BulletCollision_Debug BulletCollision_d)
76 _FIND_BULLET_LIBRARY(BULLET_MATH_LIBRARY            BulletMath LinearMath)
77 _FIND_BULLET_LIBRARY(BULLET_MATH_LIBRARY_DEBUG      BulletMath_Debug BulletMath_d LinearMath_Debug LinearMath_d)
78 _FIND_BULLET_LIBRARY(BULLET_SOFTBODY_LIBRARY        BulletSoftBody)
79 _FIND_BULLET_LIBRARY(BULLET_SOFTBODY_LIBRARY_DEBUG  BulletSoftBody_Debug BulletSoftBody_d)
82 include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
83 FIND_PACKAGE_HANDLE_STANDARD_ARGS(Bullet DEFAULT_MSG
84     BULLET_DYNAMICS_LIBRARY BULLET_COLLISION_LIBRARY BULLET_MATH_LIBRARY
85     BULLET_SOFTBODY_LIBRARY BULLET_INCLUDE_DIR)
87 set(BULLET_INCLUDE_DIRS ${BULLET_INCLUDE_DIR})
88 if(BULLET_FOUND)
89    _BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_DYNAMICS_LIBRARY)
90    _BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_COLLISION_LIBRARY)
91    _BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_MATH_LIBRARY)
92    _BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_SOFTBODY_LIBRARY)
93 endif()