Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake add depedency to the install target

Tags:

cmake

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

like image 713
M.K. aka Grisu Avatar asked Feb 06 '12 16:02

M.K. aka Grisu


People also ask

What is the use of the command install () in CMake?

This command has been superseded by the install () command. It is provided for compatibility with older CMake code. Create rules to install the listed targets into the given directory. The directory <dir> is relative to the installation prefix, which is stored in the variable CMAKE_INSTALL_PREFIX.

How to add a custom target to the install target?

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.

What is get_prerequisites in CMake?

GetPrerequisites.cmake. get_prerequisites is a lower level function that allow you to get the dependencies. The thing is, I don't any good way/best practice to use it.

Why doesn't make Doc install with all targets connected?

Because if the targets are not connected the install step installs nothing unless "make doc" is done manually befor calling "make install". See the answer to this question. We build our documentation by adding it with add_custom_target with the ALL option specified so it builds with the all target.


1 Answers

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.

like image 185
tpg2114 Avatar answered Oct 24 '22 00:10

tpg2114