externals: allow using watcher header library from the system
- CMake/DolphinLibraryTools.cmake (dolphin_find_optional_system_library_include): New function.
- CMakeLists.txt: Use it to locate the watcher header-only library.
May you point me to a distribution that ships watcher so I can test using it as a system library?
May you point me to a distribution that ships
watcherso 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.
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.
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.
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.
Hm, I spoke too soon:
ld: cannot find -lwatcher: No such file or directory collect2: error: ld returned 1 exit statusIt's header only library. I'm not sure why
dolphin_find_optional_system_library_pkgconfigneeds 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.
@dolphin-emu-bot rebuild
@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).