MantisBT - CMake
View Issue Details
0014335CMakeCMakepublic2013-08-03 00:432016-06-10 14:31
Rolf Eike Beer 
Kitware Robot 
normalminoralways
closedmoved 
CMake 2.8.11.2 
 
0014335: CMake does not error on duplicate else()
This should definitely give a syntax error as a stray else() also does:

if (foo)
   message(STATUS foo)
else ()
   message(STATUS not foo)
else ()
   message(STATUS funky)
endif ()
No tags attached.
has duplicate 0015548closed  Report syntax error for if/else/else construct 
has duplicate 0015988closed  No parse error message on double 'else' contruction 
Issue History
2013-08-03 00:43Rolf Eike BeerNew Issue
2015-04-30 03:48Rolf Eike BeerRelationship addedhas duplicate 0015548
2016-02-25 13:01Rolf Eike BeerRelationship addedhas duplicate 0015988
2016-02-29 07:14BartoszNote Added: 0040578
2016-02-29 09:00Brad KingNote Added: 0040579
2016-02-29 09:05Mathieu MalaterreNote Added: 0040580
2016-06-10 14:29Kitware RobotNote Added: 0042341
2016-06-10 14:29Kitware RobotStatusnew => resolved
2016-06-10 14:29Kitware RobotResolutionopen => moved
2016-06-10 14:29Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0040578)
Bartosz   
2016-02-29 07:14   
I would like to fix that issue, and displaying error message while double else() is used in the same condition.

Do you know where I could find source code which is parsing such conditions?
(0040579)
Brad King   
2016-02-29 09:00   
I haven't checked in detail but the fix may need to be somewhere near here:

 https://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmIfCommand.cxx;hb=v3.4.3#l35 [^]

That function is essentially recording the contents of the if() block until the matching endif().
(0040580)
Mathieu Malaterre   
2016-02-29 09:05   
Might a bit off topic, but I'd like to have also the following be fixed (no such thing as `elif`):

$ cat CMakeLists.txt
cmake_minimum_required(VERSION 3.0)

if (foo)
  message(STATUS foo)
elif (TRUE)
  message(STATUS not foo)
endif ()
(0042341)
Kitware Robot   
2016-06-10 14:29   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.