Bug 460656 - Unable to consume statically due to "KF5CoreAddons could not be found because dependency Inotify could not be found."
Summary: Unable to consume statically due to "KF5CoreAddons could not be found because...
Status: REPORTED
Alias: None
Product: extra-cmake-modules
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: ecm-bugs-null@kde.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-10-18 13:24 UTC by Dawid Wróbel
Modified: 2022-12-29 00:07 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dawid Wróbel 2022-10-18 13:24:26 UTC
SUMMARY
Any client that attempts to consume KF5CoreAddons statically will fail on Linux due to:
"KF5CoreAddons could not be found because dependency Inotify could not be  found."

See e.g. https://invent.kde.org/frameworks/kconfigwidgets/-/jobs/538225 for an example
Comment 1 Dawid Wróbel 2022-10-18 13:32:32 UTC
This one is odd. I tried debugging this previously and the problem appears to be with find-modules/FindInotify.cmake from ECM. 

Specifically, by looking into CMake trace, I saw that:
1) the first time find_path(Inotify_INCLUDE_DIRS sys/inotify.h) is executed, it finds the path just fine, and the if(Inotify_INCLUDE_DIRS) block executes as expected
2) the second time FindInotify.cmake is run (it escapes me why is it run consecutive time at all),  it appears that it uses a cached `Inotify_INCLUDE_DIRS` value, which somehow ends up empty, though, since the code in the if(Inotify_INCLUDE_DIRS) block is *not* executed.

I cannot pinpoint the exact reason behind this behavior. This is most likely the FindInotify.cmake's fault, which would make this extra-cmake-modules' bug, but I am leaving it here for the context.
Comment 2 Dawid Wróbel 2022-10-19 13:32:24 UTC
One workaround would be to replace if(@Inotify_FOUND@) with if(@Inotify_LIBRARIES@). Looking at the FindInotify, it only needs to link against anything if inotify library is located, as opposed to Inotify support built into the OS kernel.
Comment 3 Dawid Wróbel 2022-10-19 13:40:03 UTC
(Reassigning this to extra-cmake-modules, as kcoreaddons doesn't do anything out of ordinary in how it uses it, so it's unlikely its fault)
Comment 4 Dawid Wróbel 2022-10-19 15:12:33 UTC
OK, this is actually a duplicate of https://bugs.kde.org/show_bug.cgi?id=441604 — which I somehow thought it was fixed, but it wasn't, as the solution explained there fixed another issue. 

It was also discussed here: https://invent.kde.org/frameworks/kcoreaddons/-/merge_requests/129
Comment 5 Dawid Wróbel 2022-12-29 00:07:46 UTC
Git commit 8d839531cf99fb49789f583e541096f094718f12 by Dawid Wróbel.
Committed on 29/12/2022 at 00:02.
Pushed by wrobelda into branch 'master'.

Config.cmake.in: workaround Inotify static issue

M  +6    -1    KF5CoreAddonsConfig.cmake.in

https://invent.kde.org/frameworks/kcoreaddons/commit/8d839531cf99fb49789f583e541096f094718f12