Rewrites FindBullet using LibFindMacros handling version properly

pull/1/head
Roman Proskuryakov 8 years ago
parent 280b20ccb7
commit 3bcd23022a

@ -376,12 +376,7 @@ printf "Bullet 2.83.5... "
mv Bullet-2.83.5-win$BITS Bullet
fi
BULLET_SDK="`real_pwd`/Bullet"
add_cmake_opts -DBULLET_INCLUDE_DIR="$BULLET_SDK/include/bullet" \
-DBULLET_COLLISION_LIBRARY="$BULLET_SDK/lib/BulletCollision.lib" \
-DBULLET_COLLISION_LIBRARY_DEBUG="$BULLET_SDK/lib/BulletCollision_Debug.lib" \
-DBULLET_MATH_LIBRARY="$BULLET_SDK/lib/LinearMath.lib" \
-DBULLET_MATH_LIBRARY_DEBUG="$BULLET_SDK/lib/LinearMath_Debug.lib"
export BULLET_ROOT="`real_pwd`/Bullet"
echo Done.
}

@ -281,10 +281,7 @@ endif()
find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS})
find_package(SDL2 REQUIRED)
find_package(OpenAL REQUIRED)
find_package(Bullet REQUIRED)
if (NOT BULLET_FOUND OR BULLET_VERSION VERSION_LESS 283)
message(FATAL_ERROR "OpenMW requires Bullet version 2.83 or later")
endif()
find_package(Bullet 283 REQUIRED COMPONENTS BulletCollision LinearMath)
include_directories("."
SYSTEM
@ -292,7 +289,7 @@ include_directories("."
${Boost_INCLUDE_DIR}
${MYGUI_INCLUDE_DIRS}
${OPENAL_INCLUDE_DIR}
${BULLET_INCLUDE_DIRS}
${Bullet_INCLUDE_DIRS}
)
link_directories(${SDL2_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS} ${MYGUI_LIB_DIR})

@ -132,7 +132,6 @@ target_link_libraries(openmw
${Boost_PROGRAM_OPTIONS_LIBRARY}
${OPENAL_LIBRARY}
${FFmpeg_LIBRARIES}
${BULLET_LIBRARIES}
${MYGUI_LIBRARIES}
${SDL2_LIBRARY}
"osg-ffmpeg-videoplayer"

@ -1,18 +1,20 @@
# - Try to find the Bullet physics engine
#
# This module defines the following variables
#
# BULLET_FOUND - Was bullet found
# BULLET_INCLUDE_DIRS - the Bullet include directories
# BULLET_LIBRARIES - Link to this, by default it includes
# all bullet components (Dynamics,
# Collision, LinearMath, & SoftBody)
# This module accepts the following env variables
# BULLET_ROOT - Can be set to bullet install path or Windows build path
#
# This module accepts the following variables
# Once done this will define
# Bullet_FOUND - System has the all required components.
# Bullet_INCLUDE_DIRS - Include directory necessary for using the required components headers.
# Bullet_LIBRARIES - Link these to use the required bullet components.
# Bullet_VERSION - Version of libbullet
#
# BULLET_ROOT - Can be set to bullet install path or Windows build path
# For each of the components
# - LinearMath
# - BulletCollision
# - BulletSoftBody
# - BulletDynamics
#
# Copyright (c) 2009, Philip Lowman <philip at yhbt.com>
# Modified for OpenMW to parse BT_BULLET_VERSION.
#
@ -20,67 +22,52 @@
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
include(PreprocessorUtils)
set(BULLET_ROOT $ENV{BULLET_ROOT})
include(LibFindMacros)
macro(_FIND_BULLET_LIBRARY _var)
find_library(${_var}
NAMES
${ARGN}
PATHS
${BULLET_ROOT}
${BULLET_ROOT}/lib/Debug
${BULLET_ROOT}/lib/Release
${BULLET_ROOT}/out/release8/libs
${BULLET_ROOT}/out/debug8/libs
PATH_SUFFIXES lib
)
mark_as_advanced(${_var})
# Macro: _internal_find_bullet_library
# Checks for the given component by invoking pkgconfig etc.
macro(_internal_find_bullet_library _lib)
libfind_pkg_detect(Bullet_${_lib} bullet
FIND_LIBRARY ${_lib}
HINTS $ENV{BULLET_ROOT}
PATH_SUFFIXES lib
)
libfind_process(Bullet_${_lib})
endmacro()
macro(_BULLET_APPEND_LIBRARIES _list _release)
set(_debug ${_release}_DEBUG)
if(${_debug})
set(${_list} ${${_list}} optimized ${${_release}} debug ${${_debug}})
else()
set(${_list} ${${_list}} ${${_release}})
endif()
endmacro()
set(_known_components LinearMath BulletCollision BulletSoftBody BulletDynamics)
find_path(BULLET_INCLUDE_DIR NAMES btBulletCollisionCommon.h
PATHS
${BULLET_ROOT}/include
${BULLET_ROOT}/src
PATH_SUFFIXES bullet
)
# Find the libraries
#_FIND_BULLET_LIBRARY(BULLET_DYNAMICS_LIBRARY BulletDynamics)
#_FIND_BULLET_LIBRARY(BULLET_DYNAMICS_LIBRARY_DEBUG BulletDynamics_Debug BulletDynamics_d)
_FIND_BULLET_LIBRARY(BULLET_COLLISION_LIBRARY BulletCollision)
_FIND_BULLET_LIBRARY(BULLET_COLLISION_LIBRARY_DEBUG BulletCollision_Debug BulletCollision_d)
_FIND_BULLET_LIBRARY(BULLET_MATH_LIBRARY BulletMath LinearMath)
_FIND_BULLET_LIBRARY(BULLET_MATH_LIBRARY_DEBUG BulletMath_Debug BulletMath_d LinearMath_debug LinearMath_d)
# Check if the required components were found and add their stuff to the Bullet_* vars.
foreach (_component ${Bullet_FIND_COMPONENTS})
list(FIND _known_components ${_component} _known_component)
if (_known_component EQUAL -1)
message(FATAL_ERROR "Unknown component '${_component}'")
endif()
set(Bullet_${_component}_Debug_FIND_QUIETLY TRUE) # don't spam messages with optional Debug component
_internal_find_bullet_library(${_component})
_internal_find_bullet_library(${_component}_Debug)
# handle the QUIETLY and REQUIRED arguments and set BULLET_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Bullet DEFAULT_MSG
#BULLET_DYNAMICS_LIBRARY
BULLET_COLLISION_LIBRARY BULLET_MATH_LIBRARY
BULLET_INCLUDE_DIR)
if (Bullet_${_component}_Debug_FOUND)
set(Bullet_LIBRARIES ${Bullet_LIBRARIES} optimized ${Bullet_${_component}_LIBRARIES} debug ${Bullet_${_component}_Debug_LIBRARIES})
else()
set(Bullet_LIBRARIES ${Bullet_LIBRARIES} ${Bullet_${_component}_LIBRARIES})
endif()
endforeach()
set(BULLET_INCLUDE_DIRS ${BULLET_INCLUDE_DIR})
if(BULLET_FOUND)
#_BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_DYNAMICS_LIBRARY)
_BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_COLLISION_LIBRARY)
_BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_MATH_LIBRARY)
libfind_pkg_detect(Bullet bullet
FIND_PATH btBulletCollisionCommon.h
HINTS $ENV{BULLET_ROOT}
PATH_SUFFIXES include/bullet
)
set(Bullet_INCLUDE_DIRS ${Bullet_INCLUDE_DIR})
libfind_version_header(Bullet LinearMath/btScalar.h BT_BULLET_VERSION)
find_file(BULLET_BTSCALAR_FILE NAMES btScalar.h PATHS "${BULLET_INCLUDE_DIR}/LinearMath")
file(READ ${BULLET_BTSCALAR_FILE} BULLET_BTSCALAR_CONTENT)
get_preprocessor_entry(BULLET_BTSCALAR_CONTENT BT_BULLET_VERSION BULLET_VERSION)
message(STATUS "Bullet version: ${BULLET_VERSION}")
endif()
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Bullet
FOUND_VAR Bullet_FOUND
VERSION_VAR Bullet_VERSION
HANDLE_COMPONENTS
REQUIRED_VARS
Bullet_LIBRARIES
Bullet_INCLUDE_DIR
)

@ -181,7 +181,7 @@ if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
endif()
endif ()
include_directories(${BULLET_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR})
include_directories(${Bullet_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR})
add_library(components STATIC ${COMPONENT_FILES} ${MOC_SRCS} ${ESM_UI_HDR})
@ -205,7 +205,7 @@ target_link_libraries(components
${OSGGA_LIBRARIES}
${OSGFX_LIBRARIES}
${OSGANIMATION_LIBRARIES}
${BULLET_LIBRARIES}
${Bullet_LIBRARIES}
${SDL2_LIBRARY}
# For MyGUI platform
${GL_LIB}

Loading…
Cancel
Save