[CMake] Feature suggestion: cmake -E do_nothing -- useful to simulate configuration-specific commands

Anders Lindgren andlind at gmail.com
Thu Jun 19 14:31:51 EDT 2014


Hi David!

I have been playing around with "cmake -E echo". The problem is that when
using generator expressions, you can't apply them to the entire command
line (they must be applied to one argument at a time).

For example, if we would use the expression generator on the command we
could generate "copy" in some cases and "echo" in others. That would give
us:

    cmake -E copy from.txt to.txt
    cmake -E echo from.txt to.txt

Clearly, this is not what we want (as it would print "from.txt to.txt").
Wrapping each argument in an generator expression would give us:

   cmake -E copy from.txt to.txt
   cmake -E echo "" ""

This works (with the minor side effect that it prints an empty line).
However, wrapping each argument in an expression generator would be more
trouble than it's worth (and probably be 100% unmaintainable).

Since it would be almost trivial to implement "cmake -E do_nothing" (that
silently ignores arguments given to it), I don't see any reason any we
shouldn't. In the mean time, I will replace "cmake" with "true" and "REM"
under UNIX under Windows, respectively.

While on the subject, another trick it to avoid using COMMENT (as it would
be printed in all configurations) and instead use cmake -E echo "The
message" and apply the same constant generator trick on "cmake" to mute it
for the configurations where the command isn't used.

Of course, it would be even better if add_custom_command() could create
configuration-specific commands. However, after reading about this in the
bug tracker, it feels like an uphill battle, since it appears to have been
in the making since 2009... Unfortunately, I will probably not have time to
spend working on cmake (except for Emacs-related things like my font-lock
package).

Thanks for your input!

    / Anders


On Thu, Jun 19, 2014 at 6:26 PM, David Cole <dlrdave at aol.com> wrote:

> cmake -E echo
>
> with no further arguments is already pretty darned close to "cmake -E
> do_nothing"...
>
> For the configuration-specific custom commands, keep your eye on
> http://public.kitware.com/Bug/view.php?id=9974 and its related bugs.
> Eventually, I expect it will be possible. Sooner, if  you have time to work
> on CMake source code yourself. :-)
>
>
> HTH,
> David
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20140619/663dbe65/attachment-0001.html>


More information about the CMake mailing list