Imported Upstream version 2.8.10.2
[platform/upstream/cmake.git] / Modules / FindBullet.cmake
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 #=============================================================================
17 # Copyright 2009 Kitware, Inc.
18 # Copyright 2009 Philip Lowman <philip@yhbt.com>
19 #
20 # Distributed under the OSI-approved BSD License (the "License");
21 # see accompanying file Copyright.txt for details.
22 #
23 # This software is distributed WITHOUT ANY WARRANTY; without even the
24 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
25 # See the License for more information.
26 #=============================================================================
27 # (To distribute this file outside of CMake, substitute the full
28 #  License text for the above reference.)
29
30 macro(_FIND_BULLET_LIBRARY _var)
31   find_library(${_var}
32      NAMES
33         ${ARGN}
34      HINTS
35         ${BULLET_ROOT}
36         ${BULLET_ROOT}/out/release8/libs
37         ${BULLET_ROOT}/out/debug8/libs
38      PATH_SUFFIXES lib
39   )
40   mark_as_advanced(${_var})
41 endmacro()
42
43 macro(_BULLET_APPEND_LIBRARIES _list _release)
44    set(_debug ${_release}_DEBUG)
45    if(${_debug})
46       set(${_list} ${${_list}} optimized ${${_release}} debug ${${_debug}})
47    else()
48       set(${_list} ${${_list}} ${${_release}})
49    endif()
50 endmacro()
51
52 find_path(BULLET_INCLUDE_DIR NAMES btBulletCollisionCommon.h
53   HINTS
54     ${BULLET_ROOT}/include
55     ${BULLET_ROOT}/src
56   PATH_SUFFIXES bullet
57 )
58
59 # Find the libraries
60
61 _FIND_BULLET_LIBRARY(BULLET_DYNAMICS_LIBRARY        BulletDynamics)
62 _FIND_BULLET_LIBRARY(BULLET_DYNAMICS_LIBRARY_DEBUG  BulletDynamics_Debug BulletDynamics_d)
63 _FIND_BULLET_LIBRARY(BULLET_COLLISION_LIBRARY       BulletCollision)
64 _FIND_BULLET_LIBRARY(BULLET_COLLISION_LIBRARY_DEBUG BulletCollision_Debug BulletCollision_d)
65 _FIND_BULLET_LIBRARY(BULLET_MATH_LIBRARY            BulletMath LinearMath)
66 _FIND_BULLET_LIBRARY(BULLET_MATH_LIBRARY_DEBUG      BulletMath_Debug BulletMath_d LinearMath_Debug LinearMath_d)
67 _FIND_BULLET_LIBRARY(BULLET_SOFTBODY_LIBRARY        BulletSoftBody)
68 _FIND_BULLET_LIBRARY(BULLET_SOFTBODY_LIBRARY_DEBUG  BulletSoftBody_Debug BulletSoftBody_d)
69
70
71 # handle the QUIETLY and REQUIRED arguments and set BULLET_FOUND to TRUE if
72 # all listed variables are TRUE
73 include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
74 FIND_PACKAGE_HANDLE_STANDARD_ARGS(Bullet DEFAULT_MSG
75     BULLET_DYNAMICS_LIBRARY BULLET_COLLISION_LIBRARY BULLET_MATH_LIBRARY
76     BULLET_SOFTBODY_LIBRARY BULLET_INCLUDE_DIR)
77
78 set(BULLET_INCLUDE_DIRS ${BULLET_INCLUDE_DIR})
79 if(BULLET_FOUND)
80    _BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_DYNAMICS_LIBRARY)
81    _BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_COLLISION_LIBRARY)
82    _BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_MATH_LIBRARY)
83    _BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_SOFTBODY_LIBRARY)
84 endif()