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>