[CMake] Question about FOREACH

alaterale at elitemail.org alaterale at elitemail.org
Tue May 24 13:23:25 EDT 2005


Hi,
I have a quick question about the FOREACH command.  I'm basically trying
to execute the "env" program and be able to parse specific environment
variables into cmake variables.  So here's what I'm doing so far:

EXEC_PROGRAM("env > env.txt")
FILE(READ "env.txt" ENVIRONMENT_VARIABLES)

Now, I need to be able to use FOREACH to iterate through the file
contents based on some delimiter (preferably "/n" since that's what the
file is delimited on by default)

I have this so far but it doesn't work:
FOREACH(VAR ENVIRONMENT_VARIABLES)
	MESSAGE(STATUS ${VAR})
ENDFOREACH(VAR ENVIRONMENT_VARIABLES)

I guess all this would be unnecessary if there were a way to just
retrieve real environment variables from the system, but I have not
figured that out yet :P  So I guess if anyone knows how to get and set
environment variables from cmake, that would help too.  Thanks!
~~J Strange


More information about the CMake mailing list