[Cmake] STREQUAL and FILE command

Andy Cedilnik andy . cedilnik at kitware . com
17 Jul 2003 12:51:30 -0400


Hi John,

FILE READ/WRITE produce new line character on the last line. MATCHES
should however handle that. Your problem is that you are reversing the
order.

A MATCHES B means does A match expression B. In your case it does not.

So, what I would do is:

FILE(READ filename AnotherVersionNumber)
STRING(REGEX REPLACE ....)

				Andy

On Thu, 2003-07-17 at 12:04, John Biddiscombe wrote:
> I wanted to do
> FILE(WRITE filename AVersionNumber)
> and then next time
> FILE(READ filename AnotherVersionNumber)
> 
> then IF("${AVersionNumber}" MATCHES "${AnotherVersionNumber}")
> 
> but it always fails.
> 
> I thought it must be the MATCHES command so I added a STREQUAL command to the IfCommand.cxx so that
> 
> IF("${AVersionNumber}" STREQUAL "${AnotherVersionNumber}")
> 
> but this fails to. I found the trouble
> 
> if we write out
> 1_0_0_1 
> to the file. It adds a CR/LF
> then when we read it back we get
> 1_0_0_1\0A (ie an 0A char at the end)
> 
> question 1) Should the MATCHES command do the same as my STREQUAL, or shall I commit the STREQUAL addition to the if command
> 
> question 2) Should I modify the File Write to not add a CR/LF
> 
> thanks