Am 16.04.2014 11:39, schrieb Johannes Zarl:
Hi,

On Monday, 14. April 2014, 19:23:19, Theodore Papadopoulo wrote:
> if ("${arg}" STREQUAL "TOTO") -> if ("TOTO" STREQUAL "TOTO") -> if
> (B STREQUAL B)

What I do not follow is why there is an implicit evaluation of "TOTO"
into "B" (in both this case or the next I explicitely asked for a
string containing the content of the variable ${arg}, if I had
intended the content of the variable which name is in ${arg} I would
have written ${${arg}}.

If it is any consolence to you, this is one of the most-hated (anti-)features of cmake. The best you can do is to embrace this oddity (it's not going to go
away soon), and use a different idiom:

Instead of ``"${var}" STREQUAL "VALUE"'', write:

IF ( var MATCHES "^VALUE$" )

NOOOOO, please don't! I try hard to kill all those as it requires compiling a regular expression for a simple string match. Just change it to something that is no valid variable name, i.e. will never get expanded:

if (" ${arg}" STREQUAL " TOTO")

Eike
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to