[CMake] Getting add_custom_command to work with multiple outputs

Roger Leigh rleigh at codelibre.net
Sat Aug 3 18:22:09 EDT 2013


On Sat, Aug 03, 2013 at 11:20:53AM +0100, Roger Leigh wrote:
> 
> I am trying to cmake-ify a build where the bulk of the sources are
> generated.  I have a tool (python script) which reads a set of
> templates and then generates many source and header files (~250).
> I don't know in advance what the source files will be--it's
> dependent upon the templates.  I've done this:
> 
> set(GEN_DIR gen)
> set(GENERATOR path/to/script)
> set(TEMPLATES template1 template2 template3)
> 
> execute_process(COMMAND ${GENERATOR} -d -o ${GEN_DIR} ${TEMPLATES}
>   OUTPUT_VARIABLE GENERATED_SOURCES)

string(REPLACE "\n" ";" GENERATED_SOURCES ${GENERATED_SOURCES})

seems to be the missing part here, which turns the multiline
string into a list of strings.  I was expecting this to behave
like make's $(shell ...) but the additional transform step is
no big deal.  All seems to be working well now!


Regards,
Roger

-- 
  .''`.  Roger Leigh
 : :' :  Debian GNU/Linux             http://people.debian.org/~rleigh/
 `. `'   Printing on GNU/Linux?       http://gutenprint.sourceforge.net/
   `-    GPG Public Key: 0x25BFB848   Please GPG sign your mail.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130803/bf8758fd/attachment.pgp>


More information about the CMake mailing list