[CMake] Trouble exporting a library that is linked to Qt5

Alan W. Irwin irwin at beluga.phys.uvic.ca
Thu Apr 17 18:48:14 EDT 2014


For the case when libplplot (the principal library of the PLplot
project) is linked to Qt4, libplplot can be exported and other
projects can import and link to libplplot and its Qt4 dependency
without issues regardless of whether libplplot is built shared or
static.  However, there are linking errors when external projects
attempt to link to the exported static PLplot library when it has Qt5
dependencies.

Here are some more specifics about this issue.  The Qt5 part of the
linking of libplplot is done with

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 ...)

The resulting export_plplot-noconfig.cmake file contains the following
CMake code:

# Import target "plplot" for configuration ""
set_property(TARGET plplot APPEND PROPERTY IMPORTED_CONFIGURATIONS
NOCONFIG)
set_target_properties(plplot PROPERTIES
   IMPORTED_LINK_INTERFACE_LANGUAGES_NOCONFIG "C;CXX"
   IMPORTED_LINK_INTERFACE_LIBRARIES_NOCONFIG
"Qt5::Svg;Qt5::Gui;Qt5::PrintSupport;/usr/lib/x86_64-linux-gnu/libm.so;/home/wine/newstart/build_script/install-linux/lib/libshp.so;/usr/lib/x86_64-linux-gnu/libfreetype.so;csirocsa;csironn;qsastime"
   IMPORTED_LOCATION_NOCONFIG
"/home/wine/newstart/build_script/build_dir-linux/epa_build/Source/comprehensive_test_disposeable/static/install_tree/lib/libplplot.a"
   )

The Qt5 information here appears incomplete to me.
Instead of Qt5::Svg;Qt5::Gui;Qt5::PrintSupport, I would have expected
the specific locations: 
/home/wine/newstart/build_script/install-linux/lib/libQt5Svg.so;/home/wine/newstart/build_script/install-linux/lib/libQt5Gui.so;/home/wine/newstart/build_script/install-linux/lib/libQt5PrintSupport.so

The above double-colon syntax produces the following linking errors
for an external project which attempts to build an application against
libplplot:

Linking CXX executable x00c
cd /home/wine/newstart/build_script/build_dir-linux/epa_build/Source/comprehensive_test_disposeable/static/install_build_tree/c && /home/wine/newstart/build_script/install-linux_buildtools/bin/cmake -E cmake_link_script CMakeFiles/x00c.dir/link.txt --verbose=1
/usr/bin/c++   -O3 -fvisibility=hidden -Wuninitialized     CMakeFiles/x00c.dir/x00c.c.o  -o x00c -rdynamic /home/wine/newstart/build_script/build_dir-linux/epa_build/Source/comprehensive_test_disposeable/static/install_tree/lib/libplplot.a -lm -lQt5::Svg -lQt5::Gui -lQt5::PrintSupport /home/wine/newstart/build_script/install-linux/lib/libshp.so -lfreetype /home/wine/newstart/build_script/build_dir-linux/epa_build/Source/comprehensive_test_disposeable/static/install_tree/lib/libcsirocsa.a /home/wine/newstart/build_script/build_dir-linux/epa_build/Source/comprehensive_test_disposeable/static/install_tree/lib/libcsironn.a /home/wine/newstart/build_script/install-linux/lib/libqhull.so /home/wine/newstart/build_script/build_dir-linux/epa_build/Source/comprehensive_test_disposeable/static/install_tree/lib/libqsastime.a -lm -Wl,-rpath,/home/wine/newstart/build_script/install-linux/lib

/usr/bin/ld: cannot find -lQt5::Svg
/usr/bin/ld: cannot find -lQt5::Gui
/usr/bin/ld: cannot find -lQt5::PrintSupport
collect2: error: ld returned 1 exit status
make[7]: *** [c/x00c] Error 1

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?

Note, the above results were determined using version 5.2.1 of Qt5 and
CMake-2.8.12.1.

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