[CMake] Undocumented magic required for installing globbed files

Radu Serban radu at llnl.gov
Wed Jan 31 20:49:24 EST 2007


Alan W. Irwin wrote:
> On 2007-01-31 17:06-0800 Radu Serban wrote:
> 
>> Alan W. Irwin wrote:
>>
>>> install(
>>>   CODE "
>>>   file(GLOB USER_DOCS ${CMAKE_SOURCE_DIR}/doc/user/html/*) \n
>>>   file(INSTALL DESTINATION ${docdir}/html/user/html
>>>   TYPE FILE FILES \${USER_DOCS}
>>>   )"
>>> )
>> [snip]
>>
>> Just out of curiosity, is there any reason/advantage to using the 
>> above versus simply having
>>
>> file(GLOB USER_DOCS ${CMAKE_SOURCE_SIR}/doc/user/html/*)
>> file(INSTALL DESTINATION ${docdir}/html/user/html
>>  TYPE FILE FILES ${USER_DOCS})
> 
> I don't know for sure.
> 
> Remember, I just copied a pattern from other projects, and I haven't seen
> the alternative pattern you suggest which might or might not work.
> Currently, my best guess is "file(INSTALL" is a workhorse that simply 
> copies
> files at _cmake_ time.  The purpose of the "install(CODE ..." surrounding
> all this is to make a rule that runs cmake commands when the user types
> "make install" which, of course, happens at a quite different time than
> ordinary cmake commands which are usually used to configure the system 
> before
> any make commands are executed.
> 
> Anyhow, all this uncertainty about the "file(INSTALL" pattern can be
> eliminated if somebody familiar with how/why it is implemented will step
> forward to document it for the first time.
> 

Actually, I'm pretty sure that the copying of files will happen at "make 
install" time.
In any case, the alternative I really meant to suggest (which I use in my 
project) is:

file(GLOB USER_DOCS ${CMAKE_SOURCE_SIR}/doc/user/html/*)
install(FILES ${USER_DOCS} DESTINATION ${docdir}/html/user/html)

This doesn't use the undocumented file(INSTALL signature and will certainly work 
as you want.

--Radu


More information about the CMake mailing list