[cmake-developers] Feature suggestion: auto-create missing files
Petr Kmoch
petr.kmoch at gmail.com
Tue Apr 11 11:41:34 EDT 2017
Hi all,
I'd like to implement a feature for CMake which I miss there, and I'd like
to get approval for the idea & design before proceeding.
Currently, adding a new source file to a CMake-controlled project means
doing two things: creating the file on disk, and adding it to the relevant
CMakeList add_library() or add_executable() call. To me, this feels like
one operation too many. As a result, nearly all of my personal projects
using CMake end up with some sort of wrapper/pre-call which processes file
lists and creates any missing files before the list is passed to the
add_*() call.
I'd like this behaviour to become an option in CMake itself: allow the user
to switch from current behaviour of "error out if source file is not found"
to "create empty source file if it's not found." I've prototyped the
creation itself and it works, but I'd like to discuss the interface for
enabling this functionality. I was considering an inherited boolean
property on individual source file level, plus a variable which would
pre-initialise the property if set. This way, projects could control it on
the finest scope possible (or on broader scopes, since the prorepty would
recurse to directory & global level), while still providing a simple way to
set it centrally.
As far as naming is concerned, I was considering CREATE_SOURCES_IF_MISSING
for the property, and CMAKE_CREATE_SOURCES_IF_MISSING for the variable.
Is this something that would be acceptable into CMake? Any comments?
Thanks.
Petr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20170411/a26696f9/attachment.html>
More information about the cmake-developers
mailing list