Rewrites FindBullet using LibFindMacros handling version properly

pull/943/head
Roman Proskuryakov 9 years ago
parent 280b20ccb7
commit 3bcd23022a

@ -376,12 +376,7 @@ printf "Bullet 2.83.5... "
mv Bullet-2.83.5-win$BITS Bullet mv Bullet-2.83.5-win$BITS Bullet
fi fi
BULLET_SDK="`real_pwd`/Bullet" export BULLET_ROOT="`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"
echo Done. echo Done.
} }

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

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

@ -1,18 +1,20 @@
# - Try to find the Bullet physics engine # - Try to find the Bullet physics engine
# #
# This module defines the following variables # This module accepts the following env variables
# # BULLET_ROOT - Can be set to bullet install path or Windows build path
# 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 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> # Copyright (c) 2009, Philip Lowman <philip at yhbt.com>
# Modified for OpenMW to parse BT_BULLET_VERSION. # Modified for OpenMW to parse BT_BULLET_VERSION.
# #
@ -20,67 +22,52 @@
# BSD license. # BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file. # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
include(PreprocessorUtils) include(LibFindMacros)
set(BULLET_ROOT $ENV{BULLET_ROOT})
macro(_FIND_BULLET_LIBRARY _var) # Macro: _internal_find_bullet_library
find_library(${_var} # Checks for the given component by invoking pkgconfig etc.
NAMES macro(_internal_find_bullet_library _lib)
${ARGN} libfind_pkg_detect(Bullet_${_lib} bullet
PATHS FIND_LIBRARY ${_lib}
${BULLET_ROOT} HINTS $ENV{BULLET_ROOT}
${BULLET_ROOT}/lib/Debug PATH_SUFFIXES lib
${BULLET_ROOT}/lib/Release )
${BULLET_ROOT}/out/release8/libs libfind_process(Bullet_${_lib})
${BULLET_ROOT}/out/debug8/libs
PATH_SUFFIXES lib
)
mark_as_advanced(${_var})
endmacro() endmacro()
macro(_BULLET_APPEND_LIBRARIES _list _release) set(_known_components LinearMath BulletCollision BulletSoftBody BulletDynamics)
set(_debug ${_release}_DEBUG)
if(${_debug})
set(${_list} ${${_list}} optimized ${${_release}} debug ${${_debug}})
else()
set(${_list} ${${_list}} ${${_release}})
endif()
endmacro()
find_path(BULLET_INCLUDE_DIR NAMES btBulletCollisionCommon.h # Check if the required components were found and add their stuff to the Bullet_* vars.
PATHS foreach (_component ${Bullet_FIND_COMPONENTS})
${BULLET_ROOT}/include list(FIND _known_components ${_component} _known_component)
${BULLET_ROOT}/src if (_known_component EQUAL -1)
PATH_SUFFIXES bullet message(FATAL_ERROR "Unknown component '${_component}'")
) endif()
# 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)
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 if (Bullet_${_component}_Debug_FOUND)
# all listed variables are TRUE set(Bullet_LIBRARIES ${Bullet_LIBRARIES} optimized ${Bullet_${_component}_LIBRARIES} debug ${Bullet_${_component}_Debug_LIBRARIES})
include(FindPackageHandleStandardArgs) else()
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Bullet DEFAULT_MSG set(Bullet_LIBRARIES ${Bullet_LIBRARIES} ${Bullet_${_component}_LIBRARIES})
#BULLET_DYNAMICS_LIBRARY endif()
BULLET_COLLISION_LIBRARY BULLET_MATH_LIBRARY endforeach()
BULLET_INCLUDE_DIR)
set(BULLET_INCLUDE_DIRS ${BULLET_INCLUDE_DIR}) libfind_pkg_detect(Bullet bullet
if(BULLET_FOUND) FIND_PATH btBulletCollisionCommon.h
#_BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_DYNAMICS_LIBRARY) HINTS $ENV{BULLET_ROOT}
_BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_COLLISION_LIBRARY) PATH_SUFFIXES include/bullet
_BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_MATH_LIBRARY) )
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") FIND_PACKAGE_HANDLE_STANDARD_ARGS(Bullet
file(READ ${BULLET_BTSCALAR_FILE} BULLET_BTSCALAR_CONTENT) FOUND_VAR Bullet_FOUND
get_preprocessor_entry(BULLET_BTSCALAR_CONTENT BT_BULLET_VERSION BULLET_VERSION) VERSION_VAR Bullet_VERSION
message(STATUS "Bullet version: ${BULLET_VERSION}") HANDLE_COMPONENTS
endif() 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()
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}) add_library(components STATIC ${COMPONENT_FILES} ${MOC_SRCS} ${ESM_UI_HDR})
@ -205,7 +205,7 @@ target_link_libraries(components
${OSGGA_LIBRARIES} ${OSGGA_LIBRARIES}
${OSGFX_LIBRARIES} ${OSGFX_LIBRARIES}
${OSGANIMATION_LIBRARIES} ${OSGANIMATION_LIBRARIES}
${BULLET_LIBRARIES} ${Bullet_LIBRARIES}
${SDL2_LIBRARY} ${SDL2_LIBRARY}
# For MyGUI platform # For MyGUI platform
${GL_LIB} ${GL_LIB}

Loading…
Cancel
Save