[CMake] passing a list of files from c source code to cmake

J Decker d3ck0r at gmail.com
Wed Aug 5 19:18:43 EDT 2015


a combination of the above..

---- somefile.h
"file1", "file2", "file3"

---- somefile.c
...
const char *files[] = {
#include "somefile.h"
};

would be easiest for cmake to parse the .h... I would think...

otherwise no; might be easier to maintain the list in the cmake and stuff
it into the C using configure_file()


On Wed, Aug 5, 2015 at 2:57 PM, Dan Kegel <dank at kegel.com> wrote:

> I don't think it needs to be a custom command, you just do it inline.
> See e.g.
> FILE(STRINGS, ...)
> http://www.cmake.org/cmake/help/v3.0/command/file.html
> or FILE(READ, ...)
> http://www.cmake.org/pipermail/cmake/2007-May/014222.html
>
> There are several gotchas related to quoting.  Ping the list if you
> run into trouble.
> - Dan
>
>
> On Wed, Aug 5, 2015 at 4:27 PM, Owen Alanzo Hogarth <gurenchan at gmail.com>
> wrote:
> > do you have any example of that?
> >
> > Would it be a custom command? I haven't seen anything like this being
> done
> > before?
> >
> > On Thu, Aug 6, 2015 at 5:08 AM, Dan Kegel <dank at kegel.com> wrote:
> >>
> >> On Wed, Aug 5, 2015 at 3:17 PM, Owen Alanzo Hogarth <
> gurenchan at gmail.com>
> >> wrote:
> >> > I can put those in some type of array in my c source code. Now is it
> >> > possible to send that list back to cmake at build time so that it can
> >> > copy
> >> > those files to the binary tree on each build?
> >>
> >> You can write a script that parses the C source file (should be easy if
> >> you put the array body in a .h file with no decoration) and pulls
> >> it into a CMake list.
> >
> >
> --
>
> 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/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150805/10ef9270/attachment-0001.html>


More information about the CMake mailing list