Working around CMAKE brain-damage
Allan Sandfeld Jensen
kde at carewolf.com
Mon Aug 10 11:31:23 BST 2009
Hi
I've been trying to resolve a problem I got when configuring varies KDE 4
modules. CMake complains that it can not sane search paths for some libraries
in particular qimageblitz and polkitqt. The reason it can set the search path
is quite clear, CMake has for some reason found the system version of the
libraries in stead of the development versions. When rpath is set with
development dirs before system-dirs, linking will choose the correct
development version and not the wrong system version CMake has picked.
I've been debugging the modules and think I've found the source of the
problem. The problem is a combination of that we do and what cmake does.
We do:
1. Find the module using pkgconfig
2. Supply the pkg-config paths to cmake functions find_path and find_library
What does wrong is that, find_path and find_library search the default system
paths BEFORE searching the paths that you have asked it to search in. The also
creates serious issues as we use pkg-config to ensure we have picked the right
version of a library but since the cmake find_ functions use their own broken
logic, they can easily pick includes and lib-paths that differ from the pkg-
config result we have found and verified.
There is a number of solutions to fix the problem:
1. Never use find_path and find_library after pkg-config. We have found the
module using pkg-config so trust it to return correct paths.
2. Run find_path and find_library with the NO_DEFAULT_PATH flag. This will
make them not search the default paths and only the specified paths. To still
have proper fail-over we could call them again afterwards to search the
defaults incase a path haven't been found yet.
3. Instruct developers to set always set the new enviroment variables $INCLUDE
and $LIB when setting $PKG_CONFIG_PATH.
Attached is an example of solution number 2.
Greetings
`Allan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: FindQImageBlitz.cmake.diff
Type: text/x-patch
Size: 858 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20090810/11bbee7a/attachment.bin>
More information about the kde-core-devel
mailing list