From c057c0d55ef8344e953b526945cecec1aace4eac Mon Sep 17 00:00:00 2001 From: attila Date: Mon, 24 Jun 2024 15:12:36 +0200 Subject: [PATCH] CMake: Fix package resolution on Linux This change ensures that instructions are straightforward on Ubuntu 24.04 and 22.04. --- docs/Linux Dependencies.md | 8 ++++++-- extras/Build/CMake/JUCEUtils.cmake | 14 +++++++++++++- modules/juce_gui_extra/juce_gui_extra.cpp | 2 +- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/docs/Linux Dependencies.md b/docs/Linux Dependencies.md index 8b22e39667..f3f5c02bbf 100644 --- a/docs/Linux Dependencies.md +++ b/docs/Linux Dependencies.md @@ -32,7 +32,11 @@ or - libcurl4-openssl-dev (unless `JUCE_USE_CURL=0`) #### juce_graphics -- libfreetype6-dev (unless `JUCE_USE_FREETYPE=0`) +- libfontconfig1-dev (unless `JUCE_USE_FONTCONFIG=0`) +- libfreetype-dev (unless `JUCE_USE_FREETYPE=0`) + +These packages are available on Ubuntu 22 and 24. If libfreetype-dev is not +available you could try installing the libfreetype6-dev package. #### juce_gui_basics - libx11-dev @@ -63,7 +67,7 @@ The full command is as follows: sudo apt install libasound2-dev libjack-jackd2-dev \ ladspa-sdk \ libcurl4-openssl-dev \ - libfreetype6-dev \ + libfreetype-dev libfontconfig1-dev \ libx11-dev libxcomposite-dev libxcursor-dev libxcursor-dev libxext-dev libxinerama-dev libxrandr-dev libxrender-dev \ libwebkit2gtk-4.1-dev \ libglu1-mesa-dev mesa-common-dev diff --git a/extras/Build/CMake/JUCEUtils.cmake b/extras/Build/CMake/JUCEUtils.cmake index 6a941bdacf..b5390c3dcb 100644 --- a/extras/Build/CMake/JUCEUtils.cmake +++ b/extras/Build/CMake/JUCEUtils.cmake @@ -93,9 +93,21 @@ define_property(TARGET PROPERTY JUCE_COPY_PLUGIN_AFTER_BUILD INHERITED FULL_DOCS "Whether or not plugins should be copied after building") set_property(GLOBAL PROPERTY JUCE_COPY_PLUGIN_AFTER_BUILD FALSE) +function(_juce_available_pkgconfig_module_or_else out package alternative_package) + find_package(PkgConfig REQUIRED) + pkg_check_modules(package_to_be_found ${package} QUIET) + + if(package_to_be_found_FOUND) + set(${out} ${package} PARENT_SCOPE) + else() + set(${out} ${alternative_package} PARENT_SCOPE) + endif() +endfunction() + if((CMAKE_SYSTEM_NAME STREQUAL "Linux") OR (CMAKE_SYSTEM_NAME MATCHES ".*BSD")) _juce_create_pkgconfig_target(JUCE_CURL_LINUX_DEPS libcurl) - _juce_create_pkgconfig_target(JUCE_BROWSER_LINUX_DEPS webkit2gtk-4.0 gtk+-x11-3.0) + _juce_available_pkgconfig_module_or_else(webkit_package_name webkit2gtk-4.1 webkit2gtk-4.0) + _juce_create_pkgconfig_target(JUCE_BROWSER_LINUX_DEPS ${webkit_package_name} gtk+-x11-3.0) endif() # We set up default/fallback copy dirs here. If you need different copy dirs, use diff --git a/modules/juce_gui_extra/juce_gui_extra.cpp b/modules/juce_gui_extra/juce_gui_extra.cpp index fee9682cc6..5e8ca3bd2f 100644 --- a/modules/juce_gui_extra/juce_gui_extra.cpp +++ b/modules/juce_gui_extra/juce_gui_extra.cpp @@ -123,7 +123,7 @@ #elif (JUCE_LINUX || JUCE_BSD) && JUCE_WEB_BROWSER JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wzero-as-null-pointer-constant", "-Wparentheses", "-Wdeprecated-declarations") - // If you're missing this header, you need to install the webkit2gtk-4.0 package + // If you're missing this header, you need to install the webkit2gtk-4.1 or webkit2gtk-4.0 package #include #include #include