[Insight-users] slightly off-topic: question on CMakeLists

Luis Ibanez luis.ibanez at kitware.com
Sat Aug 26 12:19:50 EDT 2006


Hi Martin,

That's an interesting question.

You probably want to use the FILE command.

You can get the full help of this command by typing

           cmake --help-command FILE

It will return the text below.

You probably want to use the FILE(GLOB...) option,
like:

       FILE(GLOB PLUGINS_DIRECTORIES Plugin* )

followed by the FOREACH() command like

       FOREACH( dir ${PLUGINS_DIRECTORIES} )
            do stuff with ${dir}
       ENDFOREACH(dir)





    Regards,


       Luis



-----------


  FILE
       File manipulation command.

         FILE(WRITE filename "message to write"... )
         FILE(APPEND filename "message to write"... )
         FILE(READ filename variable)
         FILE(GLOB variable [globbing expressions]...)
         FILE(GLOB_RECURSE variable [globbing expressions]...)
         FILE(MAKE_DIRECTORY [directory]...)

       WRITE will write a message into a file called 'filename'.  It
       overwrites the file if it already exists, and creates the file if it
       does not exists.

       APPEND will write a message into a file same as WRITE, except it will
       append it to the end of the file

       NOTE: When using FILE WRITE and FILE APPEND, the produced file cannot
       be used as an input to CMake (CONFIGURE_FILE, source file ...) 
because
       it will lead to infinite loop.  Use CONFIGURE_FILE if you want to
       generate input files to CMake.

       READ will read the content of a file and store it into the variable.

       GLOB will generate a list of all files that match the globbing
       expressions and store it into the variable.  Globbing expressions are
       similar to regular expressions, but much simpler..

       Examples of globbing expressions:

          *.cxx      - match all files with extension cxx
          *.vt?      - match all files with extension vta, vtb, ... vtz
          f[3-5].txt - match files f3.txt, f4.txt, f5.txt

       GLOB_RECURSE will generate similar list as the regular GLOB, 
except it
       will traverse all the subdirectories of the matched directory and
       match the files.

       Example of recursive globbing:

          /dir/*.py  - match all python files /dir and subdirectories

       MAKE_DIRECTORY will create a directory at the specified location



===========================
Martin Urschler wrote:
> hi all,
> 
> I have a question concerning cmake. Perhaps someone reading the list 
> knows this. I have a project with some subdirectories that correspond to 
> sub-modules. One of these sub-modules should be extensible by plugins. 
> Now, since it should not be necessary a priori to know which plugins 
> should be compiled (since by default there are no plugins in the plugins 
> directory), i need a way to check for directories on the file-system 
> using CMake.
> 
> My project (and directory) structure looks like this
> 
> project - submodule1
>         - submodule2
>         - ...
>         - submodule n - plugin 1
>                       - plugin 2
>                       - ...
>                       - plugin n
> 
> By definition, every sub-directory in 'submodule n' should be a plugin 
> (so every directory 'plugin i' contains a CMakeLists.txt file, that gets 
> included by ADD_SUBDIRECTORY in the CMakeLists.txt of 'submodule n'), 
> therefore i need a way to get the directory names (plugin 1 --- plugin 
> n) and for each of these entries i would use an ADD_SUBDIRECTORY 
> commmand. I have no idea how to get the directory names with cmake.
> 
> i hope this is clear, and someone can help me!
> 
> thanks,
> Martin
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
> 
> 




More information about the Insight-users mailing list