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

Belcourt, K. Noel kbelco at sandia.gov
Sat Dec 31 00:29:32 EST 2011


On Dec 30, 2011, at 8:05 PM, Michael Hertling wrote:

> 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\\\"\")")

Eek, that's a lot of quoting.  I found a workaround but thanks for  
this, I may use it if opportunity arises in the future.  Perhaps this:

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

could be entered into the documentation somewhere as this is important  
to know.  Thanks for the help Michael.

-- Noel




More information about the CMake mailing list