Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 34 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@ set(CMAKE_OSX_DEPLOYMENT_TARGET 10.13)

project(chessx LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

option(ENABLE_SOUNDS "Enable sounds (requires Qt5::Multimedia)" ON)
option(ENABLE_TTS "Enable text-to-speech (requires Qt5::TextToSpeech)" ON)
option(ENABLE_SOUNDS "Enable sounds (requires Qt6::Multimedia)" ON)
option(ENABLE_TTS "Enable text-to-speech (requires Qt6::TextToSpeech)" ON)
option(ENABLE_SCID_SUPPORT "Enable support for Scid database format (*.si4)" ON)

add_subdirectory(dep)

# common definitions to use with Qt
add_library(qt_config INTERFACE)
target_compile_definitions(qt_config INTERFACE
Expand All @@ -23,7 +22,7 @@ target_compile_definitions(qt_config INTERFACE
)

set(REQUIRED_QT_COMPONENTS
Core Xml DBus Network OpenGL Svg PrintSupport Gui Widgets
Core Xml DBus Network OpenGL Svg PrintSupport Gui Widgets Core5Compat
)

if (ENABLE_SOUNDS)
Expand All @@ -34,7 +33,7 @@ if (ENABLE_TTS)
list(APPEND REQUIRED_QT_COMPONENTS TextToSpeech)
endif()

find_package(Qt5 REQUIRED
find_package(Qt6 REQUIRED
LinguistTools
"${REQUIRED_QT_COMPONENTS}"
Test
Expand All @@ -61,7 +60,7 @@ set_source_files_properties(${TRANSLATIONS_SRC_FILES}
OUTPUT_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/i18n"
)

qt5_add_translation(TRANSLATIONS_BIN_FILES ${TRANSLATIONS_SRC_FILES})
qt6_add_translation(TRANSLATIONS_BIN_FILES ${TRANSLATIONS_SRC_FILES})

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
Expand Down Expand Up @@ -110,6 +109,7 @@ target_link_libraries(chessx PRIVATE
board
eco
gui
Qt6::Multimedia
)

if (CMAKE_HOST_APPLE)
Expand Down Expand Up @@ -149,3 +149,30 @@ if (ENABLE_TESTING)
add_subdirectory(tests/unittests)
endif()

if (ENABLE_SOUNDS)
target_compile_definitions(chessx
PRIVATE
USE_SOUND
)
target_link_libraries(chessx PRIVATE Qt6::Multimedia)
if (UNIX AND NOT APPLE)
# on Linux QtMultimedia links to pulseaudio
find_package(PulseAudio REQUIRED)
target_link_libraries(chessx
PRIVATE
${PULSEAUDIO_LIBRARY}
${PULSEAUDIO_MAINLOOP_LIBRARY}
)
endif()
endif()

if (ENABLE_TTS)
target_compile_definitions(chessx
PRIVATE
USE_SPEECH
)
target_link_libraries(chessx PRIVATE Qt6::TextToSpeech)
endif()



16 changes: 9 additions & 7 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@ Windows.

# 3. Requirements

To compile ChessX, you need zlib, qmake and **Qt5 version 5.14.1** or above.

**known issue:** FICS does not work properly with Qt4
To compile ChessX, you need zlib, qmake and **Qt6 version 6** or above. (Last built on 6.6.2)

# 4. Compilation

Compiling the source is simple. Execute:

qmake
qmake6

and then

Expand All @@ -43,17 +41,21 @@ and then
If the compilation is successful you should be able to run ChessX
executable in **bin** (or **release**) subdirectory. It is called: **chessx** on Linux, **chessx.app** on Mac OS, and **chessx.exe** on Windows

On Windows you should then run the following to install the required dlls into the release directory:

windeployqt release

## 4.1 Compilation in Linux x64 systems

On Linux x64, the following commands are required for successful compilation:

Build the translations

lrelease-qt5 chessx.pro
lrelease chessx.pro

Run qmake, specifically qt5 version
Run qmake, specifically qt6 version

qmake-qt5
qmake6

Compile with

Expand Down
5 changes: 2 additions & 3 deletions chessx.pro
Original file line number Diff line number Diff line change
Expand Up @@ -531,9 +531,8 @@ INCLUDEPATH += src/quazip
INCLUDEPATH += $$[QT_INSTALL_PREFIX]/src/3rdparty/zlib

win32 {
# DEFINES += ZLIB_WINAPI
# LIBS += -lz
INCLUDEPATH += $$[QT_INSTALL_HEADERS]/QtZlib
DEFINES += ZLIB_WINAPI
LIBS += -lz
win32-g++:LIBS += -lz
}

Expand Down
27 changes: 15 additions & 12 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ target_link_libraries(bitboard
PRIVATE
qt_config
PUBLIC
Qt5::Core
Qt6::Core
)

if (cxx_std_11 IN_LIST CMAKE_CXX_COMPILE_FEATURES)
Expand Down Expand Up @@ -79,7 +79,7 @@ target_link_libraries(eco
PUBLIC
board
gui
Qt5::Core
Qt6::Core
)

add_library(database-core STATIC
Expand Down Expand Up @@ -235,17 +235,20 @@ target_include_directories(database
database
PRIVATE
gui

)

target_link_libraries(database
PRIVATE
qt_config
Qt5::Widgets
Qt6::Widgets
PUBLIC
database-core
Qt5::Core
Qt5::Gui
Qt5::Network
Qt6::Core
Qt6::Gui
Qt6::Network
Qt6::Core5Compat

)

if (ENABLE_SCID_SUPPORT)
Expand Down Expand Up @@ -461,20 +464,20 @@ target_link_libraries(gui
qt_config
eco
quazip
Qt5::PrintSupport
Qt5::Svg
Qt6::PrintSupport
Qt6::Svg
PUBLIC
database
Qt5::Widgets
Qt5::Xml
Qt6::Widgets
Qt6::Xml
)

if (ENABLE_SOUNDS)
target_compile_definitions(gui
PRIVATE
USE_SOUND
)
target_link_libraries(gui PRIVATE Qt5::Multimedia)
target_link_libraries(gui PRIVATE Qt6::Multimedia)
if (UNIX AND NOT APPLE)
# on Linux QtMultimedia links to pulseaudio
find_package(PulseAudio REQUIRED)
Expand All @@ -491,6 +494,6 @@ if (ENABLE_TTS)
PRIVATE
USE_SPEECH
)
target_link_libraries(gui PRIVATE Qt5::TextToSpeech)
target_link_libraries(gui PRIVATE Qt6::TextToSpeech)
endif()

2 changes: 1 addition & 1 deletion src/database/polyglotdatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ using namespace chessx;

#define MAX_COUNT 16384

struct key_compare : std::__binary_function< const book_entry&, const book_entry&, bool >
struct key_compare
{
bool operator()( const book_entry& a, const book_entry& b ) const
{
Expand Down
3 changes: 2 additions & 1 deletion src/quazip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ target_link_libraries(quazip
qt_config
PUBLIC
ZLIB::ZLIB
Qt5::Core
Qt6::Core
Qt6::Core5Compat
)

58 changes: 58 additions & 0 deletions src/quazip/qt6compat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#ifndef QT6COMPAT_H

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is a duplicate of src/gui/qt6compat.h.

#define QT6COMPAT_H

#include <QtGlobal>

#ifdef USE_SOUND
#if QT_VERSION < 0x060000
#include <QSound>
#else
#include <QSoundEffect>
class QSound : public QSoundEffect {
public:
QSound(const QString& url) : QSoundEffect()
{
setSource(QUrl(url));
}
void play()
{
QSoundEffect::play();
}
static void play(const QString& url)
{
static QSoundEffect effect;
effect.setSource(QUrl(url));
effect.play();
}
};
#endif
#endif

#if QT_VERSION < 0x060000
#include <QTextCodec>
#define SET_CODEC_UTF8(s) \
QTextCodec* textCodec = QTextCodec::codecForName("utf8"); \
if(textCodec) s.setCodec(textCodec);
#define SET_CODEC_LATIN1(s) \
QTextCodec* textCodec = QTextCodec::codecForName("ISO 8859-1"); \
if(textCodec) s.setCodec(textCodec);
#else
#include <QStringConverter>
#define SET_CODEC_UTF8(s) s.setEncoding(QStringConverter::Utf8);
#define SET_CODEC_LATIN1(s) s.setEncoding(QStringConverter::Latin1);
#endif

#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
#include <QtCore/QString>
constexpr auto SkipEmptyParts = QString::SkipEmptyParts;
#else
using Qt::SkipEmptyParts;
#endif

#if QT_VERSION < 0x060000
#define EVENT_POSITION(event) (event)->pos()
#else
#define EVENT_POSITION(event) (event)->position().toPoint()
#endif

#endif // QT6COMPAT_H