less than 1 minute read

Install mold on your linux box.

Enable mold for gcc/clang by supplying -fuse-ld=mold, e.g.

clang -fuse-ld=mold a.cpp

Enable in CMake by supplying arguments via cli, e.g.

cmake -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=mold" -DCMAKE_SHARED_LINKER_FLAGS="-fuse-ld=mold"

or via CMakeUserPreset.json, e.g.

{
    "version": 3,
    "configurePresets": [
        {
            "name": "test",
            "hidden": false,
            "inherits": [
                "base-test"
            ],
            "cacheVariables": {
                "CMAKE_EXE_LINKER_FLAGS": "-fuse-ld=mold",
                "CMAKE_SHARED_LINKER_FLAGS": "-fuse-ld=mold"
            }
        }
    ]
}


Source: https://gist.github.com/MawKKe/b8af6c1555f1c7aa4c2760350ed97fff