1- cmake_minimum_required (VERSION 3.5 )
1+ cmake_minimum_required (VERSION 3.10 )
22
33project (rviz2)
44
@@ -18,24 +18,25 @@ find_package(rviz_common REQUIRED)
1818
1919find_package (rviz_ogre_vendor REQUIRED)
2020
21- find_package (Qt5 REQUIRED COMPONENTS Widgets)
21+ find_package (QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
22+ find_package (Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
2223# TODO(wjwwood): this block is to setup the windeployqt tool, could be removed later.
23- if (Qt5_FOUND AND WIN32 AND TARGET Qt5 ::qmake AND NOT TARGET Qt5 ::windeployqt)
24- get_target_property (_qt5_qmake_location Qt5 ::qmake IMPORTED_LOCATION )
24+ if (Qt ${QT_VERSION_MAJOR} _FOUND AND WIN32 AND TARGET Qt ${QT_VERSION_MAJOR} ::qmake AND NOT TARGET Qt ${QT_VERSION_MAJOR} ::windeployqt)
25+ get_target_property (_qt_qmake_location Qt ${QT_VERSION_MAJOR} ::qmake IMPORTED_LOCATION )
2526
2627 execute_process (
27- COMMAND "${_qt5_qmake_location } " -query QT_INSTALL_PREFIX
28+ COMMAND "${_qt_qmake_location } " -query QT ${QT_VERSION_MAJOR} _INSTALL_PREFIX
2829 RESULT_VARIABLE return_code
29- OUTPUT_VARIABLE qt5_install_prefix
30+ OUTPUT_VARIABLE qt_install_prefix
3031 OUTPUT_STRIP_TRAILING_WHITESPACE
3132 )
3233
33- set (imported_location "${qt5_install_prefix } /bin/windeployqt.exe" )
34+ set (imported_location "${qt_install_prefix } /bin/windeployqt.exe" )
3435
3536 if (EXISTS ${imported_location} )
36- add_executable (Qt5 ::windeployqt IMPORTED )
37+ add_executable (Qt ${QT_VERSION_MAJOR} ::windeployqt IMPORTED )
3738
38- set_target_properties (Qt5 ::windeployqt PROPERTIES
39+ set_target_properties (Qt ${QT_VERSION_MAJOR} ::windeployqt PROPERTIES
3940 IMPORTED_LOCATION ${imported_location}
4041 )
4142 endif ()
@@ -48,21 +49,21 @@ target_link_libraries(${PROJECT_NAME}
4849 rviz_common::rviz_common
4950 rviz_ogre_vendor::OgreMain
5051 rviz_ogre_vendor::OgreOverlay
51- Qt5 ::Widgets
52+ Qt ${QT_VERSION_MAJOR} ::Widgets
5253)
5354
5455# TODO(wjwwood): find a way to make this optional or to run without "deploying" the
5556# necessary dlls and stuff to the bin folder.
5657# see:
5758# https://stackoverflow.com/questions/41193584/deploy-all-qt-dependencies-when-building#41199492
58- if (TARGET Qt5 ::windeployqt)
59+ if (TARGET Qt ${QT_VERSION_MAJOR} ::windeployqt)
5960 # execute windeployqt in a tmp directory after build
6061 add_custom_command (TARGET ${PROJECT_NAME}
6162 POST_BUILD
6263 COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_CURRENT_BINARY_DIR} /windeployqt"
63- COMMAND set PATH =%PATH %$<SEMICOLON>${qt5_install_prefix } /bin
64+ COMMAND set PATH =%PATH %$<SEMICOLON>${qt_install_prefix } /bin
6465 COMMAND
65- Qt5 ::windeployqt
66+ Qt ${QT_VERSION_MAJOR} ::windeployqt
6667 --dir "${CMAKE_CURRENT_BINARY_DIR} /windeployqt"
6768 "$<TARGET_FILE_DIR:${PROJECT_NAME} >/$<TARGET_FILE_NAME:${PROJECT_NAME} >"
6869 )
0 commit comments