[CMake] Versioning and release/distribution management with cmake and git

Johannes Zarl johannes.zarl at jku.at
Wed Sep 25 04:53:56 EDT 2013


Hi,

On Monday, 23. September 2013, 23:41:19, Roger Leigh wrote:
> Another minor annoyance I've run into is that when I define a function and
> make use of a global variable, it appears to expand the variable during
> definition, rather than evaluating it when I call the function.  Is it
> possible to make the function evaluate the variable lazily at
> invocation time rather than when defined?

Can you condense this into a compact example? Last time I checked, the 
variables defined at function definition time are not preserved:

<begin cmake snippet>
set( global_var "foo")
set( global_cache_var "foo" CACHE STRING "undocumented")
function(testclosure)
    message("global_var is ${global_var}")
    message("global_cache_var is ${global_cache_var}")
endfunction()

set( global_var "bar")
set( global_cache_var "bar" )
testclosure()
<end cmake snippet>

yields:
global_var is bar                                                                                                                                                                                                                                                              
global_cache_var is bar

Kind regards,
  Johannes


More information about the CMake mailing list