Skip to content

cmake/amule: drop the glib dep on macOS, even under wxGTK - #647

Merged
mrjimenez merged 1 commit into
amule-project:masterfrom
got3nks:fix/cmake-glib-check-wxgtk-gate
May 17, 2026
Merged

cmake/amule: drop the glib dep on macOS, even under wxGTK#647
mrjimenez merged 1 commit into
amule-project:masterfrom
got3nks:fix/cmake-glib-check-wxgtk-gate

Conversation

@got3nks

@got3nks got3nks commented May 17, 2026

Copy link
Copy Markdown
Contributor

Closes #641.

amule.cpp and amule-remote-gui.cpp include <glib.h> and call g_set_prgname() under #ifdef __WXGTK__ to bind the Wayland wl_app_id / X11 WM_CLASS to the .desktop filename. The cmake gate that runs pkg_check_modules(GLIB ... glib-2.0) and propagates GLIB_INCLUDE_DIRS to the affected targets was wrapped in if (CMAKE_SYSTEM_NAME STREQUAL "Linux"), which is too narrow: wxGTK builds aren't a Linux-only configuration. MacPorts ships wxWidgets as a wxGTK port (/opt/local/Library/Frameworks/wxWidgets.framework/Versions/wxGTK/...), so on that setup __WXGTK__ is defined but the cmake gate stayed false, the include path was never added, and the build died with glib.h: No such file or directory mid-compile.

@barracuda156's MacPorts ppc / 10.6 build is the trigger.

Fix

g_set_prgname is a no-op on macOS even when wxGTK happens to be the toolkit — there's no Wayland, no .desktop binding, and macOS apps identify via Info.plist in the .app bundle. The C-side gate is tightened to #if defined(__WXGTK__) && !defined(__APPLE__) in both amule.cpp and amule-remote-gui.cpp so macOS wxGTK builds skip the include and the call entirely. The cmake gate matches: glib is required only when __WXGTK__ is in wxWidgets_DEFINITIONS AND the host isn't Apple. Wherever there was reason to ask for glib2 on a macOS build, the answer is now "you don't need it."

Effect by configuration:

  • macOS Homebrew (wxMac): skipped at cmake (gate false) and at compile (__WXGTK__ not defined). No glib needed. Unchanged behavior.
  • macOS MacPorts (wxGTK): skipped at cmake (NOT APPLE short-circuits) and at compile (!defined(__APPLE__) short-circuits). No glib needed. This is the fix.
  • Linux wxGTK: gate stays true, glib required, FATAL_ERROR on missing dep with the install hint. Unchanged behavior.
  • Windows MinGW (wxMSW): __WXGTK__ not in DEFINITIONS, gate false. No glib needed. Unchanged behavior.

…ect#641)

amule.cpp and amule-remote-gui.cpp include <glib.h> and call
g_set_prgname() under #ifdef __WXGTK__ to bind the Wayland wl_app_id /
X11 WM_CLASS to the .desktop filename. The cmake gate that runs
pkg_check_modules(GLIB ... glib-2.0) and propagates GLIB_INCLUDE_DIRS
to the affected targets was wrapped in
"if (CMAKE_SYSTEM_NAME STREQUAL Linux)" -- which is too narrow.
wxGTK builds aren't a Linux-only configuration. MacPorts ships
wxWidgets as a wxGTK port, so on that setup __WXGTK__ was defined but
the cmake gate stayed false, the include path was never added, and the
build died with "glib.h: No such file or directory" mid-compile.

g_set_prgname is a no-op on macOS even when wxGTK is the toolkit:
no Wayland, no .desktop binding, app identity comes from Info.plist
in the .app bundle. So tighten the C-side gate to
"#if defined(__WXGTK__) && !defined(__APPLE__)" in both files;
macOS wxGTK builds skip the include and the call entirely.

Match the cmake gate the same way: glib is required only when
__WXGTK__ is in wxWidgets_DEFINITIONS AND the host isn't Apple.

Configurations:
- macOS Homebrew (wxMac): no glib needed (unchanged).
- macOS MacPorts (wxGTK): no glib needed (was the bug).
- Linux wxGTK: glib required, unchanged FATAL_ERROR with install hint.
- Windows MinGW (wxMSW): no glib needed (unchanged).
@mrjimenez
mrjimenez merged commit ec4046b into amule-project:master May 17, 2026
12 checks passed
@got3nks
got3nks deleted the fix/cmake-glib-check-wxgtk-gate branch May 22, 2026 13:50
ngosang pushed a commit to ngosang/amule that referenced this pull request Jul 27, 2026
…ject#647)

Fixes amule-project#631. Opening a collection from a file manager has never worked on any platform: nothing declared the type to the OS, nothing handled the open-document event on macOS, and the command-line path rejected anything that was not an eD2k or magnet link.

Accepts a .emulecollection path or file:// URL as an argument, handles MacOpenFiles on macOS, and declares the type to each OS. Registration is exposed on the same four surfaces as the URL schemes so a portable copy can register itself; UriScheme becomes HandlerTarget so the existing policy layer and the Linux mimeapps.list handling are reused rather than duplicated.

Hardens CMuleCollection, which becomes reachable from arbitrary files: a blank line threw std::out_of_range out of Open(), a length prefix could request a 4 GiB allocation, a filename containing a newline forged extra lines in the ED2KLinks IPC file, an entry without a hash produced an unusable link, a link smuggled into a filename was harvested by the text parser after the binary parser rejected it, and a UTF-8 BOM made a collection parse as empty. Adds unit tests, which the parser had none of.

Also fixes pre-existing bugs this feature was the first to depend on: wxExecute's string form passed quote characters through to the XDG cache helpers, those helpers inherited the AppImage's LD_LIBRARY_PATH and died on a bundled glib symbol, mimeapps.list was written without a trailing newline so the next writer's entry fused onto ours, and four installer strings were never extractable by xgettext.
mrjimenez added a commit to mrjimenez/amule that referenced this pull request Jul 29, 2026
conftest.mmap and conftest.txt were accidentally committed in
9aa8fe4 (amule-project#647). They are disposable output of the mmap capability
check (random page-sized garbage), not project data, and are no
longer written to the source tree now that the probe runs inside
build/.
mrjimenez added a commit to mrjimenez/amule that referenced this pull request Jul 30, 2026
conftest.mmap and conftest.txt were accidentally committed in
9aa8fe4 (amule-project#647). They are disposable output of the mmap capability
check (random page-sized garbage), not project data, and are no
longer written to the source tree now that the probe runs inside
build/.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

glib2 is not imported on macOS: amule.cpp: fatal error: glib.h: No such file or directory

2 participants