[CMake] How to INSTALL generated files

Eric Noulard eric.noulard at gmail.com
Sun Dec 3 17:23:29 EST 2006


I all CMakers,

We use doxygen to generated API documentation.
We have an ADD_CUSTOM_TARGET(apidoc ...) which runs doxygen.

I want to include generated documentation in the CPack
generated binary tarball/zip/...  but:

1) I don't want doxygen to be run everytime we build
   so I don't ADD_CUSTOM_TARGET(apidoc ALL ...)
   but I wanted to force CMake to run through apidoc TARGET
   when "make package" is called.

   I tried to
   ADD_DEPENDENCIES(package apidoc) but CMake
   complains about non-existent "package" target.

   For now I should remember to do a properly ordered:
   make apidoc
   make package

   if I want the up-to-date generated documentation to be included
   in the generated package.


2) The apidoc target is "generating" files I want to be "installed"
   when calling
   make  install

   The problem is my CMakeList.txt looks something like:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
   SET(APIDOC_DIR ${CMAKE_BINARY_DIR}/doc/api CACHE PATH "API
documentation directory")

   ADD_CUSTOM_TARGET(apidoc
    COMMAND ${CMAKE_COMMAND} -E echo_append "Building API Documentation..."
    COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_INPUT}
    COMMAND ${CMAKE_COMMAND} -E echo "Done."
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    )

   FILE(GLOB_RECURSE doc_files RELATIVE ${APIDOC_DIR} ${APIDOC_DIR}/*)
     FOREACH(file ${doc_files})
     GET_FILENAME_COMPONENT(file_prefix ${file} PATH)
     INSTALL(FILES ${APIDOC_DIR}/${file}
      DESTINATION doc/${file_prefix})
   ENDFOREACH(file)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

 Then I must run cmake twice for make install to work as I want.
 More precisely I should do:
 cmake
 make apidoc
 cmake
 make package

My final question is:

How to get "build-time" generated file be properly intalled
and packaged with CMake/CPack?

-- 
Erk


More information about the CMake mailing list