How to prepend CMAKE_LIBRARY_OUTPUT_DIRECTORY to QCoreApplication::libraryPaths() ?

David Faure faure at kde.org
Sun Mar 11 18:50:44 UTC 2018


On dimanche 11 mars 2018 12:08:27 CET Elvis Angelaccio wrote:
> Hi,
> I have a weird crash in ark if I enable the target generation in the bin
> subfolder [1].
> The problem is that QCoreApplication::libraryPaths() returns the following
> list:
> 
>     ark.kerfuffle: ("/usr/lib/qt/plugins",
> "/home/elvis/dev/kde/ark/build/bin")
> 
> which means that ark loads first its system-wide plugins, while it should
> load first the plugins form its build dir.
> 
> ECM has code that fixes this problem for test targets [2].
> I tried to do the same to all the ark targets (main executable, kerfuffle
> library, plugins), but it doesn't work.
> Commit message in [2] by David says:
> 
>     "This of course requires running the unittests via ctest rather than
> launching the executable directly."
> 
> Does that mean that ctest has some magic that adjusts the library paths?

The magic is the one that is set by that very commit [2] you're referencing:
it sets $QT_PLUGIN_PATH in the env used by ctest to run the test.

> Is it possible to do the same with normal executables?

I don't see how cmake could help, since you're launching the executable 
directly, not via cmake/ctest.

Solution 1: a change in Qt to add executablePath() to the plugin path, but 
that got rejected when I tried.
https://codereview.qt-project.org/203646

Solution 2 : a wrapper script to launch ark after setting the plugin path.
This seems to be the qmake solution. See the uic_wrapper.sh files anywhere in 
the builddir of any qmake project...

I guess we could make ECM generate such wrapper scripts for all non-test 
executables...

-- 
David Faure, faure at kde.org, http://www.davidfaure.fr
Working on KDE Frameworks 5





More information about the Kde-buildsystem mailing list