dolphin icon indicating copy to clipboard operation
dolphin copied to clipboard

externals: allow using watcher header library from the system

Open apteryks opened this issue 7 months ago • 8 comments

  • CMake/DolphinLibraryTools.cmake (dolphin_find_optional_system_library_include): New function.
  • CMakeLists.txt: Use it to locate the watcher header-only library.

apteryks avatar Jul 24 '25 02:07 apteryks

May you point me to a distribution that ships watcher so I can test using it as a system library?

JoshuaVandaele avatar Jul 27 '25 16:07 JoshuaVandaele

May you point me to a distribution that ships watcher so I can test using it as a system library?

It's available in Guix (too recent to be listed yet on repology), Nix, Homebrew and Conan, it seems: https://repology.org/project/wtr-watcher/versions. It's also easy to build and install from source, so that could be a simpler/faster way to get a system-available watcher library to test with.

apteryks avatar Jul 28 '25 00:07 apteryks

After testing building using a system-wide install, a lot of new repeating warnings appear:

[16/1185] Building CXX object Source/Core/Common/CMakeFiles/common.dir/Assembler/AssemblerShared.cpp.o
cc1plus: warning: /usr/local/include/wtr/watcher.hpp: not a directory
[18/1185] Building CXX object Source/Core/Common/CMakeFiles/common.dir/Analytics.cpp.o
cc1plus: warning: /usr/local/include/wtr/watcher.hpp: not a directory
[19/1185] Building CXX object Source/Core/Common/CMakeFiles/common.dir/Assembler/GekkoAssembler.cpp.o
cc1plus: warning: /usr/local/include/wtr/watcher.hpp: not a directory
[...]

This particular system install was generated using the following commands:

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
cmake --install build

/usr/local/include/wtr/watcher.hpp otherwise exists as a file.

JoshuaVandaele avatar Jul 28 '25 05:07 JoshuaVandaele

Since the upstream of watcher have now included new pkg-config files in their upcoming 0.13.7 release (see: https://github.com/e-dant/watcher/commit/bd02b11ae7a15e4bb10c3e3e8cea5011310dbaf4), I've simplified this PR to a single (existing) macro call. I believe there shouldn't be any warnings, let me know if there are.

apteryks avatar Aug 14 '25 07:08 apteryks

Hm, I spoke too soon:

ld: cannot find -lwatcher: No such file or directory
collect2: error: ld returned 1 exit status

It's header only library. I'm not sure why dolphin_find_optional_system_library_pkgconfig needs to add a -l itself, that'd be provided by the CFLAGS of pkg-config if needed.

apteryks avatar Aug 14 '25 07:08 apteryks

Hm, I spoke too soon:

ld: cannot find -lwatcher: No such file or directory
collect2: error: ld returned 1 exit status

It's header only library. I'm not sure why dolphin_find_optional_system_library_pkgconfig needs to add a -l itself, that'd be provided by the CFLAGS of pkg-config if needed.

Fixed. It was not the above macro's doing. I had to use watcher::watcher when referencing it.

apteryks avatar Aug 14 '25 11:08 apteryks

@dolphin-emu-bot rebuild

JoshuaVandaele avatar Aug 14 '25 11:08 JoshuaVandaele

@JoshuaVandaele thanks for the re-run. It looks like the alias created by dolphin_find_optional_system_library_pkgconfig is only created if when the system library is found. I've thus adjusted the alias name to be watcher, and that seems to be OK in both scenarios (system lib or bundled).

apteryks avatar Aug 14 '25 13:08 apteryks