How to run ctest on non-build machine?

Option A: Create a package on the build machine and install that package on the test machine, then run your tests against that.

Option B: Build all your executables and shared libraries with the install RPATH, and base those on relative locations using $ORIGIN. This assumes the relative directory structure of the binaries in your build tree matches your installed structure, which frequently isn’t the case.