[CMake] ADD_CUSTOM_TARGET behavior 2.4 vs 2.6?

Hendrik Sattler post at hendrik-sattler.de
Wed Aug 27 04:55:45 EDT 2008


Zitat von Roland Philippsen <roland.philippsen at gmx.net>:
> It is quite possible that the following problem arises because I
> misunderstant custom targets, but it worked under cmake-2.4 (various
> patch levels, various UNIX-ish operating systems).
>
> Attached is a mini-project which triggers an error due to the way that
>  COMMANDs are parsed by ADD_CUSTOM_TARGET(). My custom command is
> essentially saying "if there is no symlink, create it", like this:
>
> $ test -L foobar || ln -s /Users/rolo/soft/check foobar

ln already does this check, the option -f is required to overwrite an  
existing symlink.

> Under cmake-2.6 at make time, this gets translated to
>
> $ test -L foobar "||" ln -s /Users/rolo/soft/check foobar
>                  ^^^^
> Where the quotes around the or-operator break the command and make
> bails out with "/bin/sh: line 1: test: too many arguments".

Not all environment have shell bahaviour and accept an ||. Usually  
those should be normal commands with arguments, not something that  
needs to be interpreted by a shell.

> Or is there an altogether better way to create symlinks?

"cmake -E" may help you. However note, that not all filesystems can  
actually have symlinks.

HS




More information about the CMake mailing list