On 10/10/2011 3:52 PM, Robert Dailey wrote:
Yes, this works perfectly.

It's a bit disappointing that cache variables are, for all intents and
purposes, read-only in functions. The property approach is a bit more
verbose but it functions! I think 'set' needs a new override
specifically for cases like this. Something similar to "PARENT_SCOPE",
but something like "CACHE_SCOPE", that forces CMake to first check for
the existance of a cache variable with that name, and it would take
precedence over any identically named variable in function scope.

On another note, you'd think this would work too but it doesn't:

set( project_count ${new_count} CACHE INTERNAL FORCE )


This works:

set( project_count 0 CACHE INTERNAL "")
function( define_project )
   math( EXPR count "${project_count}+1" )
   set( project_count ${count} CACHE INTERNAL "")
endfunction()
define_project()
message(${project_count})
define_project()
message(${project_count})
define_project()
message(${project_count})

It prints out
1
2
3

-Bill
--
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to