Variable exported into parent scope not assigning correctly within that scope

Hi, I have bug for you…

The following code, an exported ‘return’ value set by a function and assigned to a second variable within the main scope results in the second variable not being set.

function( GetProjectID )
set( RET0 “MYPROJECT” )
set( RET0 “${RET0}” PARENT_SCOPE )
endfunction()

GetProjectID()
set( MYPROJECTNAME, “${RET0}” )
message( “PROJECT_ID: ${RET0}” )
message( “PROJECT_ID: ${MYPROJECTNAME}” )

Note that the second instance of ‘Message(PROJECT_ID…’) doesn’t display the variable as it has no value (proof: removing the prefix string results in an explicit script error relating to the use of a variable with no value).

This is with CMake version 3.20.21032501-MSVC_2 (the current Visual Studio 2019 CMake)

Is that comma here a typo in the post or do you have it in your code?

It might be me as the above was an attempt to replicate something from a more complex nest of function calls without all of the bloat.

If the comma was in the original then the bug is obviously mine and I must have acquired punctuation blindness in a sea of script - thanks for the hint. I’ll report back once I’ve restored the original functionality.