[CMake] can I make an AUTOMOC generated file depend on something ?

Kim Rydhof Thor Hansen kim at rthansen.dk
Wed Feb 25 08:09:58 EST 2015


Hi,

On Mon, Nov 17, 2014 at 10:23 PM, Stephen Kelly <steveire at gmail.com> wrote:
> Martin Koller wrote:
>
>> What rules can I add so that the tar extraction is done BEFORE the moc
>> generation ?
>
> You can add depends in the AUTOGEN_TARGET_DEPENDS target property of
> particular targets.
>
>  http://www.cmake.org/cmake/help/v3.0/prop_tgt/AUTOGEN_TARGET_DEPENDS.html

I have a similar problem because automoc doesn't pick up that my
metadata.json file is a dependency to the generated moc_plugin.cpp
when building a Qt plugin with:
    Q_PLUGIN_METADATA(IID "com.example.cmake.test" FILE "metadata.json")

Given the suggestion here I have tried to fix my problem using
AUTOGEN_TARGET_DEPENDS, but that also doesn't work.

Am I using AUTOGEN_TARGET_DEPENDS in a wrong way?

>From my CMakeLists.txt
    add_library(plugin MODULE plugin.cpp)
    target_link_libraries(plugin Qt5::Core)
    set_property(TARGET plugin PROPERTY AUTOGEN_TARGET_DEPENDS metadata.json)

I have attached a minimal example showing how the module is not
rebuild when metadata.json is edited. I have tested using 3.0.2, 3.1.3
and 3.2.0-rc2.

Regards,
Kim Hansen
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plugin-rebuild.zip
Type: application/zip
Size: 1357 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150225/62e4a286/attachment-0001.zip>


More information about the CMake mailing list