[CMake] Setting environment variables for custom targets

Josef Karthauser joe.karthauser at geomerics.com
Thu Nov 15 04:03:00 EST 2007


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.

Joe


More information about the CMake mailing list