[CMake] postBuildInstallation howto

luxInteg lux-integ at btconnect.com
Mon Nov 15 14:20:11 EST 2010


On Saturday 13 November 2010 20:43:12 Michael Hertling wrote:

> IIRC, the INSTALL() command with the FILES, PROGRAMS and DIRECTORY
> signature may appear in any CMakeLists.txt, but with the TARGETS
> signature, it must be placed in the same CMakeLists.txt as the
> targets it refers to. Anyway, IMO, it's a good style to have
> the INSTALL() commands near their subjects, generally.
> 
> > --I want to install   man pages, TEX files etc, I checked this
> > http://www.cmake.org/Wiki/CMake:Install_Commands   but did not see any
> > references to files of the latter types -So how are these installed  from
> > a ~/doc directory in the build tree?
> 
> E.g., in the source directory's ~/doc/CMakeLists.txt, say
> 
> INSTALL(FILES ${MANPAGES} DESTINATION man)
> 
> with the variable MANPAGES containing the to-be-installed man pages
> with their absolute paths within the build directory, or preferably
> 
> INSTALL(DIRECTORY ${CMAKE_BINARY_DIR}/doc/man/ DESTINATION man)
> 
> to install the contents of ${CMAKE_BINARY_DIR}/doc/man to the
> ${CMAKE_INSTALL_PREFIX}/man directory; note the trailing slash.
> 
> BTW, don't use the old INSTALL_{FILES,PROGRAMS,TARGETS}() commands; use
> the new comprehensive INSTALL() command with its signatures exclusively.
> 
> > --If say one has a directory named INCLUDE in the build tree and one sets
> >  the files therein as ${headers}  does one  do
> > INSTALL_FILES(/include ${headers}) to install into
> > ${Install_prefix}/include
> 
> If the headers variable contains absolute paths, you might say
> INCLUDE(FILES ${headers} DESTINATION include) anywhere the headers
> variable is defined to install to the ${CMAKE_INSTALL_PREFIX}/include
> directory. Otherwise, you should say INCLUDE(DIRECTORY <absolute/path/
> to/INCLUDE>/ DESTINATION include) to install the contents of the whole
> INCLUDE directory to ${CMAKE_INSTALL_PREFIX}/include - preferable again.
> 
> > and is it done from a CMakeLists.txt within ~/INCLUDE to
> > effect installation OR do you do otherwise and if so how so?
> 
> You said the INCLUDE directory is in the build tree, and the build tree
> has no CMakeLists.txt unless you're doing a discouraged in-source build:
> 
> <http://www.cmake.org/Wiki/CMake_FAQ#Out-of-source_build_trees>
> 


I had quite accidently  sussed quite a lot of it out.  I am beginning to find 
CMake quite useful.


thanks again


More information about the CMake mailing list