[CMake] CMake Function, how do I pass out strings or lists?

Tyler Roscoe tyler at cryptio.net
Wed Jan 26 12:26:24 EST 2011


On Wed, Jan 26, 2011 at 11:24:48AM -0600, kent williams wrote:
> 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}")

function() creates a new scope, so you need PARENT_SCOPE on the set() in
set_a_var().

tyler


More information about the CMake mailing list