[CMake] Help with source_group and regex

Petr Kmoch petr.kmoch at gmail.com
Tue Jun 19 12:03:11 EDT 2012


Hi Joseph.

The following should work:

FOREACH(dir dir1 dir2)
 SOURCE_GROUP(${dir}\\inc REGULAR_EXPRESSION "${dir}/.*\\.h")
 SOURCE_GROUP(${dir}\\src REGULAR_EXPRESSION "${dir}/.*\\.cpp")
 SOURCE_GROUP(${dir}\\inl REGULAR_EXPRESSION "${dir}/.*\\.inl")
ENDFOREACH()

Petr

On Tue, Jun 19, 2012 at 5:05 PM, Joseph Henry <poundpragma at gmail.com> wrote:
> Hi,
>
> My scenario is that I have many source files in different directories that
> are all going into the same lib.
>
> dir1/file1.h
> dir1/file1.cpp
> dir1/file1.inl
>
> dir2/file2.h
> dir2/file2.cpp
> dir2/file2.inl
>
> These files are listed in a variable SOURCES.
>
> what I want to do is add them to a source group using the directory as the
> base group and then all .h files in group "inc", .cpp files in group "src"
> and .inl files in group "inl".
>
> So to reiterate:
> SOURCES=dir1/file1.h;dir1/file1.cpp;dir1/file1.inl;dir2/file2.h;dir2/file2.cpp;dir2/file2.inl
>
> and I want the source groups to look like this:
>
> dir1/inc/file1.h
> dir1/src/file1.cpp
> ....
> dir2/inl/file2.inl
>
> Any help on this would be greatly appreciated.
>
>
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake


More information about the CMake mailing list