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) FetchContent_MakeAvailable(juce)
endif() endif()
# A JUCE GUI plugin needs the core system headers to compile on Linux. Detect # A JUCE GUI plugin needs the core system headers to compile on Linux, and
# them up front so a missing package produces a clear error instead of a # juce_gui_extra (pulled in transitively via juce_audio_processors) unconditionally
# confusing compile failure. GTK and libcurl are never required. # 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") if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(_mindball_headers "X11/Xlib.h" "freetype2/freetype/freetype.h" set(_mindball_headers "X11/Xlib.h" "freetype2/freetype/freetype.h"
"fontconfig/fontconfig.h" "alsa/asoundlib.h") "fontconfig/fontconfig.h" "alsa/asoundlib.h")
set(_mindball_packages "libx11-dev" "libfreetype-dev" set(_mindball_packages "libx11-dev" "libfreetype-dev"
"libfontconfig-dev" "libasound2-dev") "libfontconfig-dev" "libasound2-dev")
set(_mindball_missing "") set(_mindball_missing "")
foreach(_i RANGE 0 3) foreach(_i RANGE 0 3)
@ -43,11 +45,27 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
endif() endif()
endforeach() 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) if(_mindball_missing)
message(FATAL_ERROR 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" "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()
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 # 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 # 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 # 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 # disable it.
# linked.)
target_compile_definitions(Mindball PRIVATE JUCE_USE_CURL=0) 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 ----------------------------------------------------- # ---- git / build info -----------------------------------------------------
find_package(Git QUIET) find_package(Git QUIET)
set(MINDBALL_GIT_HASH "n/a") set(MINDBALL_GIT_HASH "n/a")

View file

@ -74,7 +74,8 @@ public:
}; };
buildInfo.setJustificationType (juce::Justification::centredRight); buildInfo.setJustificationType (juce::Justification::centredRight);
buildInfo.setFont (juce::Font (juce::Font::getDefaultMonospacedFontName(), 9.0f, 0)); buildInfo.setFont (juce::Font (juce::FontOptions (juce::Font::getDefaultMonospacedFontName(), 9.0f, 0)));
buildInfo.setColour (juce::Label::textColourId, MindballColors::textDim);
juce::String dirty = mindball::BuildInfo::gitDirty ? " +dirty" : ""; juce::String dirty = mindball::BuildInfo::gitDirty ? " +dirty" : "";
juce::String hash = juce::String (mindball::BuildInfo::gitHash); juce::String hash = juce::String (mindball::BuildInfo::gitHash);

View file

@ -117,9 +117,9 @@ void MindballAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer, juc
double bpm = lastBpm.load (std::memory_order_relaxed); double bpm = lastBpm.load (std::memory_order_relaxed);
if (auto* playHead = getPlayHead()) if (auto* playHead = getPlayHead())
{ {
juce::AudioPlayHead::CurrentPositionInfo pos; if (const auto pos = playHead->getPosition())
if (playHead->getCurrentPosition (pos) && pos.bpm > 0) if (const auto newBpm = pos->getBpm())
bpm = pos.bpm; bpm = *newBpm;
} }
lastBpm.store (bpm, std::memory_order_relaxed); lastBpm.store (bpm, std::memory_order_relaxed);