[CMake] Trouble exporting a library that is linked to Qt5
Alan W. Irwin
irwin at beluga.phys.uvic.ca
Fri Apr 18 11:33:42 EDT 2014
On 2014-04-18 15:38+0200 Stephen Kelly wrote:
> Alan W. Irwin wrote:
>
>> Can anyone explain what is going wrong here? For example, do I have to
>> do something extra (i.e., something not required for Qt4) to get
>> libplplot exported properly when it links to Qt5?
>
> Even when using Qt 4 you will find the same behavior if you use the imported
> targets instead of the file paths (Qt4::QtCore etc).
>
> If your package publically depends on Qt5, then you need to find it in your
> config file.
>
> http://www.cmake.org/cmake/help/git-next/manual/cmake-packages.7.html#creating-packages
>
Hi Steve:
Thanks for your quick reply.
To give you some more background, exporting the ~10 PLplot libraries
was implemented by me many years ago (I think when exporting first became
possible) using the simple command (for each installed library)
install(TARGETS <targetname> EXPORT export_plplot ...)
and one
install(EXPORT export_plplot ...)
command. File paths are used for all libraries and all library
dependencies so this simple procedure works fine when libplplot and
one other of our libraries depend on Qt4. Note, there is no explicit
use of an export config file with this simple method (probably because
that capability wasn't available when we implemented exporting).
I would prefer to change the above simple procedure as little as
possible so is there a simple way to access the Qt5 library filepaths?
If not and you recommend instead we use an export config
file for our two libraries that depend on Qt5, then I will make those
changes. But since the documentation that you reference in the URL
above is quite complex and includes lots of stuff we currently don't
use, then for the case where Qt5 is currently handled using
find_package(Qt5Core 5.2.0)
[...]
add_library(plplot ${plplot_LIB_SRCS})
[...]
qt5_use_modules(plplot Svg Gui PrintSupport)
[...]
install(TARGETS plplot EXPORT export_plplot ...)
[...]
install(EXPORT export_plplot DESTINATION ...)
could you give a concrete example (that works for CMake 2.8.9 and
above since 2.8.9 is our current minimum required version) of the
minimum additions necessary to the above export procedure? I can
probably figure out how to add the use of an export config file from
the above URL, but I need some guidance on the explicit commands in
the export config file that are used to find Qt5 since finding Qt5 is
a somewhat slippery concept that depends on CMake version.
Alan
__________________________
Alan W. Irwin
Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).
Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________
Linux-powered Science
__________________________
More information about the CMake
mailing list