refactor: restructure CMake to support future Qt versions

This commit is contained in:
Sefa Eyeoglu 2022-01-27 12:52:12 +01:00
parent 0442b80a2c
commit 88686ef065
No known key found for this signature in database
GPG Key ID: C10411294912A422

View File

@ -101,18 +101,19 @@ add_custom_target(tcversion echo "\\#\\#teamcity[setParameter name=\\'env.LAUNCH
################################ 3rd Party Libs ################################ ################################ 3rd Party Libs ################################
# Find the required Qt parts # Find the required Qt parts
set(QT_VERSION_MAJOR ${Launcher_QT_VERSION_MAJOR}) if(Launcher_QT_VERSION_MAJOR EQUAL 5)
find_package(Qt${QT_VERSION_MAJOR}Core REQUIRED) set(QT_VERSION_MAJOR 5)
find_package(Qt${QT_VERSION_MAJOR}Widgets REQUIRED) find_package(Qt5 REQUIRED COMPONENTS Core Widgets Concurrent Network Test Xml)
find_package(Qt${QT_VERSION_MAJOR}Concurrent REQUIRED)
find_package(Qt${QT_VERSION_MAJOR}Network REQUIRED)
find_package(Qt${QT_VERSION_MAJOR}Test REQUIRED)
find_package(Qt${QT_VERSION_MAJOR}Xml REQUIRED)
if (NOT Launcher_FORCE_BUNDLED_LIBS) if(NOT Launcher_FORCE_BUNDLED_LIBS)
find_package(QuaZip-Qt${QT_VERSION_MAJOR} REQUIRED) find_package(QuaZip-Qt5 REQUIRED)
endif()
if (NOT QuaZip-Qt5_FOUND)
set(QUAZIP_QT_MAJOR_VERSION ${QT_VERSION_MAJOR} CACHE STRING "Qt version to use (4, 5 or 6), defaults to ${QT_VERSION_MAJOR}" FORCE)
set(FORCE_BUNDLED_QUAZIP 1)
endif()
else() else()
MESSAGE(STATUS "Not looking for QuaZip via find_package") message(FATAL_ERROR "Qt version ${Launcher_QT_VERSION_MAJOR} is not supported")
endif() endif()
# The Qt5 cmake files don't provide its install paths, so ask qmake. # The Qt5 cmake files don't provide its install paths, so ask qmake.
@ -261,9 +262,8 @@ add_subdirectory(libraries/hoedown) # markdown parser
add_subdirectory(libraries/launcher) # java based launcher part for Minecraft add_subdirectory(libraries/launcher) # java based launcher part for Minecraft
add_subdirectory(libraries/javacheck) # java compatibility checker add_subdirectory(libraries/javacheck) # java compatibility checker
add_subdirectory(libraries/xz-embedded) # xz compression add_subdirectory(libraries/xz-embedded) # xz compression
if (NOT QuaZip-Qt${QT_VERSION_MAJOR}_FOUND) if (FORCE_BUNDLED_QUAZIP)
set(QUAZIP_QT_MAJOR_VERSION ${QT_VERSION_MAJOR}) message(STATUS "Using bundled QuaZip")
MESSAGE(STATUS "Adding QuaZip submodule, with QT_VERSION_MAJOR ${QUAZIP_QT_MAJOR_VERSION}")
add_subdirectory(libraries/quazip) # zip manipulation library add_subdirectory(libraries/quazip) # zip manipulation library
endif() endif()
add_subdirectory(libraries/rainbow) # Qt extension for colors add_subdirectory(libraries/rainbow) # Qt extension for colors