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

2014-04-17 Thread Alan W. Irwin

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
__
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


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

2014-04-18 Thread Stephen Kelly
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

Thanks,

Steve.



-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


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

2014-04-18 Thread Alan W. Irwin

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  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
__
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


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

2014-04-19 Thread Alan W. Irwin

On 2014-04-18 08:33-0700 Alan W. Irwin wrote:


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?


Hi Steve:

Never mind answering that question.  I have figured out how to do this for
myself.  I have created a plplotConfig.cmake file which contains:

___
# Find Qt5 components that we need.
find_package(Qt5 5.2.0 COMPONENTS Svg Gui PrintSupport)

# Find export files in same directory location as present file.
include(${CMAKE_CURRENT_LIST_DIR}/export_plplot.cmake)
___

where export_plplot.cmake is generated by the "install(EXPORT ...)"
command above.  Subsequent use of "find_package(plplot)" by external
projects now works fine for both the shared plplot library case (that
worked before) and the static plplot library case (that did not work
before).

Thanks for your essential help in getting this issue straightened out.

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
__
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake