Page MenuHomePhabricator

allow moc-ing / add MOC_H_FILES for test drivers
Closed, ResolvedPublic

Description

For testing of Qt classes, it is often useful to have helper classes for only the test driver. In these cases the helper classes could make good use of the Q_OBJECT macro, i.e. use signals/slots.

The attached patch allows to fill a MOC_H_FILES variable in test driver files.cmake. The files given in MOC_H_FILES will be run through moc and compiled into the test driver.

Event Timeline

maleike added a subscriber: maleike.

Changes to CoreHelpers.cmake to evaluate MOC_H_FILES

[SVN revision 22754]
FIX (#3983): evaluate MOC_H_FILES for test drivers

Hmm, MOC_H_FILES collides when a modules does not have a Testing directory but a common files.cmake for both the library and the test driver.

To avoid this situation, I'll evaluate a variable MODULE_TEST_MOC_H_FILES instead of MOC_H_FILES. This will also make the files.cmake more readable.

[SVN revision 22755]
COMP (#3983): rename the variable for defining mocable files in files.cmake

Short discussion with Marco:

Actually modules that do NOT have a Testing sub-directory are not meant to be. I.e. the original changes were ok, just one of our internal modules is not ok.

--> undo my last changes, let CREATE_MODULE_TESTS() evaluate MOC_H_FILES
--> repair the sandbox module that does not have a Testing subdirectory.

[SVN revision 22768]
FIX (#3983): evaluate MOC_H_FILES again. Modules without a Testing subdirectory are broken

Review:

  • Changes in CoreHelpers.cmake are sound and straightforward.
  • No further suggestions, setting status to VERIFIED.