[CMake] unexpected INSTALL problems

Michael Hertling mhertling at online.de
Wed Jun 15 23:53:33 EDT 2011


On 06/15/2011 09:52 PM, Dominik Szczerba wrote:
>> 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".
> 
> I am sure at some point I saw all the files copied over (including
> e.g. *.sh files) but I can not reproduce it any longer. Currently it
> seems you are right here. INSTALL(DIRECTORY ... NO_RECURSION) would be
> a straight forward extension.

IMO, a DIRECTORIES_MATCHING flag - analogous to FILES_MATCHING - or
negated REGEX matching, e.g. !REGEX or NOT REGEX, in connection with
the EXCLUDE flag might fit better to INSTALL(DIRECTORY ...)'s intent.

>> The REGEX should read "libboost.*\\.so.*$" or "libboost.*\\.so.*\$",
>> and what do you mean exactly with "does absolutely nothing" and "does
> 
> Why would I need double escaping? I did not see any mention of it in
> any related documentation/wiki. But even then, it does not work,
> please see below for details.

Probably, it's the same as in [1], i.e. CMake parser + regex engine.

>> 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
> 
> The former copies the whole dir structure and matching files only (in
> the top dir). Works as in docs but is not what I need. The latter does
> not copy ANYTHING, i.e. the result is an empty folder. I still wonder
> why.

On my system, the following project copies the directories under
/usr/lib and any libboost.*\.so.* file therein to /dev/shm/usr;
could you check on your system and report the results?

CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
PROJECT(INSTALL NONE)
SET(CMAKE_INSTALL_PREFIX /dev/shm/usr)
INSTALL(DIRECTORY /usr/lib/
    DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
    FILES_MATCHING REGEX "libboost.*\\.so.*\$")

>> 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.
> 
> The idea to use INSTALL(SCRIPT...) is an interesting workaround, will
> try. Still, an option to disable recursion with INSTALL(DIRECTORY...)
> would be much cleaner.

AFAIK, it's the point of INSTALL(DIRECTORY ...) to work recursively.
Actually, one uses it to copy directory structures from a project's
source/build tree, so one has tight control of what is to be copied.
Using it to copy project-external structures like parts of /usr/lib
is quite unusual and will most certainly cause problems of the kind
you've seen. That's the reason why I recommend to do such jobs with
specifically tailored scripts triggered by INSTALL(SCRIPT ...).

Regards,

Michael

[1] http://www.mail-archive.com/cmake@cmake.org/msg30659.html


More information about the CMake mailing list