fkie/catkin_lint

allow variable names in cmake version checks

Closed this issue · 3 comments

catkin_lint suggests to change
if(rviz_QT_VERSION VERSION_LESS "5")
into
if("${rviz_QT_VERSION}" VERSION_LESS "5")

with the following notice: operands for operator VERSION_LESS should be quoted strings.

However, using a variable name directly, without quoting and resolving is perfectly valid and IMHO much more readable. Could you improve this check, please?

I improved the check, because the main goal was to prevent constructs like

set(var1 OFF)
set(var2 var1)
# ...
if(${var2})
    # ...
endif()

In this case, ${var2} resolves to var1, and var1 is then treated as variable and resolved again.

Isn't that something we would like to happen?

If you are very adept with CMake, maybe. Most people I know are surprised by this behavior, which is exactly why catkin_lint warns about it in the first place.