[CMake] Custom Commands and Environmnt Settings for PATH and LD_LIBRARY_PATH
Matthew Woehlke
mw_triad at users.sourceforge.net
Mon Apr 21 13:30:53 EDT 2014
On 2014-04-11 05:32, Jörg Kreuzberger wrote:
> [stuff about environment and custom commands]
>
> So it would help to have a possiblity to have a custom command like this:
>
> add_custom_command( OUTPUT <out>
> COMMAND ..
> COMMAND ..
> ENVIRONMENT PATH=$ENV{PATH}
> ENVIRONMENT LD_LIBRARY=
I'm pretty sure this is not the first time this sort of thing has come
up. It would indeed be useful to be able to pass environment values to a
custom command without having to roll your own wrapper script. However,
because the command must be run by the build too, I believe a wrapper of
some sort is unavoidable (though on POSIX platforms, 'env' can possibly
serve this purpose).
Bonus points for supporting '{PRE,AP}PEND ENVIRONMENT' which would
automatically use the platform-appropriate PATH separator to
prepend/append a specified value to an environment variable (omitting
the separator if the variable is empty).
However, to do this, I think you would need to teach CMake a new command
mode, e.g.:
cmake -E env VAR1=VALUE VAR2:=PREPEND_VALUE VAR3+=APPEND_VALUE \
command args
I think this would be a nice feature to have, though.
--
Matthew
More information about the CMake
mailing list