GNU TeXmacsUser manualReferenceAboutEnglish
Building with CMake

1.Quick start

An out-of-source build, which is the recommended way, looks like

cmake -B build -G Ninja
cmake --build build

run from

src/

. The default SCHEME_IMPL is s7, the S7 interpreter whose sources are in the tree; -DSCHEME_IMPL=embedded18 builds the embedded Guile, whose sources must first be made available as src/tm-guile188/ (from the guile-texmacs repository), and -DSCHEME_IMPL=guile uses an installed Guile. The resulting binary is build/TeXmacs/bin/texmacs.bin (texmacs.exe on Windows, a TeXmacs.app bundle on macOS), and the runtime tree is build/TeXmacs/.

2.Options

The cache variables and options defined in

CMakeLists.txt

are:

CMAKE_BUILD_TYPE

Defaults to Release.

SCHEME_IMPL

s7 (the default), which compiles the S7 interpreter of

Scheme/S7

and defines USE_S7; embedded18 (or its synonym tm-guile188), which builds tm-guile188/ as a subproject and defines GUILE_C; or anything else, such as guile, in which case pkg-config looks for guile-1.8, guile-3.0, guile-2.2 or guile-2.0 (in this order) and defines GUILE_C for 1.8 and GUILE_D for 2.0 and later. The meaning of these dialect macros is explained in the Scheme interpreter.

TEXMACS_GUI

One of Qt (the default, which uses Qt 6 if it is found and Qt 5 otherwise), Qt6, Qt5, Qt4, Vue, SDL or X11, as ./configure --with-gui (any other value is an error). Qt6 is treated like Qt: there is no branch which insists on Qt 6. All Qt variants compile the sources of

src/Plugins/Qt/

and define QTTEXMACS; Vue compiles

src/Plugins/Vue/

(in C++20, with Clay), SDL and X11 their directory and

src/Plugins/Widkit/

. The Qtwk and Cocoa ports and the fork

src/Plugins/Qt6/

are only available with configure.

USE_MUPDF

(on for Vue and SDL, which require it, off otherwise, and forced off for X11) Compile

Plugins/MuPDF

and define MUPDF_RENDERER; the library is looked for in MUPDF_DIR.

THORVG_DIR

(empty) For Vue, the prefix of a ThorVG build (include/thorvg-1/thorvg.h and lib/libthorvg-1.a, as made by

misc/thorvg/build-thorvg.sh

): defines USE_THORVG and links OpenGL, for the GPU renderer of Vue, as configure --with-thorvg. Without it Vue draws with MuPDF only.

QTPIPES

(on) Use Qt classes instead of Unix pipes for plug-in connections.

USE_RESVG

(on) Use the resvg library for SVG images if it is found in one of the local prefixes; the option is silently switched off otherwise.

USE_ASPELL

(on) Link the Aspell library if it is found; switched off otherwise.

USE_FREETYPE

(on) FreeType is then required.

USE_GNUTLS

(on) GnuTLS is then required (it is used by the TeXmacs server and client, see collaboration, remote servers and versioning).

USE_SQLITE3

(on) Link SQLite if found, which enables the

Plugins/Sqlite3

back-end of the database.

ENABLE_EXPERIMENTAL

(off) Compile the experimental style rewriting code in

src/Style/

and define EXPERIMENTAL.

Several settings are not options but fixed: DEBUG_ASSERT is always 1 (so ASSERT and FAILED are active in all builds), PNG and zlib are required, iconv is used if found, the native PDF renderer (Hummus) is compiled for Qt without MuPDF (MuPDF writes the PDF otherwise), and the path of Ghostscript is hard-wired (/usr/bin/gs, or bin/gs.exe on Windows). If ccache is installed, it is used automatically.

Additional prefixes are searched for dependencies: the local/ subdirectory of the environment variable WORKING_DIR_WIN or WORKING_DIR, and a directory ../../local next to the repository, which is how the TeXmacs builder scripts provide their own copies of the libraries.

3.How the build is organized

Source lists.
The sources are collected with file (GLOB_RECURSE …) from the directories Data, Edit, Graphics, Kernel,
Scheme/Scheme

and

Scheme/Guile

, System, Typeset, part of Texmacs, the standard plug-ins (Bibtex, Cairo, Imlib2, Database, Freetype, Gnutls, Ghostscript, Ispell, Metafont, LaTeX_Preview, Openssl, Updater, and optionally Pdf, MuPDF, Resvg and Sqlite3), the directories of the chosen port (see TEXMACS_GUI above), and the operating system layer (

Plugins/Unix

on Linux,

Plugins/Windows

or

Plugins/Windows64

on Windows,

Plugins/Unix

and

Plugins/MacOS

on macOS). Since the lists are globbed, a new .cpp file is picked up automatically, but only after CMake is run again; a file in a directory which is not listed (for instance a new plug-in directory) must be added to

CMakeLists.txt

. The

Plugins/Qt6

,

Plugins/Qtwk

and

Plugins/NS

directories are never compiled by CMake.

Targets.
All sources are compiled once into the object library texmacs_body (
src/CMakeLists.txt

), with AUTOMOC for the Qt classes and with the generated config.h force-included in every file (-include …/src/System/config.h). The executables are then linked from these objects:

The C++ unit tests of

tests/

link against the same object library; see automatic tests.

The runtime tree.
In an out-of-source build, the whole
TeXmacs/

directory is copied into the build directory when CMake runs, and the target deploy_texmacs_to_build (part of ALL) copies it again at every build, so that changes to Scheme files, styles or documentation reach the build tree. The copy only adds and overwrites files: a file deleted in the source tree stays in the build tree until the build directory is cleaned. An in-source build (with a warning) uses

TeXmacs/

directly and writes the generated files into the source tree. In both cases the version string is written to TeXmacs/SVNREV.

Generated headers.
config.h and tm_configure.hpp are generated with configure_file from
src/System/config.h.cmake

and

src/System/tm_configure.hpp.cmake

into build/src/System/. The first one holds the feature macros (QTTEXMACS, USE_FREETYPE, GUILE_C, …), the second the version, the build user and date, and the host description reported by -version and in crash reports. The scripts texmacs and fig2ps and the manual page are generated by

misc/CMakeLists.txt

.

The glue.
The CMake build compiles the generated glue files src/Scheme/Glue/glue_*.cpp as they are in the repository and has no rule to regenerate them. After changing a build-glue-*.scm file, run the generator by hand or with make GLUE from an autotools build; see the Scheme glue.
Installation.
cmake --install installs the executable, the
TeXmacs/

tree into share/TeXmacs (or the installation prefix itself on Windows), the plug-ins, and the desktop file, icons and MIME description for Linux desktops.

4.Pitfalls

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".