Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get bullet version from cmake instead of API #591

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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