Skip to content

Commit 4607520

Browse files
committed
Merge pull request #33 from rhaschke/unify_find_qt
unified find_package for Qt4 and Qt5
2 parents c0e96d0 + b0f6b24 commit 4607520

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

librviz_tutorial/CMakeLists.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@ set(CMAKE_AUTOMOC ON)
1717
## We'll use the version that rviz used so they are compatible.
1818
if(rviz_QT_VERSION VERSION_LESS "5")
1919
message(STATUS "Using Qt4 based on the rviz_QT_VERSION: ${rviz_QT_VERSION}")
20-
find_package(Qt4 COMPONENTS QtCore QtGui REQUIRED)
20+
find_package(Qt4 ${rviz_QT_VERSION} EXACT REQUIRED QtCore QtGui)
21+
## pull in all required include dirs, define QT_LIBRARIES, etc.
2122
include(${QT_USE_FILE})
2223
else()
2324
message(STATUS "Using Qt5 based on the rviz_QT_VERSION: ${rviz_QT_VERSION}")
24-
find_package(Qt5Widgets REQUIRED)
25-
find_package(Qt5Core REQUIRED)
26-
find_package(Qt5OpenGL REQUIRED)
27-
## Set the QT_LIBRARIES variable for Qt5, so it can be used below.
25+
find_package(Qt5 ${rviz_QT_VERSION} EXACT REQUIRED Core Widgets)
26+
## make target_link_libraries(${QT_LIBRARIES}) pull in all required dependencies
2827
set(QT_LIBRARIES Qt5::Widgets)
2928
endif()
3029

rviz_plugin_tutorials/CMakeLists.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@ set(CMAKE_AUTOMOC ON)
1717
## We'll use the version that rviz used so they are compatible.
1818
if(rviz_QT_VERSION VERSION_LESS "5")
1919
message(STATUS "Using Qt4 based on the rviz_QT_VERSION: ${rviz_QT_VERSION}")
20-
find_package(Qt4 COMPONENTS QtCore QtGui REQUIRED)
20+
find_package(Qt4 ${rviz_QT_VERSION} EXACT REQUIRED QtCore QtGui)
21+
## pull in all required include dirs, define QT_LIBRARIES, etc.
2122
include(${QT_USE_FILE})
2223
else()
2324
message(STATUS "Using Qt5 based on the rviz_QT_VERSION: ${rviz_QT_VERSION}")
24-
find_package(Qt5Widgets REQUIRED)
25-
find_package(Qt5Core REQUIRED)
26-
find_package(Qt5OpenGL REQUIRED)
27-
## Set the QT_LIBRARIES variable for Qt5, so it can be used below.
25+
find_package(Qt5 ${rviz_QT_VERSION} EXACT REQUIRED Core Widgets)
26+
## make target_link_libraries(${QT_LIBRARIES}) pull in all required dependencies
2827
set(QT_LIBRARIES Qt5::Widgets)
2928
endif()
3029

0 commit comments

Comments
 (0)