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

Karthik Krishnan Karthik.Krishnan at kitware.com
Sat Aug 26 14:48:57 EDT 2006


Use a combination of FILE( GLOB .. ) and STRING( REGEX ... )

The following lines should do what you want :

FILE ( GLOB CMAKELISTFILES "${MODULEDIR}/*/CMakeLists.txt")
FOREACH( CMAKELISTFILE ${CMAKELISTFILES} )
  STRING( REGEX MATCH ".*/" PLUGINDIR ${CMAKELISTFILE})
  MESSAGE("--> ${PLUGINDIR}")
ENDFOREACH( CMAKELISTSFILE )


-karthik


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