diff --git a/test/common_test/CMakeLists.txt b/test/common_test/CMakeLists.txt index 2e38a0c25..71acbda11 100644 --- a/test/common_test/CMakeLists.txt +++ b/test/common_test/CMakeLists.txt @@ -1,5 +1,4 @@ set(TEST_TYPE "COMMON_TEST") -include_directories(${BULLET_INCLUDE_DIRS}) set(tests added_mass @@ -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) @@ -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}) diff --git a/test/common_test/joint_transmitted_wrench_features.cc b/test/common_test/joint_transmitted_wrench_features.cc index 8d1563b2d..21fb52576 100644 --- a/test/common_test/joint_transmitted_wrench_features.cc +++ b/test/common_test/joint_transmitted_wrench_features.cc @@ -17,7 +17,6 @@ #include #include -#include #include #include @@ -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 ` 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. @@ -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 ` 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);