The CMakeLists.txt below illustrates the problem:
-------------------------------------------------------------
cmake_minimum_required(VERSION 2.8)
project(testo)

function(set_a_var var value)
  set(${var} ${value})
  message("${var} = ${${var}}")
endfunction()

set_a_var(testo "HELLO!")

message("outside func testo=${testo}")
------------------------------------------------------------
The output is:
------------------------------------------------------------
cmake ../CompilerFlags
testo = HELLO!
outside func testo=
-- Configuring done
-- Generating done
-- Build files have been written to: /scratch/kent/CompilerFlags/build
-------------------------------------------------------------

I gather from looking in the CMake Modules that you have to set the
variable to be Cached, but won't this result in some cases in the
CMakeCache.txt getting stuffed full of definititions only relevant to
function calls?

Not that I want to, but what if you started computing factorials?
_______________________________________________
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