[CMake] function and raise_scope commands

Miguel A. Figueroa-Villanueva miguelf at ieee.org
Thu Dec 6 15:07:22 EST 2007


On Dec 3, 2007 3:07 PM, Ken Martin wrote:
> I checked into CVS two new commands; function and raise_scope (well three
> commands if you count endfunction)

First of all: THANKS!! Great feature to have!

Now, I have been using it and exploring its functionality and have
come across to things, which I'm not sure that are bugs or simply part
of how it works.

1. CMake crashes if I use the same variable name as the argument and
raise the scope later. That is, for the following function:

function(track_find_variable cache_variable is_changed)
  raise_scope(${is_changed})
endfunction(track_find_variable)

I can't call it like:

track_find_variable(testvar is_changed) # I had to mangle is_changed
above, but that's ok

I think it shouldn't crash. If its too much effort to have cmake
support this, then I don't think it is worth it... just having a note
that the argument can't be used as a variable name in the help and
maybe try to detect the case and signal an error...

2. Given the new scope contexts, when I call the following function:

function(tester)
  message(STATUS "${CMAKE_CURRENT_LIST_FILE}")
endfunction(tester)

tester() prints what it should:
D:/builds/temp/testLatexModule/CMakeLists.txt

However, if I put it in a cmake_utils.cmake file and call include(cmake_utils):

tester() prints garbage... somehow it gets corrupted. For example, in
one run it printed:

<CMAKE_RC_COMPILER> <FLAGS>  /fo<OBJECT> <SOURCE>

I would have thought that, since the function inherits the current
scope that this shouldn't happen...

Any insight into these problems will be greatly appreciated, but again
I think this is a great feature and for the regular use cases it seems
to be working great!

--Miguel


More information about the CMake mailing list