feat: add Qt 6 support to CMake

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
Sefa Eyeoglu
2022-05-02 21:34:09 +02:00
parent ff2cd50bfa
commit e58158c3cd
10 changed files with 172 additions and 39 deletions

View File

@ -1,7 +1,12 @@
cmake_minimum_required(VERSION 3.9.4)
project(LocalPeer)
find_package(Qt5 COMPONENTS Core Network REQUIRED)
if(QT_VERSION_MAJOR EQUAL 5)
find_package(Qt5 COMPONENTS Core Network REQUIRED)
elseif(Launcher_QT_VERSION_MAJOR EQUAL 6)
find_package(Qt6 COMPONENTS Core Network Core5Compat REQUIRED)
list(APPEND LocalPeer_LIBS Qt${QT_VERSION_MAJOR}::Core5Compat)
endif()
set(SINGLE_SOURCES
src/LocalPeer.cpp
@ -25,4 +30,4 @@ endif()
add_library(LocalPeer STATIC ${SINGLE_SOURCES})
target_include_directories(LocalPeer PUBLIC include)
target_link_libraries(LocalPeer Qt5::Core Qt5::Network)
target_link_libraries(LocalPeer Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Network ${LocalPeer_LIBS})

View File

@ -10,10 +10,11 @@ if(${BIGENDIAN})
endif(${BIGENDIAN})
# Find Qt
find_package(Qt5Core REQUIRED)
# Include Qt headers.
include_directories(${Qt5Base_INCLUDE_DIRS})
if(QT_VERSION_MAJOR EQUAL 5)
find_package(Qt5 COMPONENTS Core REQUIRED)
elseif(Launcher_QT_VERSION_MAJOR EQUAL 6)
find_package(Qt6 COMPONENTS Core REQUIRED)
endif()
set(CLASSPARSER_HEADERS
# Public headers
@ -38,4 +39,4 @@ add_definitions(-DCLASSPARSER_LIBRARY)
add_library(Launcher_classparser STATIC ${CLASSPARSER_SOURCES} ${CLASSPARSER_HEADERS})
target_include_directories(Launcher_classparser PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_link_libraries(Launcher_classparser QuaZip::QuaZip Qt5::Core)
target_link_libraries(Launcher_classparser QuaZip::QuaZip Qt${QT_VERSION_MAJOR}::Core)

View File

@ -16,7 +16,11 @@ set(CMAKE_C_STANDARD_REQUIRED true)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_C_STANDARD 11)
find_package(Qt5 COMPONENTS Core Network REQUIRED)
if(QT_VERSION_MAJOR EQUAL 5)
find_package(Qt5 COMPONENTS Core Network REQUIRED)
elseif(Launcher_QT_VERSION_MAJOR EQUAL 6)
find_package(Qt6 COMPONENTS Core Network REQUIRED)
endif()
set( katabasis_PRIVATE
src/DeviceFlow.cpp
@ -35,7 +39,7 @@ set( katabasis_PUBLIC
)
add_library( Katabasis STATIC ${katabasis_PRIVATE} ${katabasis_PUBLIC} )
target_link_libraries(Katabasis Qt5::Core Qt5::Network)
target_link_libraries(Katabasis Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Network)
# needed for statically linked Katabasis in shared libs on x86_64
set_target_properties(Katabasis

View File

@ -1,8 +1,11 @@
cmake_minimum_required(VERSION 3.9.4)
project(rainbow)
find_package(Qt5Core REQUIRED QUIET)
find_package(Qt5Gui REQUIRED QUIET)
if(QT_VERSION_MAJOR EQUAL 5)
find_package(Qt5 COMPONENTS Core Gui REQUIRED)
elseif(Launcher_QT_VERSION_MAJOR EQUAL 6)
find_package(Qt6 COMPONENTS Core Gui REQUIRED)
endif()
set(RAINBOW_SOURCES
src/rainbow.cpp
@ -11,4 +14,4 @@ src/rainbow.cpp
add_library(Launcher_rainbow STATIC ${RAINBOW_SOURCES})
target_include_directories(Launcher_rainbow PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_link_libraries(Launcher_rainbow Qt5::Core Qt5::Gui)
target_link_libraries(Launcher_rainbow Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui)

View File

@ -1,6 +1,11 @@
project(systeminfo)
find_package(Qt5Core)
if(QT_VERSION_MAJOR EQUAL 5)
find_package(Qt5 COMPONENTS Core REQUIRED)
elseif(Launcher_QT_VERSION_MAJOR EQUAL 6)
find_package(Qt6 COMPONENTS Core Core5Compat REQUIRED)
list(APPEND systeminfo_LIBS Qt${QT_VERSION_MAJOR}::Core5Compat)
endif()
set(systeminfo_SOURCES
include/sys.h
@ -19,7 +24,7 @@ elseif (UNIX)
endif()
add_library(systeminfo STATIC ${systeminfo_SOURCES})
target_link_libraries(systeminfo Qt5::Core Qt5::Gui Qt5::Network)
target_link_libraries(systeminfo Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Network ${systeminfo_LIBS})
target_include_directories(systeminfo PUBLIC include)
ecm_add_test(src/sys_test.cpp LINK_LIBRARIES systeminfo Qt5::Test TEST_NAME sys)
ecm_add_test(src/sys_test.cpp LINK_LIBRARIES systeminfo Qt${QT_VERSION_MAJOR}::Test TEST_NAME sys)