[CMake] process file contents
Magnus Therning
magnus at therning.org
Wed May 12 14:27:46 EDT 2010
On 12/05/10 19:07, James C. Sutherland wrote:
>
> On May 12, 2010, at 11:43 AM, James C. Sutherland wrote:
>
>> I would like to execute a command like:
>> getrates -n < myFileName
>>
>> I am trying to add this so it is processed after the target "getrates"
>> is built
>>
>> set( infile ${CMAKE_CURRENT_BINARY_DIR}/myFileName )
>> add_custom_command( TARGET getrates
>> POST_BUILD
>> COMMAND "${CMAKE_CURRENT_BINARY_DIR}/getrates" " -n < ${infile}"
>> WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
>> VERBATIM
>> )
>>
>>
>> This does not seem to work, however. CMake doesn't handle the "<"
>> properly. Any ideas about how to stream the contents of a file?
>>
>> Thanks,
>>
>> James
>
> Got it. It looks like removing the "" from the arguments does the job, i.e.
>
> add_custom_command( TARGET getrates
> POST_BUILD
> COMMAND ${CMAKE_CURRENT_BINARY_DIR}/getrates -n < ${infile}
> WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
> VERBATIM
> )
Yes, I learned this the hard way too. Basically it seems that an argument in
ticks ("") will be passed in as a single argument (handy when arguments
contain spaces). That means that the equivalent shell command line was
% getrates " -n < infile"
i.e. a single argument to the `getrates` command.
/M
--
Magnus Therning (OpenPGP: 0xAB4DFBA4)
magnus@therning.org Jabber: magnus@therning.org
http://therning.org/magnus identi.ca|twitter: magthe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100512/ce393f98/attachment.pgp>
More information about the CMake
mailing list