Complicated remote scenarios | CLion
This article gives general recommendations for the case when you need to build a CMake or Makefile application on a remote system and then debug it on another remote system:
https://www.jetbrains.com/help/clion/complicated-remote-scenarios.html?keymap=macOS