[CMake] install target

Alin M Elena alin.elena at qub.ac.uk
Sat May 3 15:09:16 EDT 2008


Hi,

Thanks Yuri.
Based on your observations I got a solution.
Note that I use doxygen to generate the documentation so I use the 
find_package(Doxygen)   somewhere before in CMakeLists.txt

Here is what I did
if(DOXYGEN)
  configure_file(${CMAKE_SOURCE_DIR}/Doxyfile.cmake Doxyfile)
  add_custom_target(docs
    ${DOXYGEN_EXECUTABLE} ${PROJECT_BINARY_DIR}/Doxyfile)
  install(CODE "execute_process(COMMAND ${CMAKE_BUILD_TOOL} docs)")
  install(DIRECTORY ${CMAKE_BINARY_DIR}/doc/html/ DESTINATION doc)
endif(DOXYGEN)

and now make install and make package behaves as I need.
One may note two things.
1. because I used add_custom_target I get an out-of-date target each time so 
make docs gets executed always when make install or make package.
2. install(CODE hase to be always before install(DIRECTORY otherwise doc/html 
may not exist and one gets an error.

Alin

> Hi,
>
> There were many discussions on this subject, but I don't remember final
> solution. I suppose, in your case it is better to add special target via
> ADD_CUSTOM_COMMAND, where OUTPUT is your documentation file(s), and
> MAIN_DEPENDENCY/DEPENDS are source files. Later you can install output file
> as usually. This is based on several points:
> 1) "install" ensures that everything is built by executing make all target.
> 2) ADD_CUSTOM_COMMAND while used properly sets correct dependencies between
> target file and it's sources, so if anything changed, CMake will rebuild
> this and all dependent targets.
> 3) INSTALL command will install generated target.
>
> Of course, this will not work with ADD_CUSTOM_TARGET.
>
> So the drawback is that your documentation will be built (if something has
> changed, that is actually only dependencies will be checked) every time you
> run make. I suppose in CMake this is handled by some kind
> of "BUILD_Documentation" variables to speed-up regular development.
>
> And if you need something really exotic at install time, you can refer to
> INSTALL(CODE/SCRIPT) commands :).
>
> Yuri


-- 
______________________________________________________________________ 
 "...if the universities will not study useless subjects, who will?" 
                           G. F. Fitzgerald, Nature, 45/46, 392 (1892)
______________________________________________________________________
Mr. Alin M. ELENA
Atomistic Simulation Centre
School of Mathematics and Physics
Queen's University Belfast
Office: +44 (0)28 9097 1428
Fax: +44 (0)28 9097 5359
http://titus.phy.qub.ac.uk/group/Alin/
alin.elena at yahoo.co.uk 
alin.elena at qub.ac.uk
______________________________________________________________________


More information about the CMake mailing list