[CMake] gathering directory names in cmake

Cfyz cfyzium at gmail.com
Fri Jun 24 14:04:21 EDT 2016


> I have a source tree which contains multiple directories each of
> which has a subdirectory called "xyz". I want to create a target
> that creates a zip file with each of the xyz directories.

You can filter the file paths with a few CMake script lines:

file(GLOB_RECURSE FILES "./*")
foreach(FILE ${FILES})
    if(FILE MATCHES ".*/xyz/.*")
        list(APPEND XYZ_FILES ${FILE})
    endif()
endforeach()

Now XYZ_FILES contains a list of files with /xyz/ subdirectory somewhere in
their path.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160624/829f9f19/attachment.html>


More information about the CMake mailing list