mirror of
https://github.com/itay-grudev/SingleApplication.git
synced 2024-11-15 12:15:43 +08:00
Merge pull request #118 from Shatur95/improve-qt6-support
Use QT_DEFAULT_MAJOR_VERSION
This commit is contained in:
commit
c6227ee2cd
@ -10,23 +10,25 @@ add_library(${PROJECT_NAME} STATIC
|
|||||||
)
|
)
|
||||||
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
|
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
|
||||||
|
|
||||||
set(QT_MAJOR_VERSION 5 CACHE STRING "Qt version to use (5 or 6), defaults to 5")
|
if(NOT QT_DEFAULT_MAJOR_VERSION)
|
||||||
|
set(QT_DEFAULT_MAJOR_VERSION 5 CACHE STRING "Qt version to use (5 or 6), defaults to 5")
|
||||||
|
endif()
|
||||||
|
|
||||||
# Find dependencies
|
# Find dependencies
|
||||||
set(QT_COMPONENTS Core Network)
|
set(QT_COMPONENTS Core Network)
|
||||||
set(QT_LIBRARIES Qt${QT_MAJOR_VERSION}::Core Qt${QT_MAJOR_VERSION}::Network)
|
set(QT_LIBRARIES Qt${QT_DEFAULT_MAJOR_VERSION}::Core Qt${QT_DEFAULT_MAJOR_VERSION}::Network)
|
||||||
|
|
||||||
if(QAPPLICATION_CLASS STREQUAL QApplication)
|
if(QAPPLICATION_CLASS STREQUAL QApplication)
|
||||||
list(APPEND QT_COMPONENTS Widgets)
|
list(APPEND QT_COMPONENTS Widgets)
|
||||||
list(APPEND QT_LIBRARIES Qt${QT_MAJOR_VERSION}::Widgets)
|
list(APPEND QT_LIBRARIES Qt${QT_DEFAULT_MAJOR_VERSION}::Widgets)
|
||||||
elseif(QAPPLICATION_CLASS STREQUAL QGuiApplication)
|
elseif(QAPPLICATION_CLASS STREQUAL QGuiApplication)
|
||||||
list(APPEND QT_COMPONENTS Gui)
|
list(APPEND QT_COMPONENTS Gui)
|
||||||
list(APPEND QT_LIBRARIES Qt${QT_MAJOR_VERSION}::Gui)
|
list(APPEND QT_LIBRARIES Qt${QT_DEFAULT_MAJOR_VERSION}::Gui)
|
||||||
else()
|
else()
|
||||||
set(QAPPLICATION_CLASS QCoreApplication)
|
set(QAPPLICATION_CLASS QCoreApplication)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(Qt${QT_MAJOR_VERSION} COMPONENTS ${QT_COMPONENTS} REQUIRED)
|
find_package(Qt${QT_DEFAULT_MAJOR_VERSION} COMPONENTS ${QT_COMPONENTS} REQUIRED)
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME} PUBLIC ${QT_LIBRARIES})
|
target_link_libraries(${PROJECT_NAME} PUBLIC ${QT_LIBRARIES})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user