[cmake-developers] Current deficiencies of automoc

Alan W. Irwin irwin at beluga.phys.uvic.ca
Fri Oct 21 21:01:03 EDT 2016


On 2016-10-21 23:54+0200 el.bartho at gmx.de wrote:

>
>> 1. The automoc documentation at
>> <https://cmake.org/cmake/help/v3.6/prop_tgt/AUTOMOC.html> only
>> documents the #include method (which doesn't work for the current test
>> case nor for PLplot), and the above working fullpath method is not
>> documented at all there. 
>
> At least in cmake-qt(7) [1] this is documented:
>
> If a |Q_OBJECT| or |Q_GADGET| macro is found in a header file, |moc| will be 
> run on the file. The result will be put into a file named according to 
> |moc_<basename>.cpp|. If the macro is found in a C++ implementation file, the 
> moc output will be put into a file named according to |<basename>.moc|, 
> following the Qt conventions. The |moc file| may be included by the user in 
> the C++ implementation file with a preprocessor |#include|. If it is not so 
> included, it will be added to a separate file which is compiled into the 
> target.

Hi Marc:

I have put my response to your comment back on the list where I think it
belongs.

I don't agree with your above conclusion.  The above remarks immediately refer to
header files and imply automoc scans them to find the ones that contain
the Q_OBJECT macro and certainly does not imply the user must list
the files to be scanned directly as fullpaths in the add_executable
(or add_library) command.  And the last sentence implies that
if the so-called #include method is not used, then automoc will figure
everything out for itself, i.e., the fullpath method allowing the
user to specify which headers are scanned by moc is not documented
here at all.

If the first sentence in the above paragraph had referred to header
files appearing in the list of source files for add_executable or
add_library and/or if the last sentence in the above paragraph had
been replaced by

"If it is not so included, the user must put the fullpaths of the
headers that need moc processing in the source list for add_executable
or add_library." then I would agree with your conclusion, but that
type of specific documentation of the fullpath method is just not
currently in the cmake-qt documentation.

By the way, I have been able to show that the "leaving it completely
to automoc" method documented above does not work with the second
(fixed) version of my simple example, and I urge you to try that
experiment also by making the following additional change (from
"fullpath" to "leave it to automoc")

-  add_executable(helloworld main.cpp ${CMAKE_SOURCE_DIR}/include/test_q_object.h)
+  add_executable(helloworld main.cpp)

For this case nm shows everything in test_q_object.h is completely ignored 
by automoc despite the '#include "test_q_object.h"' in main.cpp.

N.B. the above documentation is likely correct and the "leave it to
automoc" method should work but it doesn't for this simple example, and that is likely
due to the same bug that keeps the "#include" method from working for
this simple example of an include file in a separate directory.

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-developers mailing list