On Nov 15, 2007 1:53 PM, Josef Karthauser <[EMAIL PROTECTED]> wrote:
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On
> Behalf
> > Of Brandon Van Every
> > Sent: 15 November 2007 14:17
> > To: [email protected]
> > Subject: Re: [CMake] Setting environment variables for custom targets
> > > 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.
> >
>
> How so?  Can you give me an example?

Call the script in your ADD_CUSTOM_TARGET using "cmake -P
myscript.cmake".  The script would contain something like:
SET(ENV{MYVAR} FOO)
EXECUTE_PROCESS(...) # whatever you want to do

However this environment is only going to last as long as the
execution of your CMake script.  That should be fine if all you're
trying to do is fire off an external tool and then continue
processing.  It's not enough if you're trying to set an environment
variable permanently, long after your build is over.  I think you
would have to do that on a system specific basis, I don't think CMake
has any mechanism for it.


Cheers,
Brandon Van Every
_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to