From b2ce234b96e97ad673d587c335926b5b55951ab5 Mon Sep 17 00:00:00 2001 From: tooomm Date: Fri, 28 Aug 2026 16:24:39 +0200 Subject: [PATCH] simplify legacy qtdir logic --- CMakeLists.txt | 22 +----------------- cmake/FindQtRuntime.cmake | 49 +++++++++++++++++---------------------- 2 files changed, 22 insertions(+), 49 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 18cddf820..35ae849b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,21 +53,6 @@ if(WIN32 OR USE_VCPKG) # Windows (including 64bit) or USE_VCPKG set ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake CACHE FILEPATH "Vcpkg toolchain file" ) - - # Show warning if QTDIR is NOT defined - if(NOT QTDIR - AND NOT DEFINED ENV{QTDIR} - AND NOT DEFINED ENV{QTDIR64} - ) - set(QTDIR - "" - CACHE PATH "Path to Qt (e.g. C:/Qt/6.4.2/msvc2019_64)" - ) - message( - WARNING - "QTDIR variable is missing. Please set this variable to specify path to Qt (e.g. C:/Qt/6.4.2/msvc2019_64)" - ) - endif() endif() # A project name is needed for CPack @@ -196,16 +181,11 @@ endif() find_package(Threads REQUIRED) -if(DEFINED QTDIR) - list(APPEND CMAKE_PREFIX_PATH "${QTDIR}") -elseif(DEFINED ENV{QTDIR}) - list(APPEND CMAKE_PREFIX_PATH "$ENV{QTDIR}") -endif() - message(STATUS "Update Translations: ${UPDATE_TRANSLATIONS}") include(FindQtRuntime) +# Qt is located through normal CMake package discovery find_package(Qt6 6.4 REQUIRED) set(CMAKE_AUTOMOC TRUE) diff --git a/cmake/FindQtRuntime.cmake b/cmake/FindQtRuntime.cmake index 1ee1f215f..1f239d6b0 100644 --- a/cmake/FindQtRuntime.cmake +++ b/cmake/FindQtRuntime.cmake @@ -8,49 +8,42 @@ # Output: TEST_QT_MODULES set(REQUIRED_QT_COMPONENTS Core) + if(WITH_SERVER) - set(_SERVATRICE_NEEDED Network Sql WebSockets) + list(APPEND REQUIRED_QT_COMPONENTS Network Sql WebSockets) endif() if(WITH_CLIENT) - set(_COCKATRICE_NEEDED - Concurrent - Gui - Multimedia - Network - PrintSupport - ShaderTools - Svg - WebSockets - Widgets - Xml - Quick - QuickWidgets + list( + APPEND + REQUIRED_QT_COMPONENTS + Concurrent + Gui + Multimedia + Network + PrintSupport + ShaderTools + Svg + WebSockets + Widgets + Xml + Quick + QuickWidgets ) endif() if(WITH_ORACLE) - set(_ORACLE_NEEDED Concurrent Network Svg Widgets) + list(APPEND REQUIRED_QT_COMPONENTS Concurrent Network Svg Widgets) endif() if(TEST) # Union of Qt modules required across all test targets (independent of application targets). - # When adding a new test that needs additional Qt modules, add them here rather than in the test's CMakeLists.txt. - set(_TEST_NEEDED Concurrent Network Svg Widgets) + # When adding a new test that needs additional Qt modules, add them here rather than in the test's CMakeLists.txt + list(APPEND REQUIRED_QT_COMPONENTS Concurrent Network Svg Widgets) endif() -set(REQUIRED_QT_COMPONENTS ${REQUIRED_QT_COMPONENTS} ${_SERVATRICE_NEEDED} ${_COCKATRICE_NEEDED} ${_ORACLE_NEEDED} - ${_TEST_NEEDED} -) list(REMOVE_DUPLICATES REQUIRED_QT_COMPONENTS) # Find Qt and all required components including Linguist -find_package( - Qt6 - COMPONENTS ${REQUIRED_QT_COMPONENTS} Linguist - QUIET HINTS ${Qt6_DIR} -) +find_package(Qt6 REQUIRED COMPONENTS ${REQUIRED_QT_COMPONENTS} Linguist) -if(NOT Qt6_FOUND) - message(FATAL_ERROR "No suitable version of Qt was found") -endif() set(COCKATRICE_QT_VERSION_NAME Qt6) list(FIND Qt6LinguistTools_TARGETS Qt6::lrelease QT6_LRELEASE_INDEX)