Remove support for single-precision Bullet, fail during configuration instead of during linking.

pull/3076/head
fredzio 3 years ago
parent 74ce9ffb85
commit 6fd04cb8f6

@ -73,9 +73,6 @@ CONFIGURATIONS=()
TEST_FRAMEWORK=""
GOOGLE_INSTALL_ROOT=""
INSTALL_PREFIX="."
BULLET_DOUBLE=true
BULLET_DBL=""
BULLET_DBL_DISPLAY="Single precision"
ACTIVATE_MSVC=""
SINGLE_CONFIG=""
@ -99,9 +96,6 @@ while [ $# -gt 0 ]; do
d )
SKIP_DOWNLOAD=true ;;
D )
BULLET_DOUBLE=true ;;
e )
SKIP_EXTRACT=true ;;
@ -149,8 +143,6 @@ Options:
For single-config generators, several configurations can be set up at once by specifying -c multiple times.
-d
Skip checking the downloads.
-D
Use double-precision Bullet
-e
Skip extracting dependencies.
-h
@ -433,9 +425,6 @@ if [ -n "$SINGLE_CONFIG" ]; then
if [ -n "$SKIP_DOWNLOAD" ]; then
RECURSIVE_OPTIONS+=("-d")
fi
if [ -n "$BULLET_DOUBLE" ]; then
RECURSIVE_OPTIONS+=("-D")
fi
if [ -n "$SKIP_EXTRACT" ]; then
RECURSIVE_OPTIONS+=("-e")
fi
@ -508,12 +497,6 @@ if ! [ -z $UNITY_BUILD ]; then
add_cmake_opts "-DOPENMW_UNITY_BUILD=True"
fi
if [ -n "$BULLET_DOUBLE" ]; then
BULLET_DBL="-double"
BULLET_DBL_DISPLAY="Double precision"
add_cmake_opts "-DBULLET_USE_DOUBLES=True"
fi
echo
echo "==================================="
echo "Starting prebuild on MSVC${MSVC_DISPLAY_YEAR} WIN${BITS}"
@ -538,9 +521,9 @@ if [ -z $SKIP_DOWNLOAD ]; then
fi
# Bullet
download "Bullet 2.89 (${BULLET_DBL_DISPLAY})" \
"https://gitlab.com/OpenMW/openmw-deps/-/raw/main/windows/Bullet-2.89-msvc${MSVC_YEAR}-win${BITS}${BULLET_DBL}.7z" \
"Bullet-2.89-msvc${MSVC_YEAR}-win${BITS}${BULLET_DBL}.7z"
download "Bullet 2.89" \
"https://gitlab.com/OpenMW/openmw-deps/-/raw/main/windows/Bullet-2.89-msvc${MSVC_YEAR}-win${BITS}-double.7z" \
"Bullet-2.89-msvc${MSVC_YEAR}-win${BITS}-double.7z"
# FFmpeg
download "FFmpeg 4.2.2" \
@ -680,15 +663,15 @@ fi
cd $DEPS
echo
# Bullet
printf "Bullet 2.89 (${BULLET_DBL_DISPLAY})... "
printf "Bullet 2.89... "
{
cd $DEPS_INSTALL
if [ -d Bullet ]; then
printf -- "Exists. (No version checking) "
elif [ -z $SKIP_EXTRACT ]; then
rm -rf Bullet
eval 7z x -y "${DEPS}/Bullet-2.89-msvc${MSVC_YEAR}-win${BITS}${BULLET_DBL}.7z" $STRIP
mv "Bullet-2.89-msvc${MSVC_YEAR}-win${BITS}${BULLET_DBL}" Bullet
eval 7z x -y "${DEPS}/Bullet-2.89-msvc${MSVC_YEAR}-win${BITS}-double.7z" $STRIP
mv "Bullet-2.89-msvc${MSVC_YEAR}-win${BITS}-double" Bullet
fi
add_cmake_opts -DBULLET_ROOT="$(real_pwd)/Bullet"
echo Done.

@ -25,6 +25,5 @@ cmake \
-D BUILD_BSATOOL=TRUE \
-D BUILD_ESSIMPORTER=TRUE \
-D BUILD_NIFTEST=TRUE \
-D BULLET_USE_DOUBLES=TRUE \
-G"Unix Makefiles" \
..

@ -35,7 +35,6 @@ option(BUILD_DOCS "Build documentation." OFF )
option(BUILD_WITH_CODE_COVERAGE "Enable code coverage with gconv" OFF)
option(BUILD_UNITTESTS "Enable Unittests with Google C++ Unittest" OFF)
option(BUILD_BENCHMARKS "Build benchmarks with Google Benchmark" OFF)
option(BULLET_USE_DOUBLES "Use double precision for Bullet" ON)
set(OpenGL_GL_PREFERENCE LEGACY) # Use LEGACY as we use GL2; GLNVD is for GL3 and up.
@ -314,6 +313,12 @@ if(OPENMW_USE_SYSTEM_BULLET)
endif()
find_package(Bullet ${REQUIRED_BULLET_VERSION} REQUIRED COMPONENTS BulletCollision LinearMath)
include(cmake/CheckBulletPrecision.cmake)
if (HAS_DOUBLE_PRECISION_BULLET)
message(STATUS "Bullet uses double precision")
else()
message(FATAL_ERROR "Bullet does not uses double precision")
endif()
endif()
if (NOT WIN32 AND BUILD_WIZARD) # windows users can just run the morrowind installer

@ -0,0 +1,45 @@
set(TMP_ROOT ${CMAKE_BINARY_DIR}/try-compile)
file(MAKE_DIRECTORY ${TMP_ROOT})
file(WRITE ${TMP_ROOT}/checkbullet.cpp
"
#include <BulletCollision/CollisionShapes/btSphereShape.h>
int main(int argc, char** argv)
{
btSphereShape shape(1.0);
btScalar mass(1.0);
btVector3 inertia;
shape.calculateLocalInertia(mass, inertia);
return 0;
}
")
file(WRITE ${TMP_ROOT}/CMakeLists.txt
"
cmake_minimum_required(VERSION 3.1.0)
project(checkbullet)
add_executable(checkbullet checkbullet.cpp)
find_package(Bullet REQUIRED COMPONENTS BulletCollision LinearMath)
target_compile_definitions(checkbullet PUBLIC BT_USE_DOUBLE_PRECISION)
include_directories(\$\{BULLET_INCLUDE_DIRS\})
include(${CMAKE_SOURCE_DIR}/cmake/OSIdentity.cmake)
if (UBUNTU_FOUND OR DEBIAN_FOUND)
target_link_libraries(checkbullet BulletCollision-float64 LinearMath-float64)
else()
target_link_libraries(checkbullet \$\{BULLET_LIBRARIES\})
endif()
")
if (DEFINED BULLET_ROOT)
set(ROOT "-DBULLET_ROOT=${BULLET_ROOT}")
endif()
message(STATUS "Checking if Bullet uses double precision")
try_compile(RESULT_VAR
${CMAKE_BINARY_DIR}/temp
${TMP_ROOT}
checkbullet
CMAKE_FLAGS "${ROOT}"
)
set(HAS_DOUBLE_PRECISION_BULLET ${RESULT_VAR})

@ -254,7 +254,7 @@ target_link_libraries(components
RecastNavigation::Recast
)
if (BULLET_USE_DOUBLES AND (UBUNTU_FOUND OR DEBIAN_FOUND) AND OPENMW_USE_SYSTEM_BULLET)
if ((UBUNTU_FOUND OR DEBIAN_FOUND) AND OPENMW_USE_SYSTEM_BULLET)
target_link_libraries(components BulletCollision-float64 LinearMath-float64)
else()
target_link_libraries(components ${BULLET_LIBRARIES})
@ -292,6 +292,4 @@ endif()
# Make the variable accessible for other subdirectories
set(COMPONENT_FILES ${COMPONENT_FILES} PARENT_SCOPE)
if (BULLET_USE_DOUBLES)
target_compile_definitions(components PUBLIC BT_USE_DOUBLE_PRECISION)
endif()
target_compile_definitions(components PUBLIC BT_USE_DOUBLE_PRECISION)

@ -28,7 +28,7 @@ if(NOT OPENMW_USE_SYSTEM_BULLET)
set(BUILD_CPU_DEMOS OFF CACHE BOOL "")
set(BUILD_EGL OFF CACHE BOOL "")
set(USE_DOUBLE_PRECISION ${BULLET_USE_DOUBLES} CACHE BOOL "")
set(USE_DOUBLE_PRECISION ON CACHE BOOL "")
set(BULLET2_MULTITHREADING ON CACHE BOOL "")
if(BULLET_STATIC)

Loading…
Cancel
Save