I've got the following problem using cmake. I use UseDoxygen from http://tobias.rautenkranz.ch/cmake/doxygen/ to generate the documentation for my library. This works fine, but know I want to realize the following:
When I call "make install" I want to build to Documentation and install it too. Therefore I add
install(DIRECTORY ${DOXYFILE_OUTPUT_DIR}/${DOXYFILE_HTML_DIR} DESTINATION share/doc/mylib/)
add_dependencies(install doc)
to my CMakeLists.txt.
This results in an error:
CMake Error at CMakeModules/UseDoxygen.cmake:145 (add_dependencies):
add_dependencies Adding dependency to non-existent target: install
Call Stack (most recent call first):
CMakeLists.txt:141 (include)
Is it possible to get a easy workaround for this? Because if the targets are not connected the install step installs nothing unless "make doc" is done manually befor calling "make install".
regards
Grisu
We build our documentation by adding it with add_custom_target
with the ALL
option specified so it builds with the all
target.
Then to install, it's just the install
command. There is no need to add anything to the install
target.
If you add the documentation to the all
target, then doing make install
will also build the documentation.
If you generate code documentation, isn't it a better idea to execute that command after the build command? In this way it will be available at install time.
You can add a custom command at POST_BUILD and execute the doxygen commands there. See more at http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:add_custom_command
Building documentation via add_custom_target( ALL ...) is not an ideal solution, as it means the documentation gets built redundantly for all configurations (Debug, Release, RelWithDebInfo, MinSizeRel).
I'd like to build the documentation once regardless of the build config, then use the CONFIGURATIONS option of the install() command to install it only for the Release and RelWithDebInfo configs. install() should depend on the documentation target but, as I said, only build it for one config. There doesn't appear to be an way to add a dependency from install() onto the documentation that meets these requirements.