[CMake] Bug in if/else/endif in combination with option?
Marcel Loose
loose at astron.nl
Mon Mar 30 06:28:17 EDT 2009
Hi all,
I am running cmake version 2.6-patch 2.
I stumbled over the following, and I think it is a bug.
If I run cmake on this CMakeLists.txt:
cmake_minimum_required(VERSION 2.6)
set(options
fine
good
bad)
#option(fine "Fine" OFF)
#option(good "Good" OFF)
option(bad "Bad" OFF)
foreach(opt ${options})
message(STATUS "opt = ${opt}")
if(${opt} STREQUAL fine)
message(STATUS "This is fine")
elseif(${opt} STREQUAL good)
message(STATUS "This is good")
else(${opt} STREQUAL fine)
message(FATAL_ERROR "This is bad!")
endif(${opt} STREQUAL fine)
endforeach(opt ${options})
I get the following output:
...
-- val = fine
-- fine
-- val = good
-- good
-- val = bad
CMake Error at CMakeLists.txt:14 (message):
bad
...
which is to be expected.
However, when I uncomment the line option(fine...), I get the following
output:
...
-- opt = fine
-- This is fine
-- opt = good
-- This is good
-- opt = bad
-- This is fine
-- Configuring done
...
which is clearly wrong! Uncommenting the line option(good...) yields
almost the same output, but now the elseif branch is followed.
Is this a bug, or am I overlooking something?
Best regards,
Marcel Loose.
More information about the CMake
mailing list