[CMake] sigil ($) in add custom command

j s j.s4403 at gmail.com
Mon Apr 28 13:43:59 EDT 2014


The i
On Mon, Apr 28, 2014 at 11:44 AM, J Decker <d3ck0r at gmail.com> wrote:
> foreach( file ${files} )
> ADD_CUSTOM_COMMAND(
> ...
> COMMAND cpp -P -CC -DDPI_EXTERN ${file} >>
> ${FILEEXTERN}.tmp \; done'
> )
>

Unfortunately that doesn't work for me since all of the individual
files are writing to the same file.  The output file is
non-deterministic in content and subject to race conditions.  I would
need a foreach loop in the custom command itself to ensure that the
files are properly ordered.  Is anything like this possible?

ADD_CUSTOM_COMMAND(
OUTPUT ${FILEEXTERN}.tmp
FOREACH(I ${FILES})
COMMAND cpp -P -CC -DDPI_EXTERN ${I} >> ${FILEEXTERN}.tmp \; done'
ENDFOREACH(I ${FILES})
DEPENDS ${FILES}
)

Regards,

Juan








>
>
>
> On Mon, Apr 28, 2014 at 9:05 AM, j s <j.s4403 at gmail.com> wrote:
>>
>> Through trial and error, I've found that I can do the following to
>> escape a variable in a custom command.
>>
>> ADD_CUSTOM_COMMAND(
>> ...
>> COMMAND bash -c 'for i in ${FILES}\; do cpp -P -CC -DDPI_EXTERN $$i >>
>> ${FILEEXTERN}.tmp \; done'
>>
>> ...
>> )
>>
>>
>> Is this the proper way to escape a variable that needs to make to the
>> shell command level?  I'm assuming this would only work through a Unix
>> Makefile?  Is there an alternative to iterating over a variable in a
>> custom command?
>> --
>>
>> 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://www.cmake.org/mailman/listinfo/cmake
>
>


More information about the CMake mailing list