~openmw/openmw/openmw-packaging2

« back to all changes in this revision

Viewing changes to cmake/FindBullet.cmake

  • Committer: Scott Howard
  • Date: 2016-09-15 20:56:29 UTC
  • Revision ID: showard@debian.org-20160915205629-3tvfxe47zrb41a91
Cron update. Git hash: 37278b5

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# - Try to find the Bullet physics engine
2
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
 
#
 
3
# This module accepts the following env variables
13
4
#  BULLET_ROOT - Can be set to bullet install path or Windows build path
14
5
#
15
 
 
 
6
# Once done this will define
 
7
#  Bullet_FOUND         - System has the all required components.
 
8
#  Bullet_INCLUDE_DIRS  - Include directory necessary for using the required components headers.
 
9
#  Bullet_LIBRARIES     - Link these to use the required bullet components.
 
10
#  Bullet_VERSION       - Version of libbullet
 
11
#
 
12
# For each of the components
 
13
#   - LinearMath
 
14
#   - BulletCollision
 
15
#   - BulletSoftBody
 
16
#   - BulletDynamics
 
17
#
16
18
# Copyright (c) 2009, Philip Lowman <philip at yhbt.com>
17
19
# Modified for OpenMW to parse BT_BULLET_VERSION.
18
20
#
20
22
# BSD license.
21
23
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
22
24
 
23
 
include(PreprocessorUtils)
24
 
 
25
 
set(BULLET_ROOT $ENV{BULLET_ROOT})
26
 
 
27
 
macro(_FIND_BULLET_LIBRARY _var)
28
 
  find_library(${_var}
29
 
     NAMES
30
 
        ${ARGN}
31
 
     PATHS
32
 
        ${BULLET_ROOT}
33
 
                ${BULLET_ROOT}/lib/Debug
34
 
                ${BULLET_ROOT}/lib/Release
35
 
        ${BULLET_ROOT}/out/release8/libs
36
 
        ${BULLET_ROOT}/out/debug8/libs
37
 
     PATH_SUFFIXES lib
38
 
  )
39
 
  mark_as_advanced(${_var})
40
 
endmacro()
41
 
 
42
 
macro(_BULLET_APPEND_LIBRARIES _list _release)
43
 
   set(_debug ${_release}_DEBUG)
44
 
   if(${_debug})
45
 
      set(${_list} ${${_list}} optimized ${${_release}} debug ${${_debug}})
46
 
   else()
47
 
      set(${_list} ${${_list}} ${${_release}})
48
 
   endif()
49
 
endmacro()
50
 
 
51
 
find_path(BULLET_INCLUDE_DIR NAMES btBulletCollisionCommon.h
52
 
  PATHS
53
 
    ${BULLET_ROOT}/include
54
 
    ${BULLET_ROOT}/src
55
 
  PATH_SUFFIXES bullet
56
 
)
57
 
 
58
 
# Find the libraries
59
 
 
60
 
#_FIND_BULLET_LIBRARY(BULLET_DYNAMICS_LIBRARY        BulletDynamics)
61
 
#_FIND_BULLET_LIBRARY(BULLET_DYNAMICS_LIBRARY_DEBUG  BulletDynamics_Debug BulletDynamics_d)
62
 
_FIND_BULLET_LIBRARY(BULLET_COLLISION_LIBRARY       BulletCollision)
63
 
_FIND_BULLET_LIBRARY(BULLET_COLLISION_LIBRARY_DEBUG BulletCollision_Debug BulletCollision_d)
64
 
_FIND_BULLET_LIBRARY(BULLET_MATH_LIBRARY            BulletMath LinearMath)
65
 
_FIND_BULLET_LIBRARY(BULLET_MATH_LIBRARY_DEBUG      BulletMath_Debug BulletMath_d LinearMath_debug LinearMath_d)
66
 
 
67
 
 
68
 
# handle the QUIETLY and REQUIRED arguments and set BULLET_FOUND to TRUE if
69
 
# all listed variables are TRUE
70
 
include(FindPackageHandleStandardArgs)
71
 
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Bullet DEFAULT_MSG
72
 
    #BULLET_DYNAMICS_LIBRARY
73
 
    BULLET_COLLISION_LIBRARY BULLET_MATH_LIBRARY
74
 
    BULLET_INCLUDE_DIR)
75
 
 
76
 
set(BULLET_INCLUDE_DIRS ${BULLET_INCLUDE_DIR})
77
 
if(BULLET_FOUND)
78
 
   #_BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_DYNAMICS_LIBRARY)
79
 
   _BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_COLLISION_LIBRARY)
80
 
   _BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_MATH_LIBRARY)
81
 
 
82
 
    find_file(BULLET_BTSCALAR_FILE NAMES btScalar.h PATHS "${BULLET_INCLUDE_DIR}/LinearMath")
83
 
    file(READ ${BULLET_BTSCALAR_FILE} BULLET_BTSCALAR_CONTENT)
84
 
    get_preprocessor_entry(BULLET_BTSCALAR_CONTENT BT_BULLET_VERSION BULLET_VERSION)
85
 
    message(STATUS "Bullet version: ${BULLET_VERSION}")
86
 
endif()
 
25
include(LibFindMacros)
 
26
 
 
27
# Macro: _internal_find_bullet_library
 
28
# Checks for the given component by invoking pkgconfig etc.
 
29
macro(_internal_find_bullet_library _lib)
 
30
    libfind_pkg_detect(Bullet_${_lib} bullet
 
31
        FIND_LIBRARY ${_lib}
 
32
            HINTS $ENV{BULLET_ROOT}
 
33
            PATH_SUFFIXES lib
 
34
    )
 
35
    libfind_process(Bullet_${_lib})
 
36
endmacro()
 
37
 
 
38
set(_known_components LinearMath BulletCollision BulletSoftBody BulletDynamics)
 
39
 
 
40
# Check if the required components were found and add their stuff to the Bullet_* vars.
 
41
foreach (_component ${Bullet_FIND_COMPONENTS})
 
42
    list(FIND _known_components ${_component} _known_component)
 
43
    if (_known_component EQUAL -1)
 
44
        message(FATAL_ERROR "Unknown component '${_component}'")
 
45
    endif()
 
46
 
 
47
    set(Bullet_${_component}_Debug_FIND_QUIETLY TRUE) # don't spam messages with optional Debug component
 
48
    _internal_find_bullet_library(${_component})
 
49
    _internal_find_bullet_library(${_component}_Debug)
 
50
 
 
51
    if (Bullet_${_component}_Debug_FOUND)
 
52
        set(Bullet_LIBRARIES ${Bullet_LIBRARIES} optimized ${Bullet_${_component}_LIBRARIES} debug ${Bullet_${_component}_Debug_LIBRARIES})
 
53
    else()
 
54
        set(Bullet_LIBRARIES ${Bullet_LIBRARIES} ${Bullet_${_component}_LIBRARIES})
 
55
    endif()
 
56
endforeach()
 
57
 
 
58
libfind_pkg_detect(Bullet bullet
 
59
    FIND_PATH btBulletCollisionCommon.h
 
60
        HINTS $ENV{BULLET_ROOT}
 
61
        PATH_SUFFIXES include/bullet
 
62
)
 
63
set(Bullet_INCLUDE_DIRS ${Bullet_INCLUDE_DIR})
 
64
libfind_version_header(Bullet LinearMath/btScalar.h BT_BULLET_VERSION)
 
65
 
 
66
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Bullet
 
67
    FOUND_VAR Bullet_FOUND
 
68
    VERSION_VAR Bullet_VERSION
 
69
    HANDLE_COMPONENTS
 
70
    REQUIRED_VARS
 
71
        Bullet_LIBRARIES
 
72
        Bullet_INCLUDE_DIR
 
73
)