Skip to content

Instantly share code, notes, and snippets.

@drewler
Last active October 17, 2021 10:06
Show Gist options
  • Save drewler/e741a34c47a205eb787125f3c3273ecb to your computer and use it in GitHub Desktop.
Save drewler/e741a34c47a205eb787125f3c3273ecb to your computer and use it in GitHub Desktop.

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)

FROM ubuntu:20.04
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get install -y software-properties-common gpg
RUN add-apt-repository ppa:freecad-maintainers/freecad-daily
RUN apt-get update
# Compilation
RUN apt-get install -y \
build-essential \
cmake \
libtool \
lsb-release
# Python
RUN apt-get install -y \
python3 \
swig
# Boost
RUN apt-get install -y \
libboost-dev \
libboost-date-time-dev \
libboost-filesystem-dev \
libboost-graph-dev \
libboost-iostreams-dev \
libboost-program-options-dev \
libboost-python-dev \
libboost-regex-dev \
libboost-serialization-dev \
libboost-thread-dev
# Coin
RUN apt-get install -y \
libcoin-dev
# QT
RUN apt-get install -y \
qtbase5-dev \
qttools5-dev \
qt5-default \
libqt5opengl5-dev \
libqt5svg5-dev \
libqt5webkit5-dev \
libqt5xmlpatterns5-dev \
libqt5x11extras5-dev \
libpyside2-dev \
libshiboken2-dev \
pyside2-tools \
pyqt5-dev-tools \
python3-dev \
python3-matplotlib \
python3-pivy \
python3-ply \
python3-pyside2.qtcore \
python3-pyside2.qtgui \
python3-pyside2.qtsvg \
python3-pyside2.qtwidgets \
pyqt5-dev-tools
# python3-pyside2ui
ENV PATH="/usr/local/Qt-5/bin:${PATH}"
# Misc
RUN apt-get install -y \
libeigen3-dev \
libgts-bin \
libgts-dev \
libkdtree++-dev \
libmedc-dev \
libopencv-dev \
libproj-dev \
libvtk7-dev \
libx11-dev \
libxerces-c-dev \
libzipios++-dev
# Extra
RUN apt-get install -y \
libxkbcommon-x11-0
# Add enviroment varaible so CMake can find QT5
ENV CMAKE_PREFIX_PATH=/usr/local/Qt-5
# So Qt5 can find it's shared libaries
RUN echo "/usr/local/Qt-5/lib" > /etc/ld.so.conf.d/qt5.conf && \
ldconfig
# FreeCAD
RUN apt-get install -y \
libocct*-dev \
occt-draw
RUN apt-get install -y cmake-curses-gui
RUN apt-get install -y clang
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment