[Cmake] Set a variable to a list of filenames that match a
pattern
Andy Cedilnik
andy . cedilnik at kitware . com
23 Jul 2003 11:42:02 -0400
Hi David,
Without specifying the directory, it will pick your current source
directory. So,
FILE(GLOB var "${CMAKE_CURRENT_SOURCE_DIR}/*.cxx")
and
FILE(GLOB var "*.cxx")
is the same.
I just do not think it is a good think to refer to things relatively.
So, you better use full path to things.
Why would you need relative paths anyway?
Andy
On Wed, 2003-07-23 at 11:34, Karr, David wrote:
> It would be slightly better for my purposes if there were a
> way to use this *without* inserting the .../foo/ in front of
> every file name; that way I wouldn't have to run CMake every
> time I made a temporary copy of my project under a new directory,
> but only when the actual contents of the build changed.
> Would it be possible to support a syntax like this:
>
> FILE(GLOB_RECURSE var "*.cxx")
>
> which implies that the recursive search starts in
> ${CMAKE_CURRENT_SOURCE_DIR} but that the output names the files
> using their paths relative to ${CMAKE_CURRENT_SOURCE_DIR}
> instead of absolute paths; the result would be
>
> var = a.cxx b.cxx bar/c.cxx bar/d.cxx
>
>
> Also, I wonder if I could write:
>
> FILE(GLOB var2 "bar/*.cxx")
>
> with the result that
>
> var2 = bar/c.cxx bar/d.cxx
>
> This is useful to me because I want to do some things with
> the files foo/bar/*.cxx that I don't do with the files
> foo/*.cxx, for example I want to put them in their own
> source group (this apparently requires an extension to
> to SOURCE_GROUP, but I discussed this in a different message).
>
>
> I suspect the implementation of these features could be
> lifted from my hack to cmSetCommand.cxx, with appropriate
> changes to use the newer "glob" function. For that matter
> it was a very easy thing to add in the first place, at
> least in the way I tried it.