[CMake] Undocumented magic required for installing globbed files
Radu Serban
radu at llnl.gov
Wed Jan 31 20:06:41 EST 2007
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]
> Furthermore, I have no clue why the $ in ${USER_DOCS} has to be escaped,
> but
> the other "$" within the file commands do not. So all this seems very much
> like magic to me in the absence of documentation.
>
My guess: If the last $ were not escaped, cmake would attempt to expand it to
its value in the CMakeLists.txt script (where it is not defined). I assume that
the INSTALL CODE signature generates a CMake script on the fly which in your
case will be:
file(GLOB USER_DOCS path_to_sources/doc/user/html/*)
file(INSTALL DESTINATION path_to_docdir/html/user/html
TYPE FILE FILES ${USER_DOCS})
where path_to_sources is whatever CMAKE_SOURCE_DIR was in your CMakeLists.txt
(similarly path_to_docdir is whatever ${docdir} was there). Now, if you were to
run this script, USER_DOCS will contain the proper list of files.
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})
--Radu
More information about the CMake
mailing list