Make JUCE_USE_CURL=0 apply to every target, not just GelykEQ

The switch was set with target_compile_definitions(GelykEQ PRIVATE ...), so it
only reached GelykEQ. GelykEQStandalone compiles its own copy of the JUCE
modules and would have been built with juce_core's Linux default
JUCE_USE_CURL=1, needing libcurl headers.

Hoist JUCE_USE_CURL=0 and JUCE_WEB_BROWSER=0 into a directory-wide
add_compile_definitions() above the JUCE subdirectory, and feed the probed
X11 JUCE_USE_* flags through the same mechanism so they are equally global.
This commit is contained in:
Armin 2026-10-03 20:25:57 +02:00
commit 4c47b17fe9

View file

@ -5,6 +5,82 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
project(GelykEQ VERSION 1.0.0 LANGUAGES C CXX)
# --- Feature switches ----------------------------------------------------
# Gelyk never uses the embedded web browser and does no networking, so JUCE's
# optional dependency groups stay off:
#
# JUCE_USE_CURL=0 juce_core's Linux default is 1, which makes it
# #include <curl/curl.h> and compile
# juce_Network_curl.cpp. Nothing links libcurl (see
# NEEDS_CURL below), but its *development headers* would
# still be a hard build requirement. Gelyk never touches
# URL/WebInputStream, so nothing is lost.
# JUCE_WEB_BROWSER=0 juce_gui_extra's WebBrowserComponent is the only thing
# that #includes <gtk/gtk.h>, <webkit2/webkit2.h>,
# <jsc/jsc.h> and <libsoup/soup.h>.
#
# Native file dialogs are not a GTK dependency either: JUCE 8's Linux FileChooser
# shells out to zenity/kdialog via ChildProcess, and Gelyk never opens one.
#
# These are set directory-wide rather than per-target, so that every target
# this project defines inherits them - including the optional GelykEQStandalone
# app, which compiles its own copy of the JUCE modules. As
# target_compile_definitions(GelykEQ ...) they would only reach GelykEQ itself.
# (JUCE's own helper tools are separate nested CMake projects and set what they
# need themselves.)
add_compile_definitions(
JUCE_WEB_BROWSER=0
JUCE_USE_CURL=0
)
# --- Linux / BSD only ---------------------------------------------------
# What JUCE does still need on Linux is its own baseline: X11 windowing, ALSA
# and FreeType/fontconfig for juce_graphics text. Those arrive as several
# separate -dev packages on Arch/Artix, so check them up front with a useful
# hint instead of JUCE's raw pkg-config error.
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()
add_compile_definitions(${gelyk_x11_defines})
endif()
if(NOT DEFINED JUCE_ROOT)
include(FetchContent)
set(FETCHCONTENT_QUIET OFF)
@ -108,73 +184,6 @@ target_link_libraries(GelykEQ PRIVATE juce::juce_dsp)
target_compile_definitions(GelykEQ PRIVATE JUCE_MODULE_AVAILABLE_juce_dsp=1)
# Gelyk never uses the embedded web browser, so keep JUCE_WEB_BROWSER off.
# 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.
#
# 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>
)