[CMake] Using Qt5 with CMake

Alan W. Irwin irwin at beluga.phys.uvic.ca
Tue Mar 11 16:59:16 EDT 2014


On 2014-01-26 17:36+0100 Stephen Kelly wrote:

> http://doc-snapshot.qt-project.org/qt5-stable/cmake-manual.html

To resurrect this slightly old thread, it has been years since I
implemented the Qt4 parts of the PLplot build system, and I haven't
looked much at the Qt components of our build system ever since.  So I
am basically starting again from virtually no knowlege concerning
CMake support for Qt to get the PLplot build system to find and use
the Qt5 components that it needs.  I am frankly somewhat lost trying
to use the above documentation which seems rather incomplete from my
perspective.  Another complicating factor at the moment is I don't
have access to Qt5 (running Debian stable) so, for now, I don't have a
chance to try some experiments to work things out, and others (who
have considerably less general knowledge than I do concerning the
PLplot build system) will be trying out what is recommended here
instead of me.

So here are some specific questions related to PLplot's future Qt5 needs.

(1) How should you replace

find_package(Qt4 4.8.2 COMPONENTS QtCore QtGui QtSvg)

and

qt4_wrap_cpp(
   QT_MOC_OUTFILES
   ${CMAKE_SOURCE_DIR}/include/qt.h
   OPTIONS ${MOC_OPTIONS}
   )

(the two key commands the PLplot build system currently uses for Qt4)
with the new cmake finding infrastructure documented above?
(MOC_OPTIONS are some macros we set to control including or dropping
various parts of the PLplot qt.h header file.)

(2) PLplot currently does not use include(${QT_USE_FILE}) since in my
view that directory property approach is too blunt an instrument that
tends to contaminate the large parts of the PLplot build that have
nothing to do with Qt with all the Qt-related compiler flags. Instead,
we use the alternative approach of simply setting the appropriate Qt
compile flags for our specific Qt-related source files.  Does Qt5
still use that directory property apprach for setting compile flags
or is this no longer an issue?

(3) Our current alternative to include(${QT_USE_FILE}) still sets
QT_LIBRARIES.  That allows us to link one of the key PLplot Qt-related libraries
as follows:

target_link_libraries(
   plplotqt${LIB_TAG}
   plplot${LIB_TAG}
   ${MATH_LIB}
   ${QT_LIBRARIES}
   )

How should that command be replaced for the new Qt5 way of doing
things?

It appears from the above documentation that the new Qt5 find and use
methods are quite dependent on CMake version so assume for the
purposes of this question that our build system will force the PLplot
user to use CMake version 2.8.11 or higher by the time we have this
all debugged.

Thanks in advance for any help you can give with the specific
questions above for converting a project such as PLplot that currently
uses Qt4 to one that uses Qt5.

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