Discussion:
[CMake] File globbing with relative path
jbd
2006-06-26 17:16:50 UTC
Permalink
Hello everybody,

Sorry for this question, i didn't find a solution on the web or even
in the 2.2 version book, but i'm quite a beginner regarding CMake =)

I'd like to retrieve the relative path of a list of files. For example :
FILE (GLOB SRC_FILES Test*.cxx Test*.cpp Test*.c)

Here, SRC_FILES will contain all the file i requested with their full path.
Is their a clean way to retrieve a list containing only the relative path
of those files ?

I can do that :
FOREACH(myfile ${SRC_FILES})
FILE(RELATIVE_PATH TMP ${CMAKE_CURRENT_SOURCE_DIR} ${myfile})
# here TMP contain the relative path
ENDFOREACH(myfile ${SRC_FILES})

But i don't know how to rebuild a new list, or to replace the first one.

Any idea ?

Thank you !
Jan Woetzel
2006-06-26 17:25:45 UTC
Permalink
Post by jbd
FILE (GLOB SRC_FILES Test*.cxx Test*.cpp Test*.c)
See the RELATIVE option

FILE(GLOB variable [RELATIVE path] [globbing expressions]...)

Jan.
--
Dipl.-Ing. Jan Woetzel
--------------------------------------------------
University of Kiel
Institute of Computer Science and Applied Mathematics
Hermann-Rodewald-Str. 3 [room 310]
24098 Kiel/Germany
--------------------------------------------------
Phone +49-431-880-4477
Fax +49-431-880-4054
Mob. +49-179-2937346
--------------------------------------------------
Url www.mip.informatik.uni-kiel.de/~jw
Email ***@mip.informatik.uni-kiel.de
jbd
2006-06-26 17:35:46 UTC
Permalink
Post by Jan Woetzel
See the RELATIVE option
FILE(GLOB variable [RELATIVE path] [globbing expressions]...)
Jan.
Thank you for suck a quick answer, but i can't figure out to make that
work. I'm running CMake 2.2, and cmake --help-command FILE show me :

FILE(GLOB variable [globbing expressions]...)
and
FILE(RELATIVE_PATH variable directory file)

which seems to be two different things for FILE.

Sorry, but i'm sure i misunderstanding something, so i tried :
FILE (GLOB SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} Test*.cpp)
but it doesn't work.

Thanks again for your help
Jan Woetzel
2006-06-26 17:48:19 UTC
Permalink
Post by jbd
FILE (GLOB SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} Test*.cpp)
but it doesn't work.
This works here with CMake 2.4.2:

FILE(GLOB FOO RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.c*)
MESSAGE("DBG FOO=${FOO}")

Jan.
jbd
2006-06-26 23:06:45 UTC
Permalink
Indeed, it work well with 2.4.2. I was running 2.2. Thank you for your
patience !

Continue reading on narkive:
Loading...