[CMake] list subdirectories from a given folder

Julien Dardenne julien.dardenne at technooliq.com
Mon Jul 25 07:50:37 EDT 2011


Hi,

is it possible to list the subdirectories from a given folder?
I use this function but it returns me the file in the current path.

macro(list_subdirectories retval curdir return_relative)

    file(GLOB sub-dir RELATIVE ${curdir} *)
    set(list_of_dirs "")
    foreach(dir ${sub-dir})
      if(IS_DIRECTORY ${curdir}/${dir})
        if (${return_relative})
          set(list_of_dirs ${list_of_dirs} ${dir})
        else()
          set(list_of_dirs ${list_of_dirs} ${curdir}/${dir})
        endif()
      endif()
    endforeach()
    set(${retval} ${list_of_dirs})
endmacro()

I can notuse the FILE() with a different path than the current path.

Thank you for your help

-- 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110725/71087dd4/attachment.htm>


More information about the CMake mailing list