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

Dan Kegel dank at kegel.com
Wed Aug 5 17:57:42 EDT 2015


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


More information about the CMake mailing list