Help with debuggin KF5 / CMake error in building Okular to avoid jagged lines of freehand tool

I'm trying to compile Okular from scratch following these instructions (towards the end of the page):

git clone https://invent.kde.org/graphics/okular.git
cd okular
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/path/to/your/install/dir ..
make
make install

where I replaced /path/to/your/install/dir with /usr.

Make fails with (last lines):

-- Could NOT find KF5JS: found neither KF5JSConfig.cmake nor kf5js-config.cmake 
-- Could NOT find KF5Wallet (missing: KF5Wallet_DIR)
-- Could NOT find KF5Wallet: found neither KF5WalletConfig.cmake nor kf5wallet-config.cmake 
CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
  Could NOT find KF5 (missing: Archive Bookmarks Completion Config
  ConfigWidgets CoreAddons Crash IconThemes KIO Parts ThreadWeaver
  WindowSystem DocTools JS Wallet) (Required is at least version "5.44.0")
Call Stack (most recent call first):
  /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
  /usr/local/share/ECM/find-modules/FindKF5.cmake:94 (find_package_handle_standard_args)
  CMakeLists.txt:96 (find_package)

Prior steps:

  • installed extra-cmake-modules following this answer.

  • installed kf5 packages with sudo apt-get install "libkf5*" following this answer

  • tried several other tips, all without success (e.g., modifying the cmake command to:

    cmake -DQT_QMAKE_EXECUTABLE=qmake-qt5       \
          -DCMAKE_INSTALL_PREFIX=/usr .. \
    -DCMAKE_BUILD_TYPE=Release            \
    -DBUILD_TESTING=OFF                   \
    -DQT_NO_VERSION_TAGGING=OFF           \
    -Wno-dev .. &&
    make
    

    )

Relevant posts on askubuntu:

  • Perhaps I need to specify in the terminal where these packages are located, similar to this solution?

  • Or do I need to modify the CMakeLists.txt as in this solution?

Background:

On Ubuntu 20.04 LTS, using the stylus with the freehand annotation tool results in jagged lines, as this post on reddit and this gif show. See also this thread on the bugtracker which suggests a modification to ./ui/pageviewannotator.cpp that has (I think) already been implemented in the cloned github version (search the thread for PageViewAnnotator). The TLDR of the problem is that when using the stylus, too many points are created that result in the jagged shapes when rendered.

okular freehand tool

Screenshot of the linked gif: stylus (left) vs. finger (right). Using a thick stroke here to highlight the issue. The stylus works fine in other programs like Xournal++.


Solution 1:

Solution no 1

KDE is divided into many modules and okular depends on many of them. So probably the most sane solution is to use kdesrc_build tool.

Once you get it you basically need to run a single command

<path-to-binary>/kdesrc_build okular

Notes:

  • Okular depends on arround 80 modules so it will take time to download and build them all. Quite a lot of time actually. And few GB of data.
  • KDE has external dependencies and you propably will need to install a lot of additional dev packages. You can check in build logs for missing libraries. But it means that few runs of kdesrc_build might be needed.
  • Your app will be built against libraries from custom build but at runtime it will be linked to libraries of your currently running KDE (assuming you are running one). It may work if you dont use new methods from latest version but its tricky business. Still better to check it first before running session on custom kde build.

Solution no 2

This is a little bit trickier but might save some time if you want to use version of KDE that is already installed on your system.

Check what dependencies are actually needed for Okular with:

<path-to-binary>/kdesrc_build -list-build okular

Use this list to install missing kf5 packages. Note you neeed not only libraries but also development files (packages with dev suffix).

Build okular directly using cmake with the command that you pasted in the question but make sure that paths you are providing are correct for your system.

Notes:

  • cmake use pkg-config to detect libraries, so make sure you have installed it.
  • Your operating system may not provide all required development files as packages.