How do I achieve the following in CMake (using version 2.8.5)? I have documentation generated by a custom target named doc, the output of which I would like to include when installing or CPack’ing.
add_custom_target( doc "${DOXYGEN_EXECUTABLE}" Doxyfile )
install( DIRECTORY ${CMAKE_BINARY_DIR}/doc DESTINATION doc )
The Doxyfile tells Doxygen to put out the documentation at ${CMAKE_BINARY_DIR}/doc.
If I do this in the build directory:
make doc
cpack
things works fine, because the first line creates the directory on which the install target depends.
However, if I have a fresh build (so ${CMAKE_BINARY_DIR}/doc does not exist yet), and I invoke CPack directly:
cpack
then it complains that it cannot find ${CMAKE_BINARY_DIR}/doc:
CMake Error at <snip>/build/cmake_install.cmake:36 (FILE):
file INSTALL cannot find "<snip>/build/doc".
I have also tried the following:
add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/doc COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile )
install( DIRECTORY ${CMAKE_BINARY_DIR}/doc DESTINATION doc )
but I still get the same CPack error, and doing make doc in the build directory does not work either.
So if I do the make doc manually before cpack it works with the configuration at the top of this post, but how can I tell cmake/cpack that the install directive depends on the custom target doc, so that building the documentation happens automatically when calling cpack or make install?
Thanks!
Probably you need
ALLkeyword:Update:
Currently cmake does not provide an option to add custom dependencies to its built-in targets (such as
all,install,test, etc). And it seems that it will not provide this option in near future – see http://public.kitware.com/Bug/view.php?id=8438However it is still possible to achieve desired behavior with some hacks/workarounds. For example you can directly run make tool at the beginning of install step.
So use on your own risk: