Compare commits

...

4 commits

Author SHA1 Message Date
tooomm
0e0bed8d32 rework finding qt 2026-08-28 19:46:28 +02:00
tooomm
d183291753 QGraphicsItems is not a Qt interface 2026-08-28 19:46:28 +02:00
tooomm
b2ce234b96 simplify legacy qtdir logic 2026-08-28 19:46:28 +02:00
tooomm
a617d32ddf small fixes 2026-08-28 19:46:28 +02:00
10 changed files with 164 additions and 102 deletions

View file

@ -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,18 +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}")
# Find Qt, min version is defined in that .cmake file
include(FindQtRuntime)
find_package(Qt6 6.4 REQUIRED)
set(CMAKE_AUTOMOC TRUE)
## Find other needed libraries

View file

@ -1,89 +1,180 @@
# FindQtRuntime.cmake
#
# Find a compatible Qt version
# Inputs: WITH_SERVER, WITH_CLIENT, WITH_ORACLE
# Optional Input: QT6_DIR -- Hint as to where Qt6 lives on the system
# Output: COCKATRICE_QT_VERSION_NAME -- Example values: Qt6
# Output: SERVATRICE_QT_MODULES
# Output: COCKATRICE_QT_MODULES
# Output: ORACLE_QT_MODULES
# Output: TEST_QT_MODULES
#
# Inputs:
# WITH_SERVER
# WITH_CLIENT
# WITH_ORACLE
# TEST
#
# Outputs:
# COCKATRICE_QT_VERSION_NAME
# QT_CORE_MODULE
# SERVATRICE_QT_MODULES
# COCKATRICE_QT_MODULES
# ORACLE_QT_MODULES
# TEST_QT_MODULES
# QT_LIBRARY_DIR
# QT_PLUGINS_DIR
set(REQUIRED_QT_COMPONENTS Core)
if(WITH_SERVER)
set(_SERVATRICE_NEEDED Network Sql WebSockets)
endif()
if(WITH_CLIENT)
set(_COCKATRICE_NEEDED
Concurrent
Gui
Multimedia
Network
PrintSupport
ShaderTools
Svg
WebSockets
Widgets
Xml
Quick
QuickWidgets
)
endif()
if(WITH_ORACLE)
set(_ORACLE_NEEDED 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)
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}
)
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)
if(QT6_LRELEASE_INDEX EQUAL -1)
# ---------------------------------------------------------------------------
# Define the Qt components required by each target
# ---------------------------------------------------------------------------
set(SERVATRICE_QT_COMPONENTS Network Sql WebSockets)
set(COCKATRICE_QT_COMPONENTS
Concurrent
Gui
Multimedia
Network
PrintSupport
ShaderTools
Svg
WebSockets
Widgets
Xml
Quick
QuickWidgets
)
set(ORACLE_QT_COMPONENTS Concurrent Network Svg Widgets)
set(TEST_QT_COMPONENTS Concurrent Network Svg Widgets)
# ---------------------------------------------------------------------------
# Determine which Qt components are required for this build
# ---------------------------------------------------------------------------
set(REQUIRED_QT_COMPONENTS Core)
if(WITH_SERVER)
list(APPEND REQUIRED_QT_COMPONENTS ${SERVATRICE_QT_COMPONENTS})
endif()
if(WITH_CLIENT)
list(APPEND REQUIRED_QT_COMPONENTS ${COCKATRICE_QT_COMPONENTS})
endif()
if(WITH_ORACLE)
list(APPEND REQUIRED_QT_COMPONENTS ${ORACLE_QT_COMPONENTS})
endif()
if(TEST)
list(APPEND REQUIRED_QT_COMPONENTS ${TEST_QT_COMPONENTS})
endif()
list(REMOVE_DUPLICATES REQUIRED_QT_COMPONENTS)
# ---------------------------------------------------------------------------
# Find Qt and define minimum version centrally
# ---------------------------------------------------------------------------
find_package(Qt6 6.4 REQUIRED COMPONENTS ${REQUIRED_QT_COMPONENTS} Linguist)
# ---------------------------------------------------------------------------
# Convert a component list such as:
# Network;Sql;WebSockets
# into:
# Qt6::Network;Qt6::Sql;Qt6::WebSockets
# ---------------------------------------------------------------------------
function(_qt_components_to_targets COMPONENTS OUTPUT_VARIABLE)
set(TARGETS)
foreach(COMPONENT IN LISTS COMPONENTS)
list(APPEND TARGETS "${COCKATRICE_QT_VERSION_NAME}::${COMPONENT}")
endforeach()
set(${OUTPUT_VARIABLE}
"${TARGETS}"
PARENT_SCOPE
)
endfunction()
# ---------------------------------------------------------------------------
# Export Qt target lists for the individual targets
# ---------------------------------------------------------------------------
if(WITH_SERVER)
_qt_components_to_targets("${SERVATRICE_QT_COMPONENTS}" SERVATRICE_QT_MODULES)
endif()
if(WITH_CLIENT)
_qt_components_to_targets("${COCKATRICE_QT_COMPONENTS}" COCKATRICE_QT_MODULES)
endif()
if(WITH_ORACLE)
_qt_components_to_targets("${ORACLE_QT_COMPONENTS}" ORACLE_QT_MODULES)
endif()
if(TEST)
_qt_components_to_targets("${TEST_QT_COMPONENTS}" TEST_QT_MODULES)
endif()
# Core-only export (useful for headless libraries)
set(QT_CORE_MODULE "${COCKATRICE_QT_VERSION_NAME}::Core")
# ---------------------------------------------------------------------------
# Qt Linguist tools
# ---------------------------------------------------------------------------
if(TARGET Qt6::lrelease)
set(QT6_LRELEASE_INDEX 0)
else()
message(WARNING "Qt6 lrelease not found.")
endif()
list(FIND Qt6LinguistTools_TARGETS Qt6::lupdate QT6_LUPDATE_INDEX)
if(QT6_LUPDATE_INDEX EQUAL -1)
if(TARGET Qt6::lupdate)
set(QT6_LUPDATE_INDEX 0)
else()
message(WARNING "Qt6 lupdate not found.")
endif()
# ---------------------------------------------------------------------------
# Qt runtime/plugin paths
# ---------------------------------------------------------------------------
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Establish Qt Plugins directory & Library directories
get_target_property(QT_LIBRARY_DIR ${COCKATRICE_QT_VERSION_NAME}::Core LOCATION)
get_filename_component(QT_LIBRARY_DIR ${QT_LIBRARY_DIR} DIRECTORY)
if(NOT TARGET Qt6::Core)
message(FATAL_ERROR "Qt6::Core target is not available")
endif()
get_target_property(QT_LIBRARY_DIR Qt6::Core LOCATION)
get_filename_component(QT_LIBRARY_DIR "${QT_LIBRARY_DIR}" DIRECTORY)
get_filename_component(QT_PLUGINS_DIR "${Qt6Core_DIR}/../../../${QT6_INSTALL_PLUGINS}" ABSOLUTE)
get_filename_component(QT_LIBRARY_DIR "${QT_LIBRARY_DIR}/../../.." ABSOLUTE)
if(UNIX AND APPLE)
# Mac needs a bit more help finding all necessary components
# macOS needs a bit more help finding all necessary components.
list(APPEND QT_LIBRARY_DIR "/usr/local/lib")
endif()
# ---------------------------------------------------------------------------
# Debug information
# ---------------------------------------------------------------------------
message(DEBUG "QT_PLUGINS_DIR = ${QT_PLUGINS_DIR}")
message(DEBUG "QT_LIBRARY_DIR = ${QT_LIBRARY_DIR}")
# Establish exports
string(REGEX REPLACE "([^;]+)" "${COCKATRICE_QT_VERSION_NAME}::\\1" SERVATRICE_QT_MODULES "${_SERVATRICE_NEEDED}")
string(REGEX REPLACE "([^;]+)" "${COCKATRICE_QT_VERSION_NAME}::\\1" COCKATRICE_QT_MODULES "${_COCKATRICE_NEEDED}")
string(REGEX REPLACE "([^;]+)" "${COCKATRICE_QT_VERSION_NAME}::\\1" ORACLE_QT_MODULES "${_ORACLE_NEEDED}")
string(REGEX REPLACE "([^;]+)" "${COCKATRICE_QT_VERSION_NAME}::\\1" TEST_QT_MODULES "${_TEST_NEEDED}")
message(STATUS "Qt6_VERSION = ${Qt6_VERSION}")
message(STATUS "Qt6_DIR = ${Qt6_DIR}")
message(STATUS "Qt6Core_DIR = ${Qt6Core_DIR}")
message(STATUS "REQUIRED_QT_COMPONENTS = ${REQUIRED_QT_COMPONENTS}")
# Core-only export (useful for headless libs)
set(QT_CORE_MODULE "${COCKATRICE_QT_VERSION_NAME}::Core")
message(STATUS "Found Qt ${${COCKATRICE_QT_VERSION_NAME}_VERSION} at: ${${COCKATRICE_QT_VERSION_NAME}_DIR}")
if(WITH_CLIENT)
message(STATUS "COCKATRICE_QT_MODULES = ${COCKATRICE_QT_MODULES}")
endif()
if(WITH_ORACLE)
message(STATUS "ORACLE_QT_MODULES = ${ORACLE_QT_MODULES}")
endif()
if(WITH_SERVER)
message(STATUS "SERVATRICE_QT_MODULES = ${SERVATRICE_QT_MODULES}")
endif()
if(TEST)
message(STATUS "TEST_QT_MODULES = ${TEST_QT_MODULES}")
endif()

View file

@ -370,6 +370,6 @@ LangString DESC_SecStartMenu ${LANG_ENGLISH} "Create start menu items for Cockat
LangString DESC_UnSecApplication ${LANG_ENGLISH} "Cockatrice program files and start menu items"
LangString DESC_UnSecConfiguration ${LANG_ENGLISH} "Configurations, decks, card database, pictures"
!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${UnSecApplication} $(DESC_UnSecApplication)
!insertmacro MUI_DESCRIPTION_TEXT ${UnSecConfiguration} $(DESC_UnSecConfiguration)
!insertmacro MUI_DESCRIPTION_TEXT ${UnSecApplication} $(DESC_UnSecApplication)
!insertmacro MUI_DESCRIPTION_TEXT ${UnSecConfiguration} $(DESC_UnSecConfiguration)
!insertmacro MUI_UNFUNCTION_DESCRIPTION_END

View file

@ -595,7 +595,7 @@ if(APPLE)
set(plugin_dest_dir cockatrice.app/Contents/Plugins)
set(qtconf_dest_dir cockatrice.app/Contents/Resources)
# Qt plugins: iconengines, imageformats, multimedia (Qt6), platforms, styles, tls (Qt6)
# Qt plugins: iconengines, imageformats, multimedia, platforms, styles, tls
install(
DIRECTORY "${QT_PLUGINS_DIR}/"
DESTINATION ${plugin_dest_dir}
@ -660,7 +660,7 @@ if(WIN32) # Windows (including 64bit)
PATTERN "*.ini"
)
# Qt plugins: iconengines, imageformats, multimedia (Qt6) platforms, styles, tls (Qt6)
# Qt plugins: iconengines, imageformats, multimedia, platforms, styles, tls
install(
DIRECTORY "${QT_PLUGINS_DIR}/"
DESTINATION ${plugin_dest_dir}

View file

@ -16,7 +16,6 @@ class CardInfo;
class AbstractCardDragItem : public QObject, public QGraphicsItem
{
Q_OBJECT
Q_INTERFACES(QGraphicsItem)
protected:
AbstractCardItem *item;
QPointF hotSpot;

View file

@ -23,7 +23,6 @@ class QString;
class AbstractCounter : public QObject, public QGraphicsItem, public AbstractPlayerComponent
{
Q_OBJECT
Q_INTERFACES(QGraphicsItem)
protected:
PlayerLogic *player;

View file

@ -19,7 +19,6 @@ class PlayerLogic;
class ArrowItem : public QObject, public QGraphicsItem, public IAnimatedItem
{
Q_OBJECT
Q_INTERFACES(QGraphicsItem)
signals:
void requestDeletion(int creatorId, int id);

View file

@ -27,7 +27,6 @@ class GameCommand;
class PhaseButton : public QObject, public QGraphicsItem
{
Q_OBJECT
Q_INTERFACES(QGraphicsItem)
private:
QString name;
bool active, highlightable;
@ -65,7 +64,6 @@ protected:
class PhasesToolbar : public QObject, public QGraphicsItem
{
Q_OBJECT
Q_INTERFACES(QGraphicsItem)
private:
QList<PhaseButton *> buttonList;
PhaseButton *nextTurnButton;

View file

@ -16,7 +16,6 @@
class PlayerArea : public QObject, public QGraphicsItem
{
Q_OBJECT
Q_INTERFACES(QGraphicsItem)
private:
QRectF bRect;
int playerZoneId;

View file

@ -34,7 +34,6 @@ class QGraphicsSceneWheelEvent;
class ZoneViewZone : public SelectZone, public QGraphicsLayoutItem
{
Q_OBJECT
Q_INTERFACES(QGraphicsLayoutItem)
private:
static constexpr int HORIZONTAL_PADDING = 12;
static constexpr int VERTICAL_PADDING = 5;