[CMake] How to iterate over a set of directories containing projects?

Tyler Roscoe tyler at cryptio.net
Mon Jul 13 10:43:11 EDT 2009


On Mon, Jul 13, 2009 at 10:56:54AM +0200, Peter wrote:
>     add_executable( binning binning.cpp )
>     target_link_libraries( binning ${Boost_LIBRARIES} )
> 
> where binning would be the name of the sample as well as the name of the 
> directory. I'm wondering if there would be a way to avoid authoring 
> these similar CMakeLists.txt files and instead somehow iterate over all 
> the projects in the CMakeLists.txt file which is one level higher in the 
> hierarchy?

foreach (proj proj1 proj2 projN)
    add_executable (${proj} ${proj}.cpp)
    ...
endforeach ()

Like that?

tyler


More information about the CMake mailing list