[cmake-developers] QtAutogen suggestions
Sebastian Holtermann
seblist at xwmw.org
Fri Nov 25 17:37:34 EST 2016
Hi.
There are some issues with QtAutogen that still bother me and
that I would like to change.
1) Most files get generated in
${CMAKE_CURRENT_BINARY_DIR}/${TARGETNAME}_automoc.dir
Is the ".dir" suffix neccessary? I think is should be removed.
2) Moc files that are manually included by a
#include "moc_<basename>.cpp"
statement get generated in ${CMAKE_CURRENT_BINARY_DIR}
This is not ideal because
- ${CMAKE_CURRENT_BINARY_DIR} must be added to the
INCLUDE_DIRECTORIES manually in CMakeLists.txt
- Multiple targets may write divergent content
concurrently to the same moc_<basename>.cpp file.
A better solution would be to generate the moc_<basename>.cpp files in
${CMAKE_CURRENT_BINARY_DIR}/${TARGETNAME}_automoc/include.
AUTOMOC then should automatically add that directory to the
INCLUDE_DIRECTORIES of the origin target.
The same issue is present for AUTOUIC btw. which generates header files
in ${CMAKE_CURRENT_BINARY_DIR}. It could be adapted in the same way.
3) The mocs compilation file currently gets generated as
${CMAKE_CURRENT_BINARY_DIR}/${TARGETNAME}_automoc.cpp
The file could be generated as
${CMAKE_CURRENT_BINARY_DIR}/${TARGETNAME}_automoc/compilation.cpp
This way and along with the changes in 2) all files would be generated in
${CMAKE_CURRENT_BINARY_DIR}/${TARGETNAME}_automoc.
This is nice and contained and allows perfect cleanup by adding
the directory to ADDITIONAL_MAKE_CLEAN_FILES.
The moc/uic cleanup is broken/incomplete in CMake 3.7 btw..
4) AUTOMOC AUTOUIC and AUTORCC perform different independent tasks that
in the current implementation get processed serially inside a single
custom target named ${TARGETNAME}_automoc.
I think each of the three could be handled in an own target.
Then instead on one custom target there would be three custom targets:
- ${TARGETNAME}_automoc
- ${TARGETNAME}_autouic
- ${TARGETNAME}_autorcc
Also each target would generate all files in an own directory:
- ${CMAKE_CURRENT_BINARY_DIR}/${TARGETNAME}_automoc
- ${CMAKE_CURRENT_BINARY_DIR}/${TARGETNAME}_autouic
- ${CMAKE_CURRENT_BINARY_DIR}/${TARGETNAME}_autorcc
Once in place this would also be easier to maintain compared to now
where all three target logics are mixed together in a single C++ class.
Please share your opinion on the points.
If there is no fundamental opposition I will simply
go ahead and work on the patches.
-Sebastian
More information about the cmake-developers
mailing list