[CMake] file(GLOB oddities
Ryan Pavlik
rpavlik at iastate.edu
Fri Aug 27 12:26:26 EDT 2010
On 8/27/10 9:17 AM, Kevin Fitch wrote:
> I am running into an issue that causing me a bit of trouble:
> file(GLOB globOutput test)
> returns the absolute path to test (assuming there is a test directory
> under my current dir). Whereas
> file(GLOB globOutput .)
> returns an empty string. This is particularly annoying because
> file(GLOB globOutput non-existant-dir)
> also returns an empty string.
>
> And the follow on to this is that the documentation for IS_DIRECTORY,
> EXISTS, ... says:
> Behavior is well-defined only for full paths.
> What exactly does that mean? Just to clarify, is a "full path" an
> absolute path (e.g. as determined by IS_ABSOLUTE)? The only way I have
> found to get an absolute path is to use file(GLOB which works for
> anything other than .
>
> Kevin Fitch
>
I'd suggest not using file(GLOB in general, and especially for this
purpose or for creating lists of source files.
If you want to know the directories involved in the build, use:
* CMAKE_SOURCE_DIR
o http://cmake.org/cmake/help/cmake-2-8-docs.html#variable:CMAKE_SOURCE_DIR
* CMAKE_BINARY_DIR
o http://cmake.org/cmake/help/cmake-2-8-docs.html#variable:CMAKE_BINARY_DIR
* CMAKE_CURRENT_SOURCE_DIR
o http://cmake.org/cmake/help/cmake-2-8-docs.html#variable:CMAKE_CURRENT_SOURCE_DIR
* CMAKE_CURRENT_BINARY_DIR
o http://cmake.org/cmake/help/cmake-2-8-docs.html#variable:CMAKE_CURRENT_BINARY_DIR
To get an absolute path, do the following:
get_filename_component(outputvar "somedir" ABSOLUTE)
http://cmake.org/cmake/help/cmake-2-8-docs.html#command:get_filename_component
Hope this helps!
Ryan
--
Ryan Pavlik
Human-Computer Interaction Graduate Student
Virtual Reality Applications Center
Iowa State University
http://academic.cleardefinition.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100827/587b80bc/attachment.htm>
More information about the CMake
mailing list