The official document of CMake 2.8.12 says about macro
macro
When it is invoked, the commands recorded in the macro are first modified by rep
In other words, function pushes and pops new variable scope (variables created and changed exist only in the function), macro does not. However, you can override the function default behaviour with the PARENT_SCOPE parameter of the set command.
PARENT_SCOPE
set