macro(SubDirList curdir result) file(GLOB children RELATIVE ${curdir} ${curdir}/*) foreach(child ${children}) if(IS_DIRECTORY ${curdir}/${child}) list(APPEND ${result} ${child}) endif() endforeach() endmacro() macro(SubDirListRecurse curdir basedir result) file(GLOB children RELATIVE ${curdir} ${curdir}/*) foreach(child ${children}) if(IS_DIRECTORY ${curdir}/${child}) if(${child} STREQUAL ${basedir}) list(APPEND ${result} ${child}) else() file(RELATIVE_PATH relpath ${basedir} ${curdir}/${child}) list(APPEND ${result} ${relpath}) SubDirListRecurse(${curdir}/${child} ${basedir} ${result}) endif() endif() endforeach() endmacro()