How do I create a function (or macro) in cmake that adds to a list which is available in the outer scope? For instance, lets say I have a function (maybe it adds a new test):
function(AddToListFromFunction BinaryName OutVariable)
set(OutVariable ${OutVariable} ${BinaryName} PARENT_SCOPE)
message(STATUS "OutVariable ${OutVariable}" )
endfunction()
set(MyTests "")
AddToListFromFunction(MyBinary1 MyTests)
AddToListFromFunction(MyBinary2 MyTests)
message(STATUS "MyTests Variable: ${MyTests}")
This outputs:
-- OutVariable MyTests
-- OutVariable MyTests
-- MyTests Variable:
But what I expect it to output is:
-- OutVariable MyBinary1
-- OutVariable MyBinary1 MyBinary2
-- MyTests Variable: MyBinary1 MyBinary2