Keep the Linux build free of curl, WebKitGTK and extra X11 packages

JUCE_USE_CURL defaults to 1 on Linux, so juce_core compiled
juce_Network_curl.cpp and included <curl/curl.h>. Nothing linked libcurl
(NEEDS_CURL was off), but its development headers were still a hard build
requirement. Set JUCE_USE_CURL=0 and pin NEEDS_CURL/NEEDS_WEB_BROWSER to
FALSE alongside the existing JUCE_WEB_BROWSER=0.

X11's Xrandr/Xinerama/Xshm/Xcursor headers are only dlsym()ed at runtime, but
live in separate -dev packages on Arch/Artix. Probe each with
check_include_file_cxx and define the JUCE_USE_* flags accordingly, so a
distro carrying just libX11 still builds.

Also check alsa/freetype2/fontconfig up front with a distro-specific hint
instead of letting JUCE's raw pkg-config error surface, and expand the
README's Linux section to cover all of it.
This commit is contained in:
Armin 2026-10-03 19:35:29 +02:00
commit 48f9f7c190
2 changed files with 107 additions and 12 deletions

View file

@ -38,6 +38,12 @@ juce_add_plugin(GelykEQ
BUNDLE_ID com.gelyk.eq
JucePlugin_Name "Gelyk EQ"
JucePlugin_Desc "A minimalist cyber/neon multiband equalizer"
# Never link libcurl or WebKitGTK. Gelyk does no networking and has no
# embedded browser, so both optional Linux dependency groups stay off.
# (juce_add_plugin leaves these unset = off, this is just explicit.)
NEEDS_CURL FALSE
NEEDS_WEB_BROWSER FALSE
)
juce_generate_juce_header(GelykEQ)
@ -106,7 +112,68 @@ target_compile_definitions(GelykEQ PRIVATE JUCE_MODULE_AVAILABLE_juce_dsp=1)
# Otherwise juce_gui_extra's WebBrowserComponent pulls in WebKitGTK + GTK dev
# headers (webkit2gtk, gtk, jsc, libsoup), which would break headless builds
# like Arch/Artix where those aren't installed.
target_compile_definitions(GelykEQ PRIVATE JUCE_WEB_BROWSER=0)
#
# JUCE_USE_CURL is the matching kill switch for juce_core: with it left at its
# Linux default of 1, juce_core #includes <curl/curl.h> and compiles
# juce_Network_curl.cpp, so libcurl *development headers* become a hard build
# requirement even though nothing links libcurl (NEEDS_CURL is FALSE above).
# Gelyk never uses URL/WebInputStream, so switching it off costs nothing.
#
# Native file dialogs are not a problem either: JUCE 8's Linux FileChooser
# shells out to zenity/kdialog via ChildProcess instead of linking GTK, and
# Gelyk never opens one.
target_compile_definitions(GelykEQ PRIVATE
JUCE_WEB_BROWSER=0
JUCE_USE_CURL=0
)
# --- Linux / BSD only ---------------------------------------------------
# The remaining Linux requirements are genuinely needed (X11 windowing, ALSA
# and FreeType/fontconfig for juce_graphics text), but they arrive as several
# separate -dev packages on Arch/Artix. Fail early with a useful hint instead
# of JUCE's raw pkg-config error. Nothing below pulls in GTK/WebKitGTK/curl.
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME MATCHES ".*BSD")
find_package(PkgConfig REQUIRED)
foreach(gelyk_dep alsa freetype2 fontconfig)
pkg_check_modules(GELYK_HAS_${gelyk_dep} QUIET ${gelyk_dep})
if(NOT GELYK_HAS_${gelyk_dep}_FOUND)
message(FATAL_ERROR
"Missing required Linux development package: '${gelyk_dep}'.\n"
" Arch/Artix: alsa-lib freetype2 fontconfig libx11\n"
" Debian/Ubuntu: libasound2-dev libfreetype6-dev libfontconfig1-dev libx11-dev\n"
" These are JUCE's own requirements (X11 windowing, ALSA, font rendering),\n"
" not Gelyk's. No GTK, WebKitGTK, libcurl or file-selector package is needed.")
endif()
endforeach()
# X11's multi-monitor/DPI extensions are dlsym()ed at runtime by JUCE, so
# their headers are optional. Probe instead of hard-failing on distros that
# ship just libX11 + libXext (libXrandr/Xinerama/Xcursor are separate
# packages there). Only libX11's own headers are truly required.
include(CheckIncludeFileCXX)
set(gelyk_x11_optional
"JUCE_USE_XRANDR|X11/extensions/Xrandr.h"
"JUCE_USE_XINERAMA|X11/extensions/Xinerama.h"
"JUCE_USE_XSHM|X11/extensions/XShm.h"
"JUCE_USE_XCURSOR|X11/Xcursor/Xcursor.h"
)
set(gelyk_x11_defines)
foreach(gelyk_opt IN LISTS gelyk_x11_optional)
string(REPLACE "|" ";" gelyk_parts "${gelyk_opt}")
list(GET gelyk_parts 0 gelyk_define)
list(GET gelyk_parts 1 gelyk_header)
check_include_file_cxx("${gelyk_header}" GELYK_HAVE_${gelyk_define})
# A failed check leaves the variable empty rather than 0, which would
# end up as -DJUCE_USE_XCURSOR="" and break the preprocessor.
if(NOT GELYK_HAVE_${gelyk_define})
set(GELYK_HAVE_${gelyk_define} 0)
endif()
list(APPEND gelyk_x11_defines ${gelyk_define}=${GELYK_HAVE_${gelyk_define}})
endforeach()
target_compile_definitions(GelykEQ PRIVATE ${gelyk_x11_defines})
endif()
target_compile_options(GelykEQ PRIVATE
$<$<CXX_COMPILER_ID:AppleClang,Clang>:-Wall -Wextra>

View file

@ -138,22 +138,50 @@ make # configure + build
make install # copy into ~/Library/Audio/Plug-Ins and codesign
```
### Linux / Artix note (no GTK or WebKitGTK headers required)
### Linux / Artix note (no GTK, WebKitGTK, curl or GTK file selector needed)
The plugin **does not depend on GTK or WebKitGTK developer headers**, so it
builds cleanly on minimal/headless-flavored distros such as **Artix** - no
`webkit2gtk`, `gtk3`-devel, `libsoup` or `jsc` packages needed.
This is guaranteed in `CMakeLists.txt`:
Gelyk builds on minimal/headless-flavored distros such as **Artix** without any
of the usual JUCE baggage: no `webkit2gtk`, `gtk3`, `libsoup`, `jsc`, `libcurl`
or file-selector development packages. This is pinned in `CMakeLists.txt`:
```cmake
target_compile_definitions(GelykEQ PRIVATE JUCE_WEB_BROWSER=0)
NEEDS_CURL FALSE # juce_add_plugin: never link libcurl
NEEDS_WEB_BROWSER FALSE # juce_add_plugin: never link WebKitGTK
target_compile_definitions(GelykEQ PRIVATE
JUCE_WEB_BROWSER=0
JUCE_USE_CURL=0
)
```
JUCE's Linux `FileChooser` in JUCE 8 no longer links GTK either - it shells out
to `zenity`/`kdialog` at runtime, and Gelyk never opens a native file dialog.
Disabling `JUCE_WEB_BROWSER` removes the WebKitGTK-backed `WebBrowserComponent`
(which Gelyk does not use), eliminating the entire GTK/WebKit include chain.
- **`JUCE_WEB_BROWSER=0`** removes `WebBrowserComponent` from the compile, which
is the only thing in `juce_gui_extra` that `#include`s `<gtk/gtk.h>`,
`<webkit2/webkit2.h>`, `<jsc/jsc.h>` and `<libsoup/soup.h>`.
- **`JUCE_USE_CURL=0`** matters just as much. JUCE's Linux default is `1`, which
makes `juce_core` `#include <curl/curl.h>` and compile `juce_Network_curl.cpp`.
Nothing would *link* libcurl (`NEEDS_CURL` is `FALSE`), but its **headers**
would still be a hard requirement. Gelyk never touches `URL`/`WebInputStream`,
so nothing is lost.
- **File dialogs are not a GTK dependency.** JUCE 8's Linux `FileChooser` shells
out to `zenity`/`kdialog` at runtime, and Gelyk never opens a native file
dialog anyway.
- X11's multi-monitor/DPI extensions (`Xrandr`, `Xinerama`, `Xshm`, `Xcursor`)
are `dlsym()`ed at runtime by JUCE, so their headers are treated as optional:
`CMakeLists.txt` probes for each and sets `JUCE_USE_XRANDR` / `JUCE_USE_XINERAMA`
/ `JUCE_USE_XSHM` / `JUCE_USE_XCURSOR` accordingly. A distro carrying just
`libX11` still builds, minus multi-monitor reporting.
What *is* still required is JUCE's own Linux baseline, checked at configure time
with a helpful error instead of a raw pkg-config failure:
| pkg-config | Arch / Artix | Debian / Ubuntu |
|------------|-------------------------|--------------------------------|
| `alsa` | `alsa-lib` | `libasound2-dev` |
| `freetype2`| `freetype2` | `libfreetype6-dev` |
| `fontconfig` | `fontconfig` | `libfontconfig1-dev` |
| X11 headers| `libx11` (`libxext` for `Xshm`) | `libx11-dev` (`libxext-dev`) |
None of them drag in GTK.
> If you ever do need native file dialogs at runtime (outside Gelyk), install
> `zenity` or `kdialog`.