[cmake-developers] Feature suggestion: auto-create missing files

Brad King brad.king at kitware.com
Tue Apr 11 11:52:52 EDT 2017


On 04/11/2017 11:41 AM, Petr Kmoch wrote:
> 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.

I view this as a matching pair with an implicit sanity check.

> switch from current behaviour of "error out if source file is not found"
> to "create empty source file if it's not found."

So a typo in the `CMakeLists.txt` file leads to silent creation of a
source file instead of an error message?

That said, I can see how the proposed feature might be useful when
iteratively developing in an IDE.  Add the file to `CMakeLists.txt`,
reconfigure, and open the new (now existing) file to edit in the IDE.

> Is this something that would be acceptable into CMake? Any comments?

I'd like to hear more opinions from others before considering it
upstream.  It feels like a pretty personal workflow right now, and
can be implemented in CMake code already (perhaps with the `SOURCES`
target property to avoid separate lists).

If this were to be done I'd first like to see a policy introduced to
get rid of the magic extension guessing we do now.  Without knowing
the full file name with confidence we wouldn't be able to create it.

-Brad



More information about the cmake-developers mailing list