Bug 424483

Summary: Build errors if PREFIX is different from ECM's PREFIX
Product: [Frameworks and Libraries] libplasma Reporter: h.goebel
Component: libplasmaAssignee: Marco Martin <notmart>
Status: RESOLVED FIXED    
Severity: normal CC: alexander.lohnau, nate, plasma-bugs-null
Priority: NOR    
Version First Reported In: 5.70.0   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description h.goebel 2020-07-20 19:23:31 UTC
When plasma-framework and extra-cmake-modules reside in different prefixes, building packages depending on PlasmaQuick fails with

  File or directory
  /gnu/store/…-extra-cmake-modules-5.70.0/include/KF5
  referenced by variable PlasmaQuick_INCLUDE_DIR does not exist !

"/gnu/store/…-extra-cmake-modules-5.70.0" is the of PREFIX of ECM - and obviously PlasmaQuick_INCLUDE_DIR should not point there but to the PREFIX of plasma-framework.



STEPS TO REPRODUCE
====================

1. Ensure you have guile 3.x and guile-gcrypt installed.

   If these are not availalbe for you distribution, a quick way to get them is
   by installing guix:
   a. Install guix alongside your distribution (this can be remove easily later)
      <http://guix.gnu.org/manual/en/html_node/Installation.html#Installation>
      When using the supplied isntaller-script, this is a matter of a
      few minutes.

2. Clone and build guix:

   git clone https://gitlab.digitalcourage.de:htgoebel/guix.git
   cd guix
   git checkout kde-plasma-bug  #  <<--- important
   ./bootstrap
   ./configure --localstatedir=/var
   make scripts/guix make-go

3. Try to build `kscreen`:

   ./pre-inst-env guix build kscreen

OBSERVED RESULT
====================
Build/configure fails with the messae above.

EXPECTED RESULT
====================
Build/configure passes.

SOFTWARE/OS VERSIONS
====================
plasma-framwork 5.70.1
kscreen         5.70.1

ADDITIONAL INFORMATION
=========================

(1) PlasmaQuick_INCLUDE_DIR is based on PACKAGE_PREFIX_DIR (see
KF5PlasmaQuickConfig.cmake). Within KF5PlasmaQuickConfig.cmake,
PACKAGE_PREFIX_DIR is okay up to the call of `find_dependency(KF5Plasma
"5.70.0")`. After this call, PACKAGE_PREFIX_DIR points to extra-cmake-modules.

(2) I was able to inhibit this change by removing the call to
`"(find_package(ECM …)` in KF5PlasmaMacros.cmake.

(3) The repo mentioned above already contains some package definitions to help
debugging and playing around:
   * the relevant file is gnu/packages/kde-plasma.scm
   * around line 610 there a copy of KF5PlasmaQuickMacros.cmake is provided
     which you can easily play with. Tracing PACKAGE_PREFIX_DIR is
     already in there.
   * around line 600 there is code prepared for removing the
     `find_pachage(ECM …)`

(4.1) Seems like `find_pachage(ECM …)` is required to set ECM_KDE_MODULE_DIR
(see KF5PlasmaMacros.cmake). Within all KDE-framework packages
ECM_KDE_MODULE_DIR is only used in to cmake-files:
- KF5Package/KF5PackageMacros.cmake
- KF5Plasma/KF5PlasmaMacros.cmake

$ grep -rh ECM_KDE_MODULE_DIR  /gnu/store/*/lib/cmake/ | sort -u
include(${ECM_KDE_MODULE_DIR}/KDEInstallDirs.cmake)
$ grep -rl ECM_KDE_MODULE_DIR  /gnu/store/*/lib/cmake/ | sed 's!.*/lib/cmake/!!' | sort -u
KF5Package/KF5PackageMacros.cmake
KF5Plasma/KF5PlasmaMacros.cmake

(4.2) ECM_KDE_MODULE_DIR is only used in
`include(${ECM_KDE_MODULE_DIR}/KDEInstallDirs.cmake)`, which also is only used
in these two cmake files.

$ grep -rh KDEInstallDirs.cmake  /gnu/store/*/lib/cmake/ | sort -u
include(${ECM_KDE_MODULE_DIR}/KDEInstallDirs.cmake)
$ grep -rl KDEInstallDirs.cmake  /gnu/store/*/lib/cmake/ | sed 's!.*/lib/cmake/!!' | sort -u
KF5Package/KF5PackageMacros.cmake
KF5Plasma/KF5PlasmaMacros.cmake

(4.3) Maybe these are left-overs and can be removed?
Comment 2 Christophe Marin 2020-12-14 15:36:11 UTC
Git commit 87372a37fc61eb8dab0908f1cb083ba416ae9464 by Christophe Giboudeaux.
Committed on 14/12/2020 at 15:34.
Pushed by cgiboudeaux into branch 'master'.

Revert "Fix build errors if PREFIX is different from ECM's PREFIX."

This change is breaking build for applications that require kpackage
but have no direct dependency on ECM. (eg: ikona)

This reverts commit 85ab4362b62178780371348bfb277af1540552e1.

M  +2    -1    KF5PackageMacros.cmake

https://invent.kde.org/frameworks/kpackage/commit/87372a37fc61eb8dab0908f1cb083ba416ae9464