Skip to content

CLion Remote Build over SSH

With already-mounted and shared sources through NFS.

Situation

  • CLion builds on a remote Ubuntu 24.04 host (a Docker container, DockerRemoteGA) over SSH.
  • The sources are already on the remote at /mnt/project/qt-tts-piper.
  • Locally CLion sees the same project at /mnt/server/userdata/source/cppsrc/qt-tts-piper.
  • Goal: build remotely, with path mapping only and no file syncing.

Steps

1. Remote toolchain

Add a Remote Host type of toolchain to the list at Settings | Build, Execution, Deployment | Toolchains → ➕ → Remote Host

  • Enter host, port, user and authentication (a key pair avoids the password prompt that showed up in the rsync log).
  • Test the connection and make sure CMake, compiler and debugger are detected.

Toolchains are linked to presets from CMake using in the CMakePresets.json.
Shown here is an example of an include file so actual configuration presets can inherit.

{
    "version": 8,
    "cmakeMinimumRequired": {
        "major": 3,
        "minor": 29,
        "patch": 0
    },
    "configurePresets": [
        {
            "name": ".tc-gnu",
            "description": "Toolchain for generic GNU",
            "hidden": true,
            "cacheVariables": {
                "SF_COMPILER": {
                    "type": "STRING",
                    "value": "gnu"
                },
                "SF_QT_BIN_SUBDIR": {
                    "type": "STRING",
                    "value": "gcc_64/bin"
                }
            },
            "vendor": {
                "jetbrains.com/clion": {
                    "toolchain": "GNU"
                }
            }
        }
    ]
}

2. Deployment Server

Settings | Build, Execution, Deployment | Deployment

  • Use the SFTP server for the remote host (same credentials as the toolchain).
  • Do not use type In Place. It only has Local path and Web path, so it cannot express a remote location.
  • Make it the default server (checkmark icon).
  • On the Mappings tab:
Field Value
Local path /mnt/server/userdata/source/cppsrc/qt-tts-piper
Deployment path /mnt/project/qt-tts-piper
Web path empty

Why: CLion needs the mapping to translate between local and remote paths (build output, debugger, compiler messages). Nothing has to be copied, because the files are already there.

3. Stop CLion from uploading files

CLion just keeps trying to upload files even though they are already on the server and 'Confirm uploading files' is marked.

The settings page Settings | Build, Execution, Deployment | Deployment | Options has field named 'Exclude items by name'. Add a wildcard (*) like this .svn;.cvs;.idea;.DS_Store;.git;.hg;*.hprof;*.pyc;.junie;* and prevent any non-hidden file to be uploaded.

Note: Hidden file/directries can not be excluded since it is needed for:
/mnt/server/userdata/source/cppsrc/qt-tts-piper/cmake-build/d-ga-debug/.cmake/api/v1/reply
which exchanges information between CLion and the remote server.

The field 'Upload changed files automatically to the default server' needs to be set to Never.