Skip to content

Commit

Permalink
Get bullet version from cmake instead of API
Browse files Browse the repository at this point in the history
Adapted from #574.

Signed-off-by: Steve Peters <[email protected]>
  • Loading branch information
iche033 authored and scpeters committed Jan 18, 2024
1 parent 216f174 commit d938c15
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
12 changes: 11 additions & 1 deletion test/common_test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
set(TEST_TYPE "COMMON_TEST")
include_directories(${BULLET_INCLUDE_DIRS})

set(tests
added_mass
Expand Down Expand Up @@ -47,6 +46,10 @@ endfunction()

set(GZ_PHYSICS_RESOURCE_DIR "${CMAKE_SOURCE_DIR}/resources")

# Get bullet version using pkg_check_modules as it is not available
# through the cmake module
gz_pkg_check_modules_quiet(bullet_version_check "bullet")

foreach(test ${tests})
set(test_executable "${TEST_TYPE}_${test}")
add_executable(${test_executable} ${test}.cc)
Expand All @@ -67,6 +70,13 @@ foreach(test ${tests})
"GZ_PHYSICS_RESOURCE_DIR=\"${GZ_PHYSICS_RESOURCE_DIR}\""
)

if (bullet_version_check_VERSION VERSION_LESS_EQUAL 3.25)
target_compile_definitions(${test_executable} PRIVATE
"BT_BULLET_VERSION_LE_325"
)
endif()


install(TARGETS ${test_executable} DESTINATION ${TEST_INSTALL_DIR})

configure_common_test("bullet" ${test_executable})
Expand Down
17 changes: 6 additions & 11 deletions test/common_test/joint_transmitted_wrench_features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <gtest/gtest.h>

#include <chrono>
#include <LinearMath/btScalar.h>

#include <gz/common/Console.hh>
#include <gz/plugin/Loader.hh>
Expand Down Expand Up @@ -225,12 +224,10 @@ TYPED_TEST(JointTransmittedWrenchFixture, PendulumAtZeroAngle)
TYPED_TEST(JointTransmittedWrenchFixture, PendulumInMotion)
{
// This test requires https://github.com/bulletphysics/bullet3/pull/4462
// When removing this check, also remove
// `#include <LinearMath/btScalar.h>` at the top of this file, and
// `include_directories(${BULLET_INCLUDE_DIRS})` from
// test/common_test/CMakeLists.txt
if (this->engineName == "bullet-featherstone" && btGetVersion() <= 325)
#ifdef BT_BULLET_VERSION_LE_325
if (this->engineName == "bullet-featherstone")
GTEST_SKIP();
#endif

// Start pendulum at 90° (parallel to the ground) and stop at about 40°
// so that we have non-trivial test expectations.
Expand Down Expand Up @@ -418,12 +415,10 @@ TYPED_TEST(JointTransmittedWrenchFixture, JointLosses)
TYPED_TEST(JointTransmittedWrenchFixture, ContactForces)
{
// This test requires https://github.com/bulletphysics/bullet3/pull/4462
// When removing this check, also remove
// `#include <LinearMath/btScalar.h>` at the top of this file, and
// `include_directories(${BULLET_INCLUDE_DIRS})` from
// test/common_test/CMakeLists.txt
if (this->engineName == "bullet-featherstone" && btGetVersion() <= 325)
#if BT_BULLET_VERSION_LE_325
if (this->engineName == "bullet-featherstone")
GTEST_SKIP();
#endif

auto box = this->world->GetModel("box");
ASSERT_NE(nullptr, box);
Expand Down

0 comments on commit d938c15

Please sign in to comment.