[CMake] Complex command
Magnus Therning
magnus at therning.org
Tue Aug 10 10:32:04 EDT 2010
On Fri, Aug 6, 2010 at 20:18, Ryan Pavlik <rpavlik at iastate.edu> wrote:
> On 8/6/10 1:12 PM, Magnus Therning wrote:
>>
>> I was trying to put something like this into a CMake file:
>>
>> add_custom_command( ...
>> COMMAND ...
>> COMMAND ([[ -f foo ]] || ln -sf foo bar); true
>> )
>>
>> But CMake won't have it. Skipping the sub-shell is all right with CMake:
>>
>> add_custom_command( ...
>> COMMAND ...
>> COMMAND [[ -f foo ]] || ln -sf foo bar
>> )
>>
>> But then make doesn't like it if the file doesn't exist, it exits with an
>> error.
>>
>> I put the command in an external shell script instead, but would rather
>> not do
>> that.
>>
>> Any suggestions?
>>
>> /M
>
> You could create/dynamically at configure time write out a cmake file that
> does something to the effect of:
> if(EXISTS foo)
> execute_process(COMMAND ${CMAKE_COMMAND}) -E create_symlink oldfilename
> newfilename)
> endif()
>
> then make your custom command run cmake in script mode on that file. This
> will let you be cross-platform in a good way.
Thanks, that does the trick.
/M
--
Magnus Therning (OpenPGP: 0xAB4DFBA4)
magnus@therning.org Jabber: magnus@therning.org
http://therning.org/magnus identi.ca|twitter: magthe
More information about the CMake
mailing list