[CMake] [EXTERNAL] Re: execute_process appending redirected output

Michael Hertling mhertling at online.de
Fri Dec 30 22:05:27 EST 2011


On 12/28/2011 05:39 PM, Belcourt, K. Noel wrote:
> Hi Aaron,
> 
> On Dec 27, 2011, at 11:04 PM, Aaron Ten Clay wrote:
> 
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> On 12/27/11 16:16, Belcourt, Kenneth wrote:
>>> I'm trying to get CMake to execute this command
>>>
>>> INSTALL(CODE
>>> "EXECUTE_PROCESS (COMMAND cat
>> \"${CMAKE_CURRENT_SOURCE_DIR}/onejar_classpath.txt >>
>> ${CMAKE_INSTALL_PREFIX}/onejar/boot-manifest.mf\")"
>>> )
>>>
>>> but this doesn't work, here's the error I get when I run the install.
>>>
>>> I've checked that both the source and target files exist and are
>> writable. Any ideas on how to get this to work?
>>>
>> It looks as thought you might be missing some escaped double-quotes.
> 
> I've tried quite a few quoting permutations, none work.
> 
>> INSTALL(CODE
>> "EXECUTE_PROCESS (COMMAND cat
>> \"${CMAKE_CURRENT_SOURCE_DIR}/onejar_classpath.txt\" >>
>> \"${CMAKE_INSTALL_PREFIX}/onejar/boot-manifest.mf\")"
>> )
> 
> Unfortunately this doesn't work.

AFAIK, this is because EXECUTE_PROCESS() doesn't fork a shell to run
the COMMANDs, so the redirection operators like ">>" are meaningless.

>> It's also worth noting that this is not a cross-platform command.
> 
> Yup, we're a unix only shop.

Then use one of the premier *nix tools:

INSTALL(CODE "EXECUTE_PROCESS(COMMAND sh -c \"cat
\\\"${CMAKE_CURRENT_SOURCE_DIR}/onejar_classpath.txt\\\" >>
\\\"${CMAKE_INSTALL_PREFIX}/onejar/boot-manifest.mf\\\"\")")

Regards,

Michael

>> Maybe
>> look at file(READ ...) followed by file(APPEND ...)?
> 
> Looks promising, I'll check this out.
> 
> Thanks for the help Aaron.
> 
> -- Noel


More information about the CMake mailing list