project: cmake: allow building with Qt6

Signed-off-by: Marc Reilly <marc@cpdesign.com.au>
This commit is contained in:
Marc Reilly
2022-06-22 12:05:16 +10:00
parent c75cd78cff
commit 0889adbc23
3 changed files with 6 additions and 5 deletions

View File

@ -1,7 +1,8 @@
project(QtZeroConf)
cmake_minimum_required(VERSION 2.8.11)
find_package(Qt5 COMPONENTS Core Network)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Network)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Network)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
@ -50,7 +51,7 @@ target_include_directories(QtZeroConf PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(QtZeroConf PUBLIC Qt5::Core Qt5::Network)
target_link_libraries(QtZeroConf PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Network)
if(WIN32)
target_sources(QtZeroConf PRIVATE

View File

@ -116,7 +116,7 @@ QZeroConf can be used in QML applications
### Build Dependencies
Qt5
Qt5 or Qt6
On Linux, libavahi-client-dev and libavahi-common-dev

View File

@ -1,7 +1,7 @@
project(QtZeroConfExample)
cmake_minimum_required(VERSION 2.8.11)
find_package(Qt5 COMPONENTS Gui Widgets REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Gui Widgets REQUIRED)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
@ -21,5 +21,5 @@ add_executable(QtZeroConfExample
target_link_libraries(QtZeroConfExample
QtZeroConf
Qt5::Gui Qt5::Widgets
Qt${QT_VERISON_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets
)