[CMake] Writing a list variable to file

Ian.Appru at ubs.com Ian.Appru at ubs.com
Wed Mar 1 09:39:02 EST 2006


Hi Brad 

1) works well - thanks 
   the MESSAGE cmd won't print it which made me doubt it was working

2) doesn't work since the ; seps are removed before the regular
expression is applied

- Ian

-----Original Message-----
From: Brad King [mailto:brad.king at kitware.com] 
Sent: 01 March 2006 14:13
To: Appru, Ian
Cc: cmake at cmake.org
Subject: Re: [CMake] Writing a list variable to file

Ian.Appru at ubs.com wrote:
> Is there a recommended way of writing a variable containing a list to 
> a file - so that each ; sep item ends up on a different line?

There are several approaches.  Here are two:

1.) Build the contents of the variable with newlines instead of
semicolons, or transform the contents like this:

SET(CONTENTS "")
FOREACH(line MYLINES)
   SET(CONTENTS "${CONTENTS}${line}\n")
ENDFOREACH(line)

2.) Use the STRING command's REGEX option to replace semicolons with
newlines.

-Brad

Visit our website at http://www.ubs.com

This message contains confidential information and is intended only 
for the individual named.  If you are not the named addressee you 
should not disseminate, distribute or copy this e-mail.  Please 
notify the sender immediately by e-mail if you have received this 
e-mail by mistake and delete this e-mail from your system.

E-mail transmission cannot be guaranteed to be secure or error-free 
as information could be intercepted, corrupted, lost, destroyed, 
arrive late or incomplete, or contain viruses.  The sender therefore 
does not accept liability for any errors or omissions in the contents 
of this message which arise as a result of e-mail transmission.  If 
verification is required please request a hard-copy version.  This 
message is provided for informational purposes and should not be 
construed as a solicitation or offer to buy or sell any securities or 
related financial instruments.



More information about the CMake mailing list