diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 860b079d..6c64c8ab 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -18,6 +18,11 @@ set(MUJOCO_TEST_WORKING_DIR ${CMAKE_CURRENT_SOURCE_DIR}) include(GoogleTest) macro(mujoco_test name) + set(options) + set(oneValueArgs) + set(multiValueArgs PROPERTIES) + cmake_parse_arguments(_ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + add_executable(${name} ${name}.cc) target_link_libraries(${name} gtest_main mujoco) target_include_directories(${name} PRIVATE ${MUJOCO_TEST_INCLUDE}) @@ -34,6 +39,9 @@ macro(mujoco_test name) ${testList} PROPERTIES ENVIRONMENT "PATH=$;$ENV{PATH}" ) endif() + if(_ARGS_PROPERTIES) + set_tests_properties(${testList} PROPERTIES ${_ARGS_PROPERTIES}) + endif() endmacro() add_library(fixture STATIC fixture.h fixture.cc) @@ -65,7 +73,4 @@ add_subdirectory(engine) add_subdirectory(sample) add_subdirectory(user) add_subdirectory(xml) - -if(NOT WIN32) - add_subdirectory(plugin/elasticity) -endif() +add_subdirectory(plugin/elasticity) diff --git a/test/plugin/elasticity/CMakeLists.txt b/test/plugin/elasticity/CMakeLists.txt index e62dae06..008ae8be 100644 --- a/test/plugin/elasticity/CMakeLists.txt +++ b/test/plugin/elasticity/CMakeLists.txt @@ -12,6 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -mujoco_test(elasticity_test) -target_link_libraries(elasticity_test fixture gmock elasticity) - +mujoco_test( + elasticity_test + PROPERTIES + ENVIRONMENT + "MUJOCO_PLUGIN_DIR=$" +) +target_link_libraries(elasticity_test fixture gmock) diff --git a/test/plugin/elasticity/elasticity_test.cc b/test/plugin/elasticity/elasticity_test.cc index c5e70674..b94c74a9 100644 --- a/test/plugin/elasticity/elasticity_test.cc +++ b/test/plugin/elasticity/elasticity_test.cc @@ -27,8 +27,28 @@ namespace mujoco { namespace { -using PluginTest = MujocoTest; +class PluginTest : public MujocoTest { + public: + // load plugin library + PluginTest() : MujocoTest() { + #if defined(_WIN32) || defined(__CYGWIN__) + mj_loadPluginLibrary(( + std::string(std::getenv("MUJOCO_PLUGIN_DIR")) + + std::string("\\elasticity.dll")).c_str()); + #else + #if defined(__APPLE__) + mj_loadPluginLibrary(( + std::string(std::getenv("MUJOCO_PLUGIN_DIR")) + + std::string("/libelasticity.dylib")).c_str()); + #else + mj_loadPluginLibrary(( + std::string(std::getenv("MUJOCO_PLUGIN_DIR")) + + std::string("/libelasticity.so")).c_str()); + #endif + #endif + } +}; // -------------------------------- cable -----------------------------------