[CMake] Strange problem with parsing variables

Ken Martin ken.martin at kitware.com
Tue Feb 6 10:42:20 EST 2007


This was fixed in CVS CMake a couple weeks ago. I sent out an email
describing the issue to the list in response to a similar (or the same)
problem.

Thanks
Ken

Ken Martin PhD 
Kitware Inc.
28 Corporate Drive
Clifton Park NY 12065
518 371 3971 

-----Original Message-----
From: cmake-bounces+ken.martin=kitware.com at cmake.org
[mailto:cmake-bounces+ken.martin=kitware.com at cmake.org] On Behalf Of
wedekind
Sent: Tuesday, February 06, 2007 9:08 AM
To: cmake at cmake.org
Subject: AW: [CMake] Strange problem with parsing variables

Hello all,

I just want to revive my topic from two weeks ago. Please have a look at
the mail below. Can you reproduce this behaviour? What's the reason behind
it or is it a bug?

Cheers

Marco

>>-----Ursprüngliche Nachricht-----
>>Von: wedekind [mailto:wedekind at caesar.de]
>>Gesendet: Freitag, 26. Januar 2007 17:02
>>An: 'cmake at cmake.org'
>>Betreff: [CMake] Strange problem with parsing variables
>>
>>Hello all,
>>
>>I've encountered a strange parsing problem with a 2-month old checkout
>from
>>CMake's cvs repository. Please have a look at the following sample
>>CMakeLists.txt:
>>
>>SET(SOME_VAR 1)
>>
>>IF(SOME_VAR)
>>   MESSAGE("SOME_VAR is set to true")
>>ENDIF(SOME_VAR)
>>
>>IF(NOT SOME_VAR)
>>   SET(SOME_OTHER_VAR some_value)
>>   MESSAGE("SOME_VAR set to false")
>>   IF(some_value STREQUAL ${SOME_OTHER_VAR})
>>      MESSAGE("SOME_OTHER_VAR is set to some_value")
>>   ENDIF(some_value STREQUAL ${SOME_OTHER_VAR})
>>ENDIF(NOT SOME_VAR)
>>
>>When running cmake on it, cmake throws an error like this:
>>
>>CMakeLists.txt:10:
>>IF had incorrect arguments: some_value STREQUAL ${SOME_OTHER_VAR} (Unknown
>>arguments specified).
>>
>>I guess, what happens is, that cmake does not know about any variables
>>defined in the second IF (IF(NOT SOME_VAR)...), i.e. SOME_OTHER_VAR is not
>>known to cmake's parser. But it complains about this "missing" variable
>>because it is used in another IF-statement (IF(some_value STREQUAL
>>${SOME_OTHER_VAR})...). This is strange, because cmake does not need to
>>parse the content of the second IF, if SOME_VAR is set to "1". Or it
>should
>>parse the variables too.
>>
>>If you define SOME_OTHER_VAR outside of the second IF, everything works
>>fine:
>>
>>SET(SOME_VAR 1)
>>
>>IF(SOME_VAR)
>>   MESSAGE("SOME_VAR is set to true")
>>ENDIF(SOME_VAR)
>>
>>SET(SOME_OTHER_VAR some_value)
>>
>>IF(NOT SOME_VAR)
>>   MESSAGE("SOME_VAR set to false")
>>   IF(some_value STREQUAL ${SOME_OTHER_VAR})
>>      MESSAGE("SOME_OTHER_VAR is set to some_value")
>>   ENDIF(some_value STREQUAL ${SOME_OTHER_VAR})
>>ENDIF(NOT SOME_VAR)
>>
>>It also works, if you put the content of the second IF-statement into a
>>separate file, which is included in the second if:
>>
>>SET(SOME_VAR 1)
>>
>>IF(SOME_VAR)
>>   MESSAGE("SOME_VAR is set to true")
>>ENDIF(SOME_VAR)
>>
>>IF(NOT SOME_VAR)
>>   INCLUDE(include.cmake)
>>ENDIF(NOT SOME_VAR)
>>
>>include.cmake is:
>>
>>SET(SOME_OTHER_VAR some_value)
>>MESSAGE("SOME_VAR set to false")
>>IF(some_value STREQUAL ${SOME_OTHER_VAR})
>>   MESSAGE("SOME_OTHER_VAR is set to some_value")
>>ENDIF(some_value STREQUAL ${SOME_OTHER_VAR})
>>
>>Why does cmake work this way?
>>
>>Cheers
>>
>>Marco



_______________________________________________
CMake mailing list
CMake at cmake.org
http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list