[CMake] Setting environment variables for custom targets

Brandon Van Every bvanevery at gmail.com
Thu Nov 15 09:17:03 EST 2007


On Nov 15, 2007 4:03 AM, Josef Karthauser <joe.karthauser at geomerics.com> wrote:
> I'm using a custom target to run an external command to build some
> objects, however the external command needs some environment variables
> setting to run properly.  Is there a way of setting an environment
> variable within CMAKE, so that it gets used during the build?
>
> It doesn't appear that,
>
>         SET(ENV{MYVAR} FOO)
>        ADD_CUSTOM_TARGET(MYTARGET mycommand args),
>
> does the right thing, as the environment var MYVAR is only set during
> the cmake build, but not populated at build time and so not utilised by
> the custom target.

Wrap your external command in a CMake script.


Cheers,
Brandon Van Every


More information about the CMake mailing list