SIRF-SuperBuild icon indicating copy to clipboard operation
SIRF-SuperBuild copied to clipboard

Macro RenameVariable does change default value and does not rename variable

Open paskino opened this issue 5 years ago • 3 comments

The implementation of the macro RenameVariable does do 2 things:

  1. overrides the default value with the OLD value if OLD exists
  2. does unset the OLD
  3. does NOT set the NEW variable

This is confusing as a default value should not get overridden. Also, the name suggests that the macro would rename an old variable with a new and set the default value if the old one isn't set and this is not what happens.

Probably something like this should do:


macro(RenameVariable OLD NEW DEFAULT_VAR)
  if (DEFINED ${NEW})
     message (WARNING "Great job, you are using the new variable name already! 100 SIRF points!")
  else()
 # NEW is not defined and we will define it with OLD if defined else with DEFAULT_VAR
    if (DEFINED ${OLD})
      message(WARNING "Obsolete use of ${OLD}. I have used its value to set ${NEW} (use that variable in future!)")
      set(${NEW} ${${OLD}})
      unset(${OLD} CACHE)
    else()
      message(WARNING "${NEW} variable is set to default: ${DEFAULT_VAR} ")
      set(${NEW} ${${DEFAULT_VAR}})
  endif()
endmacro()

paskino avatar Aug 10 '20 10:08 paskino

Let's actually get rid of this function and break backward compatibility, which we will actually break anyway with the new SIRF version.

paskino avatar Aug 10 '20 14:08 paskino

@KrisThielemans any opinion?

paskino avatar Oct 27 '20 13:10 paskino

yes sure, get rid of it (put it in CHANGES.md)

KrisThielemans avatar Oct 27 '20 13:10 KrisThielemans