Remove GTK dependency and fix build on Arch/Artix

- Remove pointless GTK dependency
- Improve error message when dependency missing (gtk.h)
- Fix build on Arch/Artix
This commit is contained in:
Armin 2026-08-29 10:09:28 +02:00
commit 7f6eee0186
3 changed files with 41 additions and 15 deletions

View file

@ -24,14 +24,16 @@ else()
FetchContent_MakeAvailable(juce)
endif()
# A JUCE GUI plugin needs the core system headers to compile on Linux. Detect
# them up front so a missing package produces a clear error instead of a
# confusing compile failure. GTK and libcurl are never required.
# A JUCE GUI plugin needs the core system headers to compile on Linux, and
# juce_gui_extra (pulled in transitively via juce_audio_processors) unconditionally
# includes <gtk/gtk.h>. Detect these up front so a missing package produces a
# clear error instead of a confusing "gtk/gtk.h: No such file or directory"
# compile failure. libcurl is not required.
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(_mindball_headers "X11/Xlib.h" "freetype2/freetype/freetype.h"
"fontconfig/fontconfig.h" "alsa/asoundlib.h")
set(_mindball_packages "libx11-dev" "libfreetype-dev"
"libfontconfig-dev" "libasound2-dev")
set(_mindball_headers "X11/Xlib.h" "freetype2/freetype/freetype.h"
"fontconfig/fontconfig.h" "alsa/asoundlib.h")
set(_mindball_packages "libx11-dev" "libfreetype-dev"
"libfontconfig-dev" "libasound2-dev")
set(_mindball_missing "")
foreach(_i RANGE 0 3)
@ -43,11 +45,27 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
endif()
endforeach()
# juce_gui_extra unconditionally includes <gtk/gtk.h> on Linux.
find_package(PkgConfig QUIET)
if(NOT PkgConfig_FOUND)
string(APPEND _mindball_missing " pkg-config (package: pkg-config)\n")
else()
pkg_check_modules(_mindball_gtk gtk+-3.0 QUIET)
if(NOT _mindball_gtk_FOUND)
string(APPEND _mindball_missing " gtk/gtk.h (package: libgtk-3-dev)\n")
endif()
endif()
if(_mindball_missing)
message(FATAL_ERROR
"Missing required system headers for the Linux build:\n${_mindball_missing}"
"Missing required system packages for the Linux build:\n${_mindball_missing}"
"Install them with:\n"
" sudo apt-get install pkg-config libx11-dev libfreetype-dev libfontconfig-dev libasound2-dev\n")
" # Debian/Ubuntu:\n"
" sudo apt-get install pkg-config libx11-dev libfreetype-dev libfontconfig-dev libasound2-dev libgtk-3-dev\n"
" # Arch Linux:\n"
" sudo pacman -S pkgconf libx11 freetype2 fontconfig alsa-lib gtk3\n"
" # Fedora:\n"
" sudo dnf install pkgconf-pkg-config libX11-devel freetype-devel fontconfig-devel alsa-lib-devel gtk3-devel\n")
endif()
endif()
@ -85,10 +103,17 @@ target_compile_definitions(Mindball PRIVATE JUCE_VST3_CAN_REPLACE_VST2=0)
# juce_core enables libcurl by default on Linux; without NEEDS_CURL the JUCE
# helper targets don't link -lcurl, so that would fail at link time with
# undefined references to curl_easy_setopt. We use no network features, so
# disable it. (GTK/webkit2gtk is never required because juce_gui_extra is not
# linked.)
# disable it.
target_compile_definitions(Mindball PRIVATE JUCE_USE_CURL=0)
# juce_gui_extra unconditionally #includes <gtk/gtk.h> (and webkit) on Linux
# only when JUCE_WEB_BROWSER is enabled. JUCE only adds the GTK include path
# via JUCE_BROWSER_LINUX_DEPS when NEEDS_WEB_BROWSER is set, which in turn
# requires the webkit2gtk dev package. We don't use a web browser, so disable
# JUCE_WEB_BROWSER entirely - this drops the GTK/webkit includes and avoids
# needing webkit2gtk installed just to compile the plugin.
target_compile_definitions(Mindball PRIVATE JUCE_WEB_BROWSER=0)
# ---- git / build info -----------------------------------------------------
find_package(Git QUIET)
set(MINDBALL_GIT_HASH "n/a")