Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions 3rd/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -549,9 +549,36 @@ if(EUI_ENABLE_MARKDOWN)
endif()

if(UNIX AND NOT APPLE)
# eui_begin/end_quiet_third_party_config above replaces PKG_CONFIG_EXECUTABLE
# with a stub and then FORCE-restores the (usually empty) pre-stub value
# into the cache, which poisons find_program for the rest of the run.
# Platform tray detection below genuinely needs the real pkg-config, so
# drop the poisoned cache entry and let FindPkgConfig search again.
unset(PKG_CONFIG_EXECUTABLE CACHE)
find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
# SNI (StatusNotifierItem) backend: only glib/gio, present on every
# desktop Linux. Preferred over the GTK + libappindicator chain.
# gobject-2.0 is listed explicitly: gio-2.0.pc normally pulls it in
# via Requires, but naming it keeps the link line complete even with
# stripped-down or pkgconf-incompatible .pc files.
pkg_check_modules(EUI_GIO QUIET gio-2.0 gobject-2.0 glib-2.0)
# Legacy chain. libappindicator upstream is unmaintained and the
# Ayatana fork renamed the module, so this only fires on hosts that
# still ship the old build. Kept as a fallback; the SNI branch takes
# precedence in CMakeLists.txt.
pkg_check_modules(EUI_APPINDICATOR QUIET appindicator3-0.1)
pkg_check_modules(EUI_GTK3 QUIET gtk+-3.0)
endif()
# Fail loudly instead of silently compiling the empty tray stub: a Linux
# build with EUI_TRAY_HAS_BACKEND=0 looks successful but has no tray.
if(EUI_ENABLE_TRAY AND NOT EUI_GIO_FOUND
AND NOT (EUI_APPINDICATOR_FOUND AND EUI_GTK3_FOUND))
message(FATAL_ERROR
"Linux tray support requires glib/gio (gio-2.0, preferred, SNI backend) "
"or GTK3 + libappindicator (legacy fallback), detected via pkg-config, "
"but none of them were found. Install your distribution's glib2 development "
"package (e.g. glib2-devel / libglib2.0-dev), or configure with "
"-DEUI_ENABLE_TRAY=OFF to build without tray support.")
endif()
endif()
14 changes: 13 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ option(EUI_BUILD_SHARED "Build eui_neo as a shared library instead of a static l
option(EUI_ENABLE_INSTALL "Install EUI-NEO library, headers, and CMake package files." ${EUI_NEO_TOP_LEVEL_DEFAULT})
option(EUI_ENABLE_MODULES "Build optional EUI-NEO modules when their directories are present." ON)
option(EUI_VULKAN_LOW_LATENCY_PRESENT "Prefer low-latency Vulkan presentation when available." OFF)
option(EUI_ENABLE_TRAY "Enable the system tray backend. On Linux, configuration fails when neither glib/gio (SNI) nor GTK3 + libappindicator is available; turn this OFF to build without tray support." ON)

set(EUI_DEFAULT_WINDOW_BACKEND "glfw")
set(EUI_DEFAULT_RENDER_BACKEND "opengl")
Expand Down Expand Up @@ -336,7 +337,18 @@ if(WIN32)
elseif(APPLE)
target_compile_definitions(eui_neo PUBLIC EUI_TRAY_APPKIT=1)
target_link_libraries(eui_neo PUBLIC "-framework Cocoa" objc)
elseif(UNIX AND EUI_APPINDICATOR_FOUND AND EUI_GTK3_FOUND)
elseif(UNIX AND EUI_ENABLE_TRAY AND EUI_GIO_FOUND)
# StatusNotifierItem backend: speaks the freedesktop SNI + DBusMenu
# protocols over GDBus, needing only glib/gio (see tray_bridge.c). This is
# the default because glib is ubiquitous and libappindicator is dead.
target_compile_definitions(eui_neo PUBLIC EUI_TRAY_SNI=1)
target_include_directories(eui_neo PUBLIC ${EUI_GIO_INCLUDE_DIRS})
target_compile_options(eui_neo PRIVATE ${EUI_GIO_CFLAGS_OTHER})
target_link_directories(eui_neo PUBLIC ${EUI_GIO_LIBRARY_DIRS})
target_link_libraries(eui_neo PUBLIC ${EUI_GIO_LIBRARIES})
elseif(UNIX AND EUI_ENABLE_TRAY AND EUI_APPINDICATOR_FOUND AND EUI_GTK3_FOUND)
# Legacy fallback: GTK3 + libappindicator. Only reached when glib/gio is
# absent but the old stack is present.
target_compile_definitions(eui_neo PUBLIC EUI_TRAY_APPINDICATOR=1)
target_include_directories(eui_neo PUBLIC ${EUI_APPINDICATOR_INCLUDE_DIRS} ${EUI_GTK3_INCLUDE_DIRS})
target_compile_options(eui_neo PRIVATE ${EUI_APPINDICATOR_CFLAGS_OTHER} ${EUI_GTK3_CFLAGS_OTHER})
Expand Down
Loading