[CMake] FOREACH loop control variable scope bug

Bradley Lowekamp blowekamp at mail.nih.gov
Wed Jun 22 13:07:54 EDT 2005


hi all,

This behavior I think is a bug. This is another problem I have 
encounter in CMake with my apparent abuse while I am trying to get my 
project to work easily. Consider the following simplified example:


# top level CMakeLists.txt
SET(var "this is var")
FOREACH(LCV one)
	MESSAGE("var: ${var} LCV: ${LCV}")
	ADD_SUBDIRECTORY(foo)
ENDFOREACH(LCV one two three)


# foo dir CMakeLists.txt
MESSAGE("In Directory var: ${var} LCV: ${LCV}")

This produces the following output:

var: this is var LCV: one
In Directory var: this is var LCV:

I expected LCV to be defined in the subdirectory just like any other 
variable would have been. I realize this is can only happen with the 
new immediate execution of the ADD_SUBDIRECTORY command. It appear that 
there is some scoping issues with this variable.

Thanks,
Brad



========================================================
Bradley Lowekamp
Management Systems Designers Contractor for
Office of High Performance Computing and Communications
National Library of Medicine
'blowekamp at mail.nih.gov



More information about the CMake mailing list