![]() |
Selecting and building a port | ![]() |
One macro identifies the port in config.h (and on the command line of the make build, through -D@CONFIG_GUI_DEFINE@ in
src/makefile.in
):
Qt port (
Plugins/Qt
or
Plugins/Qt6
).
Qtwk (
Plugins/Qtwk
and
Plugins/Widkit
); QTTEXMACS is defined as well, since Qtwk uses the application, fonts, pictures, renderer and pipes of the Qt port.
X11 port (
Plugins/X11
and Widkit).
SDL port (
Plugins/SDL
and Widkit).
Vue port (
Plugins/Vue
).
Cocoa port (
Plugins/NS
).
Outside the port directories, many files test these macros, typically to include the header which defines simple_widget_rep. For instance
Texmacs/Window/tm_button.cpp
chooses between
NS/ns_simple_widget.h
(AQUATEXMACS),
Qt/qt_simple_widget.hpp
(QTTEXMACS without QTWKTEXMACS),
Vue/vue_widget.hpp
(VUETEXMACS) and, in the #else branch,
Widkit/simple_wk_widget.hpp
. Other tests enable features which only exist in some ports: the Cocoa port is treated as Qt by the generic code wherever that has Qt specific parts (delayed commands, native pictures, drops, the repainting and the mouse of the editor), and Vue often shares the X11 branch (for instance to center the paper in a wider canvas,
Edit/Interface/edit_interface.cpp
). Because QTTEXMACS holds in Qtwk, code which really needs Qt widgets must test QTWKTEXMACS too. A new port must add its own branches, and the #else branch is usually the Widkit code. Code which depends on the Qt version tests QT_VERSION instead, see the Qt port.
The autoconf macro TM_GUI (
misc/m4/tm_gui.m4
) reads --with-gui=port:
The Qt port, with the Qt version found by LC_WITH_QT. On macOS it also enables the Objective-C helpers of
Plugins/MacOS
(CONFIG_MACOS).
The same Qt setup, but CONFIG_QT= "Qtwk Widkit":
src/makefile.in
then compiles
Plugins/Qtwk
, Widkit and only eight files of Plugins/Qt (
qt_renderer.cpp
,
qt_font.cpp
,
qt_picture.cpp
,
qt_utilities.cpp
, the pipes, the sockets and
qt_http.cpp
), and runs the meta object compiler on three headers of Qtwk.
The X11 port. It looks for the X11 headers and libraries, sets CONFIG_X11= "X11 Widkit" (plus Ghostscript when Ghostscript is not configured otherwise) and defines X11TEXMACS.
The SDL port: SDL3 (--with-sdl3,
misc/m4/sdl3.m4
), CONFIG_SDL= "SDL Widkit".
The Vue port: SDL3 and, with --with-thorvg=prefix (
misc/m4/thorvg.m4
), the GPU renderer (USE_THORVG; ThorVG is built by
misc/thorvg/build-thorvg.sh
, and OpenGL is linked). The sources of
Plugins/Vue
are compiled with -std=c++20, and
clay.c
as C.
The Cocoa port: defines AQUATEXMACS, sets CONFIG_COCOA= NS and links with -framework Cocoa -framework PDFKit. It needs the macOS extensions (CONFIG_MACOS), so --disable-macosx-extensions is refused. The packaging script
packages/macos/build-ns-app.sh
configures, builds and bundles it.
Compile
Plugins/Qt6
instead of Plugins/Qt (
misc/m4/qt.m4
): the variable QT_PLUGIN_DIR becomes Qt6, which selects both the sources and the include path -IPlugins/Qt6. The option is on by default when CONFIG_OS is ANDROID, and configure stops with an error if the Qt found is older than 6.10. Qtwk always takes its files from Plugins/Qt.
Use Qt processes instead of Unix pipes for plug-ins (QTPIPES). It is the default of qt and qtwk and refused with the other ports.
Whether MuPDF is used depends on the port (TM_MUPDF_FOR_GUI in
misc/m4/mupdf.m4
): SDL and Vue draw with it and need --with-mupdf, Qt uses it for pictures when it is found, and X11 and Cocoa, whose pictures clash with those of MuPDF at link time, refuse it.
src/makefile.in
then compiles the port directories through the substituted variables: @CONFIG_X11@, @CONFIG_SDL@ and @CONFIG_VUE@ for the C++ sources, @CONFIG_COCOA@ @CONFIG_MACOS@ for the Objective-C sources, and, for Qt, the directory Plugins/$(QT_PLUGIN_DIR) (with the Qt meta object compiler run on its headers when @CONFIG_QT@ is not empty).
The top level
CMakeLists.txt
declares
set (TEXMACS_GUI "Qt" CACHE STRING "TeXmacs Gui (Qt, Qt6, Qt5, Qt4, Vue, SDL, X11)") option (QTPIPES "use Qt pipes" ON) |
and stops with an error for any other value.
Qt4 and Qt5 force the corresponding major version; Qt and Qt6 look for Qt 6 first and fall back to Qt 5. The components used are Core, Gui, Widgets, PrintSupport, Svg and Network. The sources are Plugins/Qt/*.cpp and *.hpp, without the moc_*.cpp left by a make build, since CMake runs its own AUTOMOC. Qt6 does not select
Plugins/Qt6
.
SDL3 and SDL3_ttf through pkg-config, and MuPDF (USE_MUPDF, on by default for these two, with MUPDF_DIR as a hint), without which the configuration stops. The Vue sources are compiled as C++20 in an object library of their own (texmacs_cxx20 in
src/CMakeLists.txt
). For Vue, THORVG_DIR (empty by default) names the prefix of a ThorVG build made by
misc/thorvg/build-thorvg.sh
: it defines USE_THORVG and links OpenGL, for the GPU renderer, as --with-thorvg does; without it the CMake build of Vue draws with MuPDF only.
find_package (X11), X11 and Widkit sources, MuPDF off.
CMake cannot build the
Plugins/Qt6
fork, Qtwk or Cocoa.
The Android launcher in
src/packages/android/launcher
is a separate CMake project which links a prebuilt libtexmacs.a with Qt 6 or 5 (find_package (QT NAMES Qt6 Qt5 …)). The library itself is configured with configure, where --enable-qt-new is the default for Android, so a library configured for Android uses
Plugins/Qt6
unless --disable-qt-new is given. The operating system side of Android is described in platform support.
Headless mode is not a separate port but a run-time mode, selected by -headless (and implied by the conversion and web site options, see the main program); is_headless () in
Texmacs/Texmacs/texmacs.cpp
tells whether it is on. Two ports make no windows at all in this mode:
A QTMCoreApplication replaces the QTMApplication, no window is shown, and the interpose handler skips the screen updates; see also the section on headless mode in the Qt implementation. Qtwk creates a QTWKCoreApplication in the same way, but its windows do not test is_headless.
gui_open opens no display at all, the windows are virtual windows without an SDL window, and the event loop is replaced by headless_loop (
vue_gui.cpp
), which runs the queued commands and the interpose handler every 10 ms until a command quits. This is what the documentation checks of this tree use (with SDL_VIDEO_DRIVER=dummy and TEXMACS_VUE_GPU=0 as a precaution).
SDL, X11 and Cocoa make their windows as usual, but never show them:
The constructor of sdl_gui_rep (
sdl_gui.cpp
) selects the dummy video driver, which opens no display, and sdl_window_rep::set_visibility (
sdl_window.cpp
) shows no window.
The windows are never mapped (x_window_rep::set_visibility in
x_window.cpp
), but a display is still needed: without one, x_gui_rep (
x_init.cpp
) fails with a message which suggests xvfb-run or a virtual DISPLAY.
The application gets no icon in the Dock and no menu bar (activation policy Prohibited in gui_open,
ns_gui.mm
), no window is ordered front (
ns_widget.mm
) and the wait window is not shown.