Skip to content

Commit

Permalink
fixup! Allow specifying an order of Qt versions to consider
Browse files Browse the repository at this point in the history
Simplify code by using foreach instead of while loop.
  • Loading branch information
rhaschke committed Feb 2, 2024
1 parent ba70f39 commit bae25ef
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,16 @@ find_package(OpenGL REQUIRED)
set(CMAKE_AUTOMOC ON)

set(RVIZ_QT_VERSIONS "5;6" CACHE STRING "List of Qt versions to consider (in order)")
set(_versions_list ${RVIZ_QT_VERSIONS})
while(_versions_list)
# Pop first element from list _versions_list
list(GET _versions_list 0 _current_version)
list(REMOVE_AT _versions_list 0)
# Try to find this Qt version
foreach(_current_version ${RVIZ_QT_VERSIONS})
find_package(Qt${_current_version} QUIET COMPONENTS Core Widgets OpenGL)
if (Qt${_current_version}_FOUND)
set(QTVERSION ${Qt${_current_version}_VERSION})
set(QT_LIBRARIES Qt${_current_version}::Widgets)
set(_versions_list) # break from while loop
break() # early break from loop
else()
message(WARNING "Qt${_current_version} not found.")
endif()
endwhile()
endforeach()
if(NOT QTVERSION)
message(FATAL_ERROR "Failed to find a suitable Qt version.")
endif()
Expand Down

0 comments on commit bae25ef

Please sign in to comment.