Return a list from the function using OUT parameter

前端 未结 3 1436
星月不相逢
星月不相逢 2020-11-29 11:16

I would like to create a CMake function as:

function(test src_list dst_list)
# do something
endfunction()

usage:

test(${my_lis         


        
3条回答
  •  感动是毒
    2020-11-29 11:37

    In CMake, functions have their own scope, and by default, all modification of variables are local, unless you pass CACHE or PARENT_SCOPE as parameter to set. Inside a function, if you want to modify a variable in the scope of the caller, you should use:

    set(${dst_list}  PARENT_SCOPE)
    

    See documentation:

    A function opens a new scope: see set(var PARENT_SCOPE) for details.

提交回复
热议问题