On 2014-04-16 06:03, Rolf Eike Beer wrote:
Am 16.04.2014 11:39, schrieb Johannes Zarl:
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")
set(" TOTO" "evil")
Admittedly it's much less likely that variable names containing
non-identifier characters¹ will occur "by accident", the only truly safe
way to avoid unintended implicit expansion is to either rely on implicit
expansion (i.e. always assign your operands to variables and give the
variable names as the literal arguments), or use some other command that
doesn't perform expansion.
(¹ except for '-', which will often occur in automatically created
variable names when used in project names, e.g. my-project_SOURCE_DIR.)
See also
http://permalink.gmane.org/gmane.comp.programming.tools.cmake.devel/9936.
--
Matthew
--
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