[CMake] unexpected INSTALL problems

Michael Hertling mhertling at online.de
Wed Jun 15 15:03:14 EDT 2011


On 06/15/2011 01:58 PM, Dominik Szczerba wrote:
> I am trying to copy all libboost* stuff from /usr/lib to
> CMAKE_INSTALL_PREFIX just as most users would guess:
> 
> INSTALL(DIRECTORY ${BOOST_RUNTIME_DIR}/ DESTINATION
> ${CMAKE_INSTALL_PREFIX}/bin FILES_MATCHING .......)
> 
> Whatever I specify for matching I always get half of my system copied
> instead of the requested files. E.g.

The FILES_MATCHING option of INSTALL(DIRECTORY ...) applies to files
only, i.e. with the above-noted line and BOOST_RUNTIME_DIR==/usr/lib,
you'll get the *whole* directory structure under /usr/lib including
symlinks to directories, but only files and symlinks to files which
match PATTERN/REGEX, copied to DESTINATION. Supposedly, this is
what you denote "half of my system copied".

> PATTERN "libboost*.so" does absolutely nothing and REGEX
> "libboost.*\.so.*$" complains about the slash, when removed does
> nothing either. As a result all content is always copied.

The REGEX should read "libboost.*\\.so.*$" or "libboost.*\\.so.*\$",
and what do you mean exactly with "does absolutely nothing" and "does
nothing either"? Nothing copied at all or just directories but no files?

On my system,

INSTALL(DIRECTORY /usr/lib/ DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
FILES_MATCHING PATTERN "libboost*.so")

as well as

INSTALL(DIRECTORY /usr/lib/ DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
FILES_MATCHING REGEX "libboost.*\\.so.*\$")

yield the results expected from the documentation, i.e. the whole but
shallow directory structure under /usr/lib and the libboost*.so or
libboost.*\\.so.*\$ files and symlinks, respectively; check with
find <CMAKE_INSTALL_PREFIX>/bin -name "*.so" -o -name "*.so.*".

> Interestingly and confusingly, the same thing (only used PATTERN)
> works for e.g. "*.h". What is special here?
> 
> Are there any examples how to use this functionality? Both the
> documentation and the FAQ are not very comprehensive in this matter.

Obviously, your approach to copy the Boost libraries from /usr/lib
using INSTALL(DIRECTORY /usr/lib/ ... FILES_MATCHING ...) is not
appropriate. Instead, you might use a suitably configured CMake
script which runs FILE(GLOB ...) or FILE(GLOB_RECURSE ...) and
FILE(INSTALL|COPY ...) and is invoked by INSTALL(SCRIPT ...).
In this way, you'll have your project's Boost installation
done in one go during the project's installation.

'hope that helps.

Regards,

Michael


More information about the CMake mailing list