watcher icon indicating copy to clipboard operation
watcher copied to clipboard

[feature-request] Add missing CMake config or pkg-config file

Open apteryks opened this issue 5 months ago • 16 comments

This would make it more convenient to find the library/headers using common means, and also make it possible to query whether a minimal version is satisfied.

apteryks avatar Jul 24 '25 01:07 apteryks

How about two pc files: one for the c++ header library, the other for the C static and shared libraries and their header?

e-dant avatar Jul 30 '25 12:07 e-dant

It sounds like a good idea! Maybe watcher-c.pc for the C static/shared library? Or is it better practice to keep these separated these days, like watcher-c-private.pc and watcher-c.pc ?

apteryks avatar Jul 30 '25 12:07 apteryks

Think https://github.com/e-dant/watcher/commit/bd02b11ae7a15e4bb10c3e3e8cea5011310dbaf4 solves this. How does it look?

e-dant avatar Aug 09 '25 18:08 e-dant

Maybe watcher-c.pc for the C static/shared library?

That sounded good to me, went with that.

e-dant avatar Aug 09 '25 18:08 e-dant

Will try it now for my use case (unbundling watcher in dolphin-emu).

apteryks avatar Aug 14 '25 06:08 apteryks

I tried the latest commit of the next branch, but the test suite appears to fail there, with errors like:

Access events are not reported ... sed: read error on /tmp/guix-build-watcher-0.13.6-0.5638162.drv-0/tst-uYB7BS: Is a directory
oops :(

I'll try just applying the pkg-config patches.

apteryks avatar Aug 14 '25 06:08 apteryks

Managed to build with test suite passing on commit 0aff9ee.

apteryks avatar Aug 14 '25 06:08 apteryks

Works well, thank you!

apteryks avatar Aug 14 '25 07:08 apteryks

Ah, I think there's a small issue, where prefix= is not set to a value, so the include dir is relative, which trips CMake for example:

CMake Error in Source/Core/Common/CMakeLists.txt:
  Target "_alias_PkgConfigWATCHER" contains relative path in its
  INTERFACE_INCLUDE_DIRECTORIES:

    "include/wtr"

apteryks avatar Aug 14 '25 08:08 apteryks

At least when building watcher with CMake.

apteryks avatar Aug 14 '25 08:08 apteryks

I think the .pc files are often expressed as something like:

prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${exec_prefix}/lib

apteryks avatar Aug 14 '25 08:08 apteryks

Got it, will fix that up, thank you!

e-dant avatar Aug 14 '25 12:08 e-dant

fixed in 0.13.7

e-dant avatar Sep 01 '25 23:09 e-dant

@e-dant hi! I just tried 0.13.8 to build dolphin-emu, and got:

CMake Error in Source/Core/Common/CMakeLists.txt:
  Target "_alias_PkgConfigWATCHER" contains relative path in its
  INTERFACE_INCLUDE_DIRECTORIES:

    "include/wtr"

Indeed, there are relative paths in the watcher.pc file still:

$ cat /gnu/store/1hs79cagf7kbli886gjdmwb64kv9aq54-watcher-0.13.8/lib/pkgconfig/watcher.pc
prefix=
exec_prefix=${prefix}
libdir=lib
includedir=include/wtr

Name: watcher
Description: watcher: a filesystem watcher
URL: github.com/e-dant/watcher
Version: 0.13.8
Requires:
Conflicts:
Libs:
Libs.private: ;Threads::Threads
Cflags: -I${includedir}

So I've brough back my Guix-package phase to fix it up in Guix:

(add-after 'unpack 'fix-.pc-files-prefix
            ;; There are some issues with the new .pc files (see:
            ;; <https://github.com/e-dant/watcher/issues/82>).
            (lambda _
              (substitute* "CMakeLists.txt"
                (("\"\\$\\{CMAKE_INSTALL_LIBDIR}\"")
                 "\"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}\"")
                (("\\$\\{CMAKE_INSTALL_INCLUDEDIR}/wtr")
                 "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/wtr"))
              (substitute* "watcher.pc.in"
                (("@PC_WATCHER_PREFIX@")
                 #$output))
              (substitute* "watcher-c/watcher-c.pc.in"
                (("@PC_LIBWATCHER_C_PREFIX@")
                 #$output))))

And I can now build dolphin-emu again. Could you please reopen this issue? Thanks!

apteryks avatar Sep 03 '25 13:09 apteryks

Oof, my bad! I'll fix this up, thank you

e-dant avatar Sep 03 '25 13:09 e-dant

No worries :-) Thanks for your reactivity!

apteryks avatar Sep 04 '25 05:09 apteryks