aboutsummaryrefslogtreecommitdiff
path: root/cmake/QtVersionOption.cmake
diff options
context:
space:
mode:
authorSefa Eyeoglu <contact@scrumplex.net>2022-07-03 22:40:05 +0200
committerSefa Eyeoglu <contact@scrumplex.net>2022-07-10 12:19:15 +0200
commit4e99da7b6212fdba121d93892f48f6bce158e2a6 (patch)
tree3e719bbadd43dc9ae03dda5420c014bd7109874d /cmake/QtVersionOption.cmake
parenteb5ed508248d922edd8f516b90d38b55841f0695 (diff)
downloadPrismLauncher-4e99da7b6212fdba121d93892f48f6bce158e2a6.tar.gz
PrismLauncher-4e99da7b6212fdba121d93892f48f6bce158e2a6.tar.bz2
PrismLauncher-4e99da7b6212fdba121d93892f48f6bce158e2a6.zip
refactor: query Qt variables using ECM
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
Diffstat (limited to 'cmake/QtVersionOption.cmake')
-rw-r--r--cmake/QtVersionOption.cmake38
1 files changed, 38 insertions, 0 deletions
diff --git a/cmake/QtVersionOption.cmake b/cmake/QtVersionOption.cmake
new file mode 100644
index 00000000..1390f9db
--- /dev/null
+++ b/cmake/QtVersionOption.cmake
@@ -0,0 +1,38 @@
+#.rst:
+# QtVersionOption
+# ---------------
+#
+# Adds a build option to select the major Qt version if necessary,
+# that is, if the major Qt version has not yet been determined otherwise
+# (e.g. by a corresponding find_package() call).
+#
+# This module is typically included by other modules requiring knowledge
+# about the major Qt version.
+#
+# ``QT_MAJOR_VERSION`` is defined to either be "5" or "6".
+#
+#
+# Since 5.82.0.
+
+#=============================================================================
+# SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
+#
+# SPDX-License-Identifier: BSD-3-Clause
+
+if (DEFINED QT_MAJOR_VERSION)
+ return()
+endif()
+
+if (TARGET Qt5::Core)
+ set(QT_MAJOR_VERSION 5)
+elseif (TARGET Qt6::Core)
+ set(QT_MAJOR_VERSION 6)
+else()
+ option(BUILD_WITH_QT6 "Build against Qt 6" OFF)
+
+ if (BUILD_WITH_QT6)
+ set(QT_MAJOR_VERSION 6)
+ else()
+ set(QT_MAJOR_VERSION 5)
+ endif()
+endif()