Reduce cmake test boilerplate
All instances of mujoco_test in the code base were followed by a call to target_link_libraries(<testname> fixture gmock). As anyhow mujoco_test already was calling target_link_libraries to some predefined list of targets (mujoco and gtest_main), this PR adds to the list of default linked targets also fixture and gmock, to reduce the boilerplate. Furthermore, to completly remove the need for calling target_link_libraries after a call to mujoco_test, this PR also add to the mujoco_test macro the ADDITIONAL_LINK_LIBRARIES argument, that can be used if a given test needs to link some additional targets beside the default ones. To permit to use these new features also for mujoco benchmarks, this PR adds a MAIN_TARGET parameter to mujoco_test, to select if gtest_main or another target is used to provide the main entry point to the test executable.
This commit is contained in:
@@ -12,11 +12,9 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
mujoco_test(user_model_test)
|
||||
target_link_libraries(user_model_test fixture gmock absl::str_format)
|
||||
mujoco_test(user_model_test ADDITIONAL_LINK_LIBRARIES absl::str_format)
|
||||
|
||||
mujoco_test(user_objects_test)
|
||||
target_link_libraries(user_objects_test fixture gmock)
|
||||
|
||||
mujoco_test(
|
||||
user_api_test
|
||||
@@ -24,24 +22,13 @@ mujoco_test(
|
||||
ENVIRONMENT
|
||||
"MUJOCO_PLUGIN_DIR=$<TARGET_FILE_DIR:elasticity>"
|
||||
)
|
||||
target_link_libraries(user_api_test fixture gmock)
|
||||
|
||||
mujoco_test(user_flex_test)
|
||||
target_link_libraries(user_flex_test fixture gmock)
|
||||
|
||||
mujoco_test(user_mesh_test)
|
||||
target_link_libraries(
|
||||
user_mesh_test
|
||||
fixture
|
||||
gmock
|
||||
absl::str_format
|
||||
)
|
||||
mujoco_test(user_mesh_test ADDITIONAL_LINK_LIBRARIES absl::str_format)
|
||||
|
||||
mujoco_test(user_composite_test)
|
||||
target_link_libraries(user_composite_test fixture gmock)
|
||||
|
||||
mujoco_test(user_resource_test)
|
||||
target_link_libraries(user_resource_test fixture gmock)
|
||||
|
||||
mujoco_test(user_vfs_test)
|
||||
target_link_libraries(user_vfs_test fixture gmock)
|
||||
|
||||
Reference in New Issue
Block a user