Proposal for TREE argument in source_group command
Hello cmake-dev community,
I've created small proposal for new argument in source_group command. The new argument would be 'TREE'.
The goal is to provide more user-friendly syntax for creating source groups which matches actual directories tree where user have his source files.
It's syntax looks like this
source_group(TREE ${root} FILES ${source_files})
Example: Lets say that user have source files organized in such way:
${CMAKE_CURRENT_LIST_DIR}/sources/src/main.cpp
${CMAKE_CURRENT_LIST_DIR}/sources/src/foo/bar.cpp
${CMAKE_CURRENT_LIST_DIR}/sources/src/foo/baz.cpp
${CMAKE_CURRENT_LIST_DIR}/sources/src/foo/fooer/barer.cpp
${CMAKE_CURRENT_LIST_DIR}/sources/inc/foo/bar.hpp
${CMAKE_CURRENT_LIST_DIR}/sources/inc/foo/baz.hpp
${CMAKE_CURRENT_LIST_DIR}/sources/inc/foo/fooer/barer.hpp
and cmake variables set like this
set(root ${CMAKE_CURRENT_LIST_DIR}/sources)
set(inc_files ${root}/inc/foo/bar.hpp
${root}/inc/foo/baz.hpp
${root}/inc/foo/fooer/barer.hpp)
set(src_files ${root}/src/main.cpp
${root}/src/foo/bar.cpp
${root}/src/foo/baz.cpp
${root}/src/foo/fooer/barer.cpp)
and now, when user'll call source_group like this
source_group(TREE ${root} FILES ${src_files} ${inc_files})
cmake'll create such source groups inc inc/foo/ inc/foo/fooer src src/foo src/foo/fooer
which'll contain files respectively to its location on filesystem.
Of course my implementation is backward-compatybile.
Additionally, I've created cmCommandArgumentsParser and cmCommandArguments classes which helps dealing with command arguments.
It's not tested yet. I decided to send this mail first to get feedback if it's the thing. If you'll like this, I'll write tests apply reviews feedback and update documentation.
So if anyone have something to point, add, reject feel free (: