[CMake] Cannot get automoc to work properly with recommended Qt5 support method

Alan W. Irwin irwin at beluga.phys.uvic.ca
Sun Oct 16 16:43:55 EDT 2016


Hi Stephen:

I am addressing you directly (as well as the list) because you have
been so helpful with Qt5 issues in the past.

The PLplot build system (some of whose components depend on Qt5)
currently uses one of the older Qt5 support methods documented at
<http://doc.qt.io/qt-5/cmake-manual.html>.  But that method is complex
and we are currently running into troubles with it where it uses the
plain target_link_libraries command which conflicts with the keyworded
version that we prefer for our build system.  So I have attempted to
update our Qt5 support to the latest target_link_libraries method
documented at the above URL, but automoc appears not to be working
correctly.

I follow the advice in the above URL and set

set(CMAKE_AUTOMOC ON)

and also set AUTOMOC_MOC_OPTIONS to the following list:

-DPLD_bmpqt;-DPLD_jpgqt;-DPLD_pngqt;-DPLD_ppmqt;-DPLD_tiffqt;-DPLD_svgqt;-DPLD_pdfqt;-DPLD_qtwidget;-DPLD_extqt;-DPLD_memqt

This list is the same as I use for MOC_OPTIONS in the old working method, and
these various macro definitions _must_ be defined to avoid dropping large
swaths of our code from the compilation.  Instead of using

set(CMAKE_INCLUDE_CURRENT_DIR ON)

I use instead (in the directory where the plplotqt library is built)

include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ...)

Furthermore, in that same directory I use

target_link_libraries(plplotqt PRIVATE plplot ${MATH_LIB} Qt5::Svg Qt5::Gui Qt5::PrintSupport)

for the build.  Although that build apparently works with no obvious
issues, there is no sign of any of the above macros in the
VERBOSE=1 output.  Furthermore, I get the following near-empty result
for the generated bindings/qt_gui/plplotqt_automoc.cpp file which
consists just of the following two lines:

/* This file is autogenerated, do not edit*/
enum some_compilers { need_more_than_nothing };

Finally,

"ldd -r bindings/qt_gui/libplplotqt.st"

shows missing symbols that should be defined if the above macros are
defined.

What am I missing?

To move to a related topic, the above URL has a tutorial example for
the recommended support method which builds the helloworld target from
main.cpp.  It would be nice for Qt5 users to learn from that tutorial
example by building it themselves, but that example is incomplete
since no main.cpp (presumably Qt5-related) is provided (as far as I
can discover).  Any chance you could provide that simple example for
developers like me who don't have a lot of Qt5 or C++ expertise but
who just want to build other's Qt5-related work using the best
CMake-related methods?

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