[CMake] Adding a dependency leads to dependency being build during ALL_BUILD even if neither target is part of it

Caspar Jonas Goch cjgoch+cmake at gmail.com
Wed Apr 22 08:07:34 EDT 2015


Dear all,

in our project we have two sets of documentation, which are each their own
custom target:

Framework/Doc/CMakeLists.txt:
add_custom_target(FrameworkDoc
                  ${DOXYGEN} ${CMAKE_CURRENT_BINARY_DIR}/doxygen.conf
                  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
                  )

Application/Doc/CMakeLists.txt:
add_custom_target(doc
                  ${DOXYGEN} ${CMAKE_CURRENT_BINARY_DIR}/doxygen.conf
                  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
                  )

As building the documentation takes quite some time neither is part of the
ALL target. With the above configuration building works as expected, each
has to be build manually and the build works. However, the doc target needs
the .tag file which is generated as part of FrameworkDoc. If I add a
dependency:
add_custom_target(doc
                  ${DOXYGEN} ${CMAKE_CURRENT_BINARY_DIR}/doxygen.conf
                  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
                  DEPENDS FrameworkDoc
                  )

the FrameworkDoc target is being build every time I build the ALL target,
instead of only if I build the doc target.

I this behaviour intentional? Am I missing some option I should be using?

Any advice is appreciated,
Caspar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150422/ebdcb6fd/attachment.html>


More information about the CMake mailing list