Start by creating some folder where source code and build artifacts will be stored.
mkdir -p ~/projects/freecad
mkdir ~/projects/freecad/build
cd ~/projects/freecad
Clone FreeCAD's source code into the source
folder
git clone https://github.com/FreeCAD/FreeCAD source
Build a docker image with all the required build and runtime dependencies
wget https://gist.githubusercontent.com/drewler/e741a34c47a205eb787125f3c3273ecb/raw/92f9eb6421557ad1d5fcb19407f11de199bee6f4/Dockerfile
docker build . -t freecad-env:latest
Run the build commands (+ measure total execution time)
# CMake
time docker run --rm -e CC=clang-10 -e CXX=clang++-10 -v $(pwd)/build:/build -v $(pwd)/source:/source -it freecad-env:latest bash -c "cd /build && cmake -DBUILD_QT5=ON -DPYTHON_EXECUTABLE=/usr/bin/python3 -DCMAKE_BUILD_TYPE=Debug /source"
# make
time docker run --rm -e CC=clang-10 -e CXX=clang++-10 -v $(pwd)/build:/build -v $(pwd)/source:/source -it freecad-env:latest bash -c "cd /build && make -j$(nproc --ignore=2)"
Run FreeCAD GUI
docker run --rm -e "DISPLAY" -v /tmp/.X11-unix:/tmp/.X11-unix:ro -v $(pwd)/build:/build -it freecad-env:latest /build/bin/FreeCAD
(It can run on WSL if there's an X server configured)