Build FontForge Using CMake Instead of Configure

Yes, you can build FontForge using CMake, and it is now the officially recommended and supported method. Modern versions of FontForge have replaced the legacy Autotools (./configure and make) build system entirely with CMake. This article outlines the prerequisites, the build process, and common configuration options needed to build FontForge from source using CMake on Unix-like systems (Linux and macOS).

Why the Shift to CMake?

FontForge transitioned from GNU Autotools to CMake to streamline cross-platform builds, improve compilation speeds, and offer better native support for operating systems like Windows and macOS. The traditional ./configure script is no longer maintained in modern branches of the repository.

Prerequisites

Before compiling, ensure you have CMake (version 3.14 or newer), a C/C++ compiler (GCC or Clang), Git, and the required development libraries installed. On Debian- or Ubuntu-based distributions, you can install the core build tools and dependencies with:

sudo apt update
sudo apt install build-essential cmake ninja-build git \
    libfreetype6-dev libglib2.0-dev libpng-dev libjpeg-dev \
    libtiff-dev libgif-dev libxml2-dev libspiro-dev libuninameslist-dev \
    python3-dev libgtk-3-dev

(Package names may vary slightly on Fedora, Arch Linux, or macOS via Homebrew).

Step-by-Step Build Instructions

Follow these steps to clone the repository and build the binary using CMake:

  1. Clone the FontForge Repository:

    git clone --depth 1 https://github.com/fontforge/fontforge.git
    cd fontforge
  2. Configure the Project: Create an out-of-source build directory and run CMake to detect dependencies and generate the build files. Using the Ninja build system is recommended for faster builds, but standard Makefiles work as well.

    cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release

    (If you do not have Ninja installed, omit -G Ninja to use standard Makefiles).

  3. Compile FontForge: Execute the build command. CMake will automatically use the appropriate number of processor cores:

    cmake --build build
  4. Install the Application: Once compilation completes without errors, install FontForge to your system:

    sudo cmake --install build

Common CMake Build Flags

You can customize the compilation by passing flags during the configuration step (cmake -B build ...):

  • -DENABLE_GUI=ON/OFF: Build the graphical interface (defaults to ON).
  • -DENABLE_PYTHON_SCRIPTING=ON/OFF: Enable Python bindings and scripting (defaults to ON).
  • -DENABLE_PYTHON_EXTENSION=ON/OFF: Build the Python extension module.
  • -DENABLE_FONTFORGE_EXTRAS=ON/OFF: Build additional standalone utilities.
  • -DCMAKE_INSTALL_PREFIX=/path/to/dir: Set a custom installation path instead of the system default (/usr/local).