diff --git a/matlab/CMakeLists.txt b/matlab/CMakeLists.txt index 36350a53ccfad..d73173b58e78a 100644 --- a/matlab/CMakeLists.txt +++ b/matlab/CMakeLists.txt @@ -326,6 +326,13 @@ if(MATLAB_BUILD_TESTS) # targets. target_link_libraries(placeholder_test GTest::gtest GTest::gtest_main) + # Ensure using GTest:gtest and GTest::gtest_main on macOS without + # specifying DYLD_LIBRARY_DIR. + set_target_properties(placeholder_test + PROPERTIES BUILD_RPATH + "$;$" + ) + # Add test targets for C++ tests. add_test(PlaceholderTestTarget placeholder_test)