On Sunday 09 May 2010, Esben Mose Hansen wrote: > On Sunday 09 May 2010 13:49:13 Alexander Neundorf wrote: > > I can't confirm that. > > I get the following with the attached CMakeLists.txt with cmake 2.8.1: > > Interesting. Actually, CMake behaves very oddly in this case. 2.8.0 prints > "B is true" (and nothing else) for this small program: > > PROJECT(my) > > cmake_minimum_required(VERSION 2.8) > > > SET(MYVAR "/var/lib") > > IF ("/var/lib") > MESSAGE("A IS TRUE") > ENDIF() > IF (MYVAR) > MESSAGE("B IS TRUE") > ENDIF() > > > Is that really intentional? It certainly explains the variance between our > results.
Yes. The argument to if() is the name of a variable. So in IF ("/var/lib") cmake checks whether the variable named "/var/lib" has a TRUE value. This variable most probably does not exist, so it returns false. In IF (MYVAR) cmake checks whether the variable named "MYVAR" has a TRUE value, now the value exists as "/var/lib", so it returns true. Alex _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake