On Thursday 14 February 2013, Shaun Williams wrote:
> I'm slowly realizing the gravity of this behavior:
> 
> if(build_system STREQUAL "windows")
> ...
> endif()
> 
> If someone creates a variable named "windows", then this code will not work
> as intended.
> 
> I'm starting to convert our scripts to use this hopefully foolproof
> alternative:
> 
> string(COMPARE EQUAL "${build_system}" windows _cmp)
> if (_cmp)
> ...
> endif()
> 
> It will make it ugly to create a nested if else block, but it'll work.

You can do 
if("${myvar}" MATCHES "somestring")
or more strict

if("${myvar}" MATCHES "^somestring$")

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

Reply via email to