[CMake] How to exclude top level directory from install(DIRECTORY)

Ralf Habacker ralf.habacker at freenet.de
Tue Sep 1 08:47:25 EDT 2015


Hi,

in a cmake project I have a directory structure like shown below:

source/
   subdir1/
         subdir2/
             file
   subdir2/
             file

which should be installed partially.

In one install call I need to exclude subdir1/subdir2 which could be
performed with the following install command.

install(DIRECTORY source DESTINATION . REGEX subdir1/subdir2 EXCLUDE)

but it looks impossible to exclude the top level subdir2. I tried
several variations.

install(DIRECTORY source DESTINATION . REGEX subdir2 EXCLUDE) ->
excludes all directory named 'subdir2'
install(DIRECTORY source DESTINATION . REGEX /subdir2 EXCLUDE) - does
not match any subdir
install(DIRECTORY source DESTINATION . REGEX ./subdir2 EXCLUDE) - does
not match any subdir
install(DIRECTORY source DESTINATION . REGEX ^subdir2 EXCLUDE) - does
not match any subdir
install(DIRECTORY source DESTINATION . REGEX ^/subdir2 EXCLUDE) - does
not match any subdir
install(DIRECTORY source DESTINATION . REGEX ^./subdir2 EXCLUDE) - does
not match any subdir

How to proceed ?

Regards
Ralf






More information about the CMake mailing list