cmake and linking issues
Stephen Kelly
steveire at gmail.com
Wed Oct 30 11:22:12 UTC 2013
Giorgos Tsiapaliokas wrote:
> find_package(KDE4Support REQUIRED NO_MODULE)
> find_package(KDELibs4 REQUIRED NO_MODULE)
>
> So should the find_package be written like this?
> Is it normal to fail otherwise?
There are likely two issues:
1) a bug in cmake fixed in master with
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0ad2a1c181
2) The targets in those libraries link publically to other targets, but the
dependency is not found in the Config file.
This relates to what I've pointed out a million times. If a dependency is
only used internally, use the PRIVATE keyword to target_link_libraries. If
users of the framework must also link to the dependency, make it PUBLIC and
also add find_dependency() for the dependency to the config file.
For example, if I write:
find_package(KIO REQUIRED)
I get this:
CMake Error at CMakeLists.txt:6 (find_package):
Found package configuration file:
/home/stephen/dev/prefix/qtbase/kde/lib/x86_64-linux-
gnu/cmake/KIO/KIOConfig.cmake
but it set KIO_FOUND to FALSE so package "KIO" is considered to be NOT
FOUND. Reason given by package:
The following imported targets are referenced, but are missing:
KF5::KBookmarks KF5::XmlGui KF5::Solid
For example, either KIO should link privately to solid instead of
publically, or there should be a find_dependency(Solid) in the KIO config
file. Which is it?
There should be an effort to get this right, because it matters for
compatibility guarantees.
Thanks,
Steve.
More information about the Kde-frameworks-devel
mailing list