[CMake] Explanation....

Theodore Papadopoulo Theodore.Papadopoulo at inria.fr
Fri Apr 11 08:20:36 EDT 2014


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I have run on behaviour of cmake that I really do not understand (even
if I have clues)... This is probably stupid, but I'm puzzled...

The attached CMakeLists.txt gives the following output:

::-B-::  <- This shows that B is indeed parsed as OPTIONAL
A
A        <- Fine I'm in the else part of the if
OPTIONAL
HERE     <- Fine.
B
HERE     <- ???????

Tested on cmake 2.3.4 and 2.8.12.2.
Of course this is related to the reuse of TOTO both as a variable name
and as a variable content.... but this seems really error prone.

	Thank's for any clue.

	Theo Papadopoulo.
	
PS: I'm clearly supporting the addition of a continue() command:

http://public.kitware.com/Bug/bug_relationship_graph.php?bug_id=14013&graph=relation

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEUEARECAAYFAlNH3hQACgkQEr8WrU8nPV2BZgCXbxsiijX9dQD0TlfIGQa5bIfj
0QCfZffqFn0WpoFEAv1oBrF6fVF62JY=
=ooMR
-----END PGP SIGNATURE-----
-------------- next part --------------
cmake_minimum_required(VERSION 2.8)

project(Test)

set(DEFAULT A)
set(TOTO B)
message("::-${TOTO}-::")
foreach(arg ${DEFAULT} TOTO ${TOTO})
    message("${arg}")
    if ("${arg}" STREQUAL "TOTO")
        message("HERE")
    else()
        message("${arg}")
    endif()
endforeach()


More information about the CMake mailing list