[CMake] gathering directory names in cmake
Lee Butler
iraytrace at gmail.com
Thu Jun 23 11:13:44 EDT 2016
Alas, this has no effect. Consider the following shell script:
-----------------------------------------------------------------
#!/bin/sh
if [ -d attempt ] ; then rm -rf attempt ; fi
mkdir attempt
cd attempt
for d in src src/app src/plugins/one ; do
mkdir -p $d/xyz
touch $d/xyz/one.txt
touch $d/xyz/two.txt
done
PATTERN="\${CMAKE_SOURCE_DIR}/src/*xyz/"
cat > CMakeLists.txt <<EOF
project(gatherdir)
cmake_minimum_required(VERSION 3.0)
file(GLOB_RECURSE xyzDirs "${PATTERN}")
message(STATUS "____look for ${PATTERN}")
message(STATUS "____xyzDirs: \${xyzDirs}")
EOF
cmake .
---------------------------------------------------------------------
I cannot find any string that PATTERN can be which will cause xyzDirs to
have the names of the three "xyz" directories. I could search for
*xyz/* but now I have to edit the list to remove file names, remove
doubles from the result, etc.
On 6/22/2016 10:52 AM, cmake-request at cmake.org wrote:
> On Mon, Jun 20, 2016 at 8:47 PM, Lee Butler<iraytrace at gmail.com> wrote:
>
>> >I have a source tree which contains multiple directories each of which has
>> >a subdirectory called "xyz". I want to create a target that creates a zip
>> >file with each of the xyz directories. So if the source tree looks like
>> > src
>> > src/xyz
>> >src/application
>> >src/application/xyz
>> >src/plugins/one/xyz
>> >
>> >I want to end up with a zip file containing:
>> > src/xyz/*
>> >src/application/xyz/*
>> >src/plugins/one/xyz/*
>> >
>> >On unix I could just generate the list of these directories with:
>> > find src -type d -name test -print
>> >alas, I need a cross-platform way to do this.
>> >
>> >I tried:
>> > file(GLOB_RECURSE XYZFILES "${CMAKE_SOURCE_DIR}/src/*xyz)
>> >and got nothing.
>> >
>> >At the moment, it looks like I cannot wildcard any portion of the
>> >directory path. The following:
>> > file(GLOB_RECURSE XYZFILES "${CMAKE_SOURCE_DIR}/src/*xyz*")
>> >
> what about adding a backslash at end of expression ?
> file(GLOB_RECURSE XYZFILES "${CMAKE_SOURCE_DIR}/src/*xyz/")
>
>
> seems to only produce files which have xyz in their name.
>> >
>> >Lee
>> >--
>> >
>> -- Regards, Rashad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160623/94c7b95f/attachment.html>
More information about the CMake
mailing list