diff --git a/CMakeLists.txt b/CMakeLists.txt index 489ea3e..134e5f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 . 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 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 (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") diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 9a3bab6..e6336b3 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -74,7 +74,8 @@ public: }; 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 hash = juce::String (mindball::BuildInfo::gitHash); diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index f22564b..0b60362 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -117,9 +117,9 @@ void MindballAudioProcessor::processBlock (juce::AudioBuffer& buffer, juc double bpm = lastBpm.load (std::memory_order_relaxed); if (auto* playHead = getPlayHead()) { - juce::AudioPlayHead::CurrentPositionInfo pos; - if (playHead->getCurrentPosition (pos) && pos.bpm > 0) - bpm = pos.bpm; + if (const auto pos = playHead->getPosition()) + if (const auto newBpm = pos->getBpm()) + bpm = *newBpm; } lastBpm.store (bpm, std::memory_order_relaxed);