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

Alex Turbov i.zaufi at gmail.com
Tue Apr 11 13:15:32 EDT 2017


Hi,

here is my 5 cents...

On Tue, Apr 11, 2017 at 10:52 PM, Brad King <brad.king at kitware.com> wrote:

> 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.
>
+1

>
> > 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?
>
+1

doesn't looks like a good idea... also if someone (re)moved/renamed a file
intentionally and forget to update CMakeLists.txt (or just rerun `make`
which executes `cmake`)


> 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.
>

my personal practice completely the opposite:
in my CMakeLists I have a custom target to generate a source file from the
project specific template, so I just use CLI to generate a new file like:

    $ make new-class name=BlahBlah ns=Vendor::Project subdir=some/dir

and then go to corresponding CMakeLists.txt and add the generated source(s)
to a target
and thanks to `cmake` missed files are reported at configuration time


> > 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
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensou
> rce/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake-developers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20170412/3d219bd8/attachment.html>


More information about the cmake-developers mailing list