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

Martin Koller kollix at aon.at
Mon Nov 17 07:01:39 EST 2014


Hi,

I have a project where Qt is used, so I use AUTOMOC.
However I have something special:
My Qt class implementation needs another (external) Qt implemented source, which
I have packed as tar.bz2 file.

I have a rule which shall extract the .tar.bz2 file, which works nicely.
However, the AUTOMOC generates the moc_ file BEFORE the rule to extract the .tar.bz2 file
triggers, which means moc can not include some headers which are inside this tar file
and the result is wrong.

I have something like (excerpt):

add_library(MYLIB MODULE source.cxx)
set_target_properties(MYLIB PROPERTIES AUTOMOC TRUE)

add_custom_command(OUTPUT header.h
                   COMMAND ${CMAKE_COMMAND} -E tar xf ${CMAKE_CURRENT_SOURCE_DIR}/includes.tar.bz2
                   COMMAND ${CMAKE_COMMAND} -E tar vxf ${CMAKE_CURRENT_SOURCE_DIR}/${TARFILE}
                   COMMAND ${CMAKE_COMMAND} -E touch_nocreate header.h
                   DEPENDS ${TARFILE})

add_custom_target(data_lib DEPENDS header.h)

add_dependencies(${TARGET} data_lib)


What rules can I add so that the tar extraction is done BEFORE the moc generation ?

-- 
Best Regards/Schöne Grüße

Martin



More information about the CMake mailing list