fix: CMake problems found by the openBSD package (#1422)

* fix: CMake problems found by openBSD package

* remove unused WITH_XAPIAN option
* don't link Qt TTS if not requested

* fix: address CMake problems found by openBSD package

* remove unused WITH_XAPIAN option
* don't link Qt TTS if not requested
* Disable some code when TTS is not requested

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
shenleban tongying 2024-03-19 23:08:17 -04:00 committed by GitHub
parent ebce607634
commit b9e14f806c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 98 additions and 81 deletions

View file

@ -4,7 +4,6 @@ cmake_minimum_required(VERSION 3.25) # ubuntu 23.04 Fedora 36
option(WITH_FFMPEG_PLAYER "Enable support for FFMPEG player" ON) option(WITH_FFMPEG_PLAYER "Enable support for FFMPEG player" ON)
option(WITH_EPWING_SUPPORT "Enable epwing support" ON) option(WITH_EPWING_SUPPORT "Enable epwing support" ON)
option(WITH_XAPIAN "enable Xapian support" ON)
option(WITH_ZIM "enable zim support" ON) option(WITH_ZIM "enable zim support" ON)
option(WITH_TTS "enable QTexttoSpeech support" ON) option(WITH_TTS "enable QTexttoSpeech support" ON)
@ -36,18 +35,13 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
#### Qt #### Qt
find_package(Qt6 REQUIRED COMPONENTS set(GD_QT_COMPONENTS Concurrent Core5Compat LinguistTools Multimedia PrintSupport WebEngineWidgets Widgets Svg Xml)
Concurrent
Core5Compat if (WITH_TTS)
LinguistTools list(APPEND GD_QT_COMPONENTS TextToSpeech)
Multimedia endif ()
PrintSupport
WebEngineWidgets find_package(Qt6 REQUIRED COMPONENTS ${GD_QT_COMPONENTS})
Widgets
Svg
Xml
TextToSpeech
)
qt_standard_project_setup() # availiable after find_package(Qt6 .... Core qt_standard_project_setup() # availiable after find_package(Qt6 .... Core
set(CMAKE_AUTORCC ON) # not included in the qt_standard_project_setup set(CMAKE_AUTORCC ON) # not included in the qt_standard_project_setup
@ -130,9 +124,11 @@ target_link_libraries(${GOLDENDICT} PRIVATE
Qt6::WebEngineWidgets Qt6::WebEngineWidgets
Qt6::Widgets Qt6::Widgets
Qt6::Svg Qt6::Svg
Qt6::TextToSpeech
) )
if (WITH_TTS)
target_link_libraries(${GOLDENDICT} PRIVATE Qt6::TextToSpeech)
endif ()
target_include_directories(${GOLDENDICT} PRIVATE target_include_directories(${GOLDENDICT} PRIVATE
${PROJECT_SOURCE_DIR}/thirdparty/qtsingleapplication/src ${PROJECT_SOURCE_DIR}/thirdparty/qtsingleapplication/src
@ -172,11 +168,6 @@ if (NOT WITH_EPWING_SUPPORT)
target_compile_definitions(${GOLDENDICT} PUBLIC NO_EPWING_SUPPORT) target_compile_definitions(${GOLDENDICT} PUBLIC NO_EPWING_SUPPORT)
endif () endif ()
if (WITH_XAPIAN)
target_compile_definitions(${GOLDENDICT} PUBLIC USE_XAPIAN)
endif ()
if (WITH_ZIM) if (WITH_ZIM)
target_compile_definitions(${GOLDENDICT} PUBLIC MAKE_ZIM_SUPPORT) target_compile_definitions(${GOLDENDICT} PUBLIC MAKE_ZIM_SUPPORT)
endif () endif ()

View file

@ -28,13 +28,10 @@ endif ()
##### Finding packages from package manager ##### Finding packages from package manager
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
# Provided by Cmake
find_package(ZLIB REQUIRED) find_package(ZLIB REQUIRED)
find_package(BZip2 REQUIRED) find_package(BZip2 REQUIRED)
# Consider all PkgConfig dependencies as one # Consider all PkgConfig dependencies as one
pkg_check_modules(PKGCONFIG_DEPS IMPORTED_TARGET pkg_check_modules(PKGCONFIG_DEPS IMPORTED_TARGET
hunspell hunspell
@ -43,7 +40,8 @@ pkg_check_modules(PKGCONFIG_DEPS IMPORTED_TARGET
vorbis # .ogg vorbis # .ogg
vorbisfile vorbisfile
liblzma liblzma
) xapian-core
)
target_link_libraries(${GOLDENDICT} PRIVATE target_link_libraries(${GOLDENDICT} PRIVATE
PkgConfig::PKGCONFIG_DEPS PkgConfig::PKGCONFIG_DEPS
@ -69,15 +67,10 @@ if (WITH_FFMPEG_PLAYER)
libavformat libavformat
libavutil libavutil
libswresample libswresample
) )
target_link_libraries(${GOLDENDICT} PRIVATE PkgConfig::FFMPEG) target_link_libraries(${GOLDENDICT} PRIVATE PkgConfig::FFMPEG)
endif () endif ()
if (WITH_XAPIAN)
find_package(Xapian REQUIRED) # https://github.com/xapian/xapian/tree/master/xapian-core/cmake
target_link_libraries(${GOLDENDICT} PRIVATE ${XAPIAN_LIBRARIES})
endif ()
if (WITH_EPWING_SUPPORT) if (WITH_EPWING_SUPPORT)
find_library(EB_LIBRARY eb REQUIRED) find_library(EB_LIBRARY eb REQUIRED)
target_link_libraries(${GOLDENDICT} PRIVATE ${EB_LIBRARY}) target_link_libraries(${GOLDENDICT} PRIVATE ${EB_LIBRARY})

View file

@ -845,7 +845,7 @@ Class load()
// Upgrading // Upgrading
c.dictServers = makeDefaultDictServers(); c.dictServers = makeDefaultDictServers();
} }
#ifndef NO_TTS_SUPPORT
QDomNode ves = root.namedItem( "voiceEngines" ); QDomNode ves = root.namedItem( "voiceEngines" );
if ( !ves.isNull() ) { if ( !ves.isNull() ) {
@ -872,6 +872,7 @@ Class load()
c.voiceEngines.push_back( v ); c.voiceEngines.push_back( v );
} }
} }
#endif
c.mutedDictionaries = loadMutedDictionaries( root.namedItem( "mutedDictionaries" ) ); c.mutedDictionaries = loadMutedDictionaries( root.namedItem( "mutedDictionaries" ) );
c.popupMutedDictionaries = loadMutedDictionaries( root.namedItem( "popupMutedDictionaries" ) ); c.popupMutedDictionaries = loadMutedDictionaries( root.namedItem( "popupMutedDictionaries" ) );
@ -1664,7 +1665,7 @@ void save( Class const & c )
p.setAttributeNode( icon ); p.setAttributeNode( icon );
} }
} }
#ifndef NO_TTS_SUPPORT
{ {
QDomNode ves = dd.createElement( "voiceEngines" ); QDomNode ves = dd.createElement( "voiceEngines" );
root.appendChild( ves ); root.appendChild( ves );
@ -1706,6 +1707,7 @@ void save( Class const & c )
v.setAttributeNode( rate ); v.setAttributeNode( rate );
} }
} }
#endif
{ {
QDomElement muted = dd.createElement( "mutedDictionaries" ); QDomElement muted = dd.createElement( "mutedDictionaries" );

View file

@ -779,6 +779,7 @@ struct Program
typedef QVector< Program > Programs; typedef QVector< Program > Programs;
#ifndef NO_TTS_SUPPORT
struct VoiceEngine struct VoiceEngine
{ {
bool enabled; bool enabled;
@ -823,6 +824,7 @@ struct VoiceEngine
}; };
typedef QVector< VoiceEngine > VoiceEngines; typedef QVector< VoiceEngine > VoiceEngines;
#endif
struct HeadwordsDialog struct HeadwordsDialog
{ {
@ -856,7 +858,9 @@ struct Class
Lingua lingua; Lingua lingua;
Forvo forvo; Forvo forvo;
Programs programs; Programs programs;
#ifndef NO_TTS_SUPPORT
VoiceEngines voiceEngines; VoiceEngines voiceEngines;
#endif
unsigned lastMainGroupId; // Last used group in main window unsigned lastMainGroupId; // Last used group in main window
unsigned lastPopupGroupId; // Last used group in popup window unsigned lastPopupGroupId; // Last used group in popup window

View file

@ -269,7 +269,9 @@ void loadDictionaries( QWidget * parent,
addDicts( Forvo::makeDictionaries( loadDicts, cfg.forvo, dictNetMgr ) ); addDicts( Forvo::makeDictionaries( loadDicts, cfg.forvo, dictNetMgr ) );
addDicts( Lingua::makeDictionaries( loadDicts, cfg.lingua, dictNetMgr ) ); addDicts( Lingua::makeDictionaries( loadDicts, cfg.lingua, dictNetMgr ) );
addDicts( Programs::makeDictionaries( cfg.programs ) ); addDicts( Programs::makeDictionaries( cfg.programs ) );
#ifndef NO_TTS_SUPPORT
addDicts( VoiceEngines::makeDictionaries( cfg.voiceEngines ) ); addDicts( VoiceEngines::makeDictionaries( cfg.voiceEngines ) );
#endif
addDicts( DictServer::makeDictionaries( cfg.dictServers ) ); addDicts( DictServer::makeDictionaries( cfg.dictServers ) );

View file

@ -16,7 +16,9 @@ Sources::Sources( QWidget * parent, Config::Class const & cfg ):
#ifdef MAKE_CHINESE_CONVERSION_SUPPORT #ifdef MAKE_CHINESE_CONVERSION_SUPPORT
chineseConversion( new ChineseConversion( this, cfg.transliteration.chinese ) ), chineseConversion( new ChineseConversion( this, cfg.transliteration.chinese ) ),
#endif #endif
#ifndef NO_TTS_SUPPORT
textToSpeechSource( nullptr ), textToSpeechSource( nullptr ),
#endif
itemDelegate( new QItemDelegate( this ) ), itemDelegate( new QItemDelegate( this ) ),
itemEditorFactory( new QItemEditorFactory() ), itemEditorFactory( new QItemEditorFactory() ),
mediawikisModel( this, cfg.mediawikis ), mediawikisModel( this, cfg.mediawikis ),
@ -317,12 +319,14 @@ void Sources::on_removeProgram_clicked()
programsModel.removeProgram( current.row() ); programsModel.removeProgram( current.row() );
} }
#ifndef NO_TTS_SUPPORT
Config::VoiceEngines Sources::getVoiceEngines() const Config::VoiceEngines Sources::getVoiceEngines() const
{ {
if ( !textToSpeechSource ) if ( !textToSpeechSource )
return Config::VoiceEngines(); return Config::VoiceEngines();
return textToSpeechSource->getVoiceEnginesModel().getCurrentVoiceEngines(); return textToSpeechSource->getVoiceEnginesModel().getCurrentVoiceEngines();
} }
#endif
Config::Hunspell Sources::getHunspell() const Config::Hunspell Sources::getHunspell() const
{ {

View file

@ -296,9 +296,9 @@ public:
{ {
return programsModel.getCurrentPrograms(); return programsModel.getCurrentPrograms();
} }
#ifndef NO_TTS_SUPPORT
Config::VoiceEngines getVoiceEngines() const; Config::VoiceEngines getVoiceEngines() const;
#endif
Config::Hunspell getHunspell() const; Config::Hunspell getHunspell() const;
Config::Transliteration getTransliteration() const; Config::Transliteration getTransliteration() const;
@ -318,9 +318,9 @@ private:
#ifdef MAKE_CHINESE_CONVERSION_SUPPORT #ifdef MAKE_CHINESE_CONVERSION_SUPPORT
ChineseConversion * chineseConversion; ChineseConversion * chineseConversion;
#endif #endif
#ifndef NO_TTS_SUPPORT
TextToSpeechSource * textToSpeechSource; TextToSpeechSource * textToSpeechSource;
#endif
QItemDelegate * itemDelegate; QItemDelegate * itemDelegate;
QScopedPointer< QItemEditorFactory > itemEditorFactory; QScopedPointer< QItemEditorFactory > itemEditorFactory;

View file

@ -1,20 +1,21 @@
/* This file is (c) 2013 Timon Wong <timon86.wang@gmail.com> /* This file is (c) 2013 Timon Wong <timon86.wang@gmail.com>
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */ * Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
#ifndef NO_TTS_SUPPORT
#include "voiceengines.hh" #include "voiceengines.hh"
#include "audiolink.hh" #include "audiolink.hh"
#include "htmlescape.hh" #include "htmlescape.hh"
#include "utf8.hh" #include "utf8.hh"
#include "wstring_qt.hh" #include "wstring_qt.hh"
#include <string> #include <string>
#include <map> #include <map>
#include <QDir> #include <QDir>
#include <QFileInfo> #include <QFileInfo>
#include <QCryptographicHash> #include <QCryptographicHash>
#include "utils.hh" #include "utils.hh"
namespace VoiceEngines { namespace VoiceEngines {
@ -137,3 +138,5 @@ vector< sptr< Dictionary::Class > > makeDictionaries( Config::VoiceEngines const
} }
} // namespace VoiceEngines } // namespace VoiceEngines
#endif

View file

@ -1,14 +1,13 @@
/* This file is (c) 2013 Timon Wong <timon86.wang@gmail.com> /* This file is (c) 2013 Timon Wong <timon86.wang@gmail.com>
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */ * Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
#pragma once
#ifndef NO_TTS_SUPPORT
#ifndef __VOICEENGINES_HH_INCLUDED__ #include "dictionary.hh"
#define __VOICEENGINES_HH_INCLUDED__ #include "config.hh"
#include "wstring.hh"
#include "dictionary.hh" #include <QCryptographicHash>
#include "config.hh"
#include "wstring.hh"
#include <QCryptographicHash>
namespace VoiceEngines { namespace VoiceEngines {

View file

@ -488,7 +488,9 @@ int main( int argc, char ** argv )
if ( gdcl.notts ) { if ( gdcl.notts ) {
cfg.notts = true; cfg.notts = true;
#ifndef NO_TTS_SUPPORT
cfg.voiceEngines.clear(); cfg.voiceEngines.clear();
#endif
} }
cfg.resetState = gdcl.resetState; cfg.resetState = gdcl.resetState;

View file

@ -1,8 +1,10 @@
#include "speechclient.hh" #ifndef NO_TTS_SUPPORT
#include <QtCore> #include "speechclient.hh"
#include <QLocale>
#include <QDebug> #include <QtCore>
#include <QLocale>
#include <QDebug>
SpeechClient::SpeechClient( Config::VoiceEngine const & e, QObject * parent ): SpeechClient::SpeechClient( Config::VoiceEngine const & e, QObject * parent ):
QObject( parent ), QObject( parent ),
internalData( new InternalData( e ) ) internalData( new InternalData( e ) )
@ -67,3 +69,5 @@ bool SpeechClient::tell( QString const & text ) const
{ {
return tell( text, internalData->engine.volume, internalData->engine.rate ); return tell( text, internalData->engine.volume, internalData->engine.rate );
} }
#endif

View file

@ -1,12 +1,12 @@
#ifndef __SPEECHCLIENT_HH_INCLUDED__ #pragma once
#define __SPEECHCLIENT_HH_INCLUDED__ #ifndef NO_TTS_SUPPORT
#include <QObject> #include <QObject>
#include "config.hh" #include "config.hh"
#include <QTextToSpeech> #include <QTextToSpeech>
#include <memory> #include <memory>
#include <QDebug> #include <QDebug>
#include <QSharedPointer> #include <QSharedPointer>
class SpeechClient: public QObject class SpeechClient: public QObject
{ {
@ -81,4 +81,4 @@ private:
QSharedPointer< InternalData > internalData; QSharedPointer< InternalData > internalData;
}; };
#endif // __SPEECHCLIENT_HH_INCLUDED__ #endif

View file

@ -1,10 +1,11 @@
/* This file is (c) 2013 Timon Wong <timon86.wang@gmail.com> /* This file is (c) 2013 Timon Wong <timon86.wang@gmail.com>
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */ * Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
#ifndef NO_TTS_SUPPORT
#include "texttospeechsource.hh" #include "texttospeechsource.hh"
#include <QVariant> #include <QVariant>
#include <QMessageBox> #include <QMessageBox>
#include <memory> #include <memory>
TextToSpeechSource::TextToSpeechSource( QWidget * parent, Config::VoiceEngines voiceEngines ): TextToSpeechSource::TextToSpeechSource( QWidget * parent, Config::VoiceEngines voiceEngines ):
QWidget( parent ), QWidget( parent ),
@ -431,3 +432,5 @@ void VoiceEngineItemDelegate::setModelData( QWidget * uncastedEditor,
model->setData( engineIdIndex, editor->engineId() ); model->setData( engineIdIndex, editor->engineId() );
model->setData( engineNameIndex, editor->engineName() ); model->setData( engineNameIndex, editor->engineName() );
} }
#endif

View file

@ -1,15 +1,16 @@
/* This file is (c) 2013 Timon Wong <timon86.wang@gmail.com> /* This file is (c) 2013 Timon Wong <timon86.wang@gmail.com>
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */ * Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
#ifndef __TEXTTOSPEECHSOURCE_HH_INCLUDED__ #pragma once
#define __TEXTTOSPEECHSOURCE_HH_INCLUDED__
#include "ui_texttospeechsource.h" #ifndef NO_TTS_SUPPORT
#include "config.hh"
#include "speechclient.hh"
#include <QComboBox> #include "ui_texttospeechsource.h"
#include <QStyledItemDelegate> #include "config.hh"
#include "speechclient.hh"
#include <QComboBox>
#include <QStyledItemDelegate>
/// A model to be projected into the text to speech view, according to Qt's MVC model /// A model to be projected into the text to speech view, according to Qt's MVC model
class VoiceEnginesModel: public QAbstractItemModel class VoiceEnginesModel: public QAbstractItemModel
@ -116,4 +117,4 @@ private:
void adjustSliders(); void adjustSliders();
}; };
#endif // __TEXTTOSPEECHSOURCE_HH_INCLUDED__ #endif

View file

@ -1182,6 +1182,7 @@ void ArticleView::openLink( QUrl const & url, QUrl const & ref, QString const &
QMessageBox::critical( this, "GoldenDict", tr( "The referenced audio program doesn't exist." ) ); QMessageBox::critical( this, "GoldenDict", tr( "The referenced audio program doesn't exist." ) );
} }
else if ( url.scheme() == "gdtts" ) { else if ( url.scheme() == "gdtts" ) {
#ifndef NO_TTS_SUPPORT
// Text to speech // Text to speech
QString md5Id = Utils::Url::queryItemValue( url, "engine" ); QString md5Id = Utils::Url::queryItemValue( url, "engine" );
QString text( url.path().mid( 1 ) ); QString text( url.path().mid( 1 ) );
@ -1197,7 +1198,11 @@ void ArticleView::openLink( QUrl const & url, QUrl const & ref, QString const &
break; break;
} }
} }
#else
qDebug() << "gdtts:// is not supported due to missing TTS support";
#endif
} }
else if ( Utils::isExternalLink( url ) ) { else if ( Utils::isExternalLink( url ) ) {
// Use the system handler for the conventional external links // Use the system handler for the conventional external links
QDesktopServices::openUrl( url ); QDesktopServices::openUrl( url );

View file

@ -171,7 +171,11 @@ bool EditDictionaries::isSourcesChanged() const
|| sources.getHunspell() != cfg.hunspell || sources.getTransliteration() != cfg.transliteration || sources.getHunspell() != cfg.hunspell || sources.getTransliteration() != cfg.transliteration
|| sources.getLingua() != cfg.lingua || sources.getForvo() != cfg.forvo || sources.getMediaWikis() != cfg.mediawikis || sources.getLingua() != cfg.lingua || sources.getForvo() != cfg.forvo || sources.getMediaWikis() != cfg.mediawikis
|| sources.getWebSites() != cfg.webSites || sources.getDictServers() != cfg.dictServers || sources.getWebSites() != cfg.webSites || sources.getDictServers() != cfg.dictServers
|| sources.getPrograms() != cfg.programs || sources.getVoiceEngines() != cfg.voiceEngines; || sources.getPrograms() != cfg.programs
#ifndef NO_TTS_SUPPORT
|| sources.getVoiceEngines() != cfg.voiceEngines
#endif
;
} }
void EditDictionaries::acceptChangedSources( bool rebuildGroups ) void EditDictionaries::acceptChangedSources( bool rebuildGroups )
@ -192,8 +196,9 @@ void EditDictionaries::acceptChangedSources( bool rebuildGroups )
cfg.webSites = sources.getWebSites(); cfg.webSites = sources.getWebSites();
cfg.dictServers = sources.getDictServers(); cfg.dictServers = sources.getDictServers();
cfg.programs = sources.getPrograms(); cfg.programs = sources.getPrograms();
#ifndef NO_TTS_SUPPORT
cfg.voiceEngines = sources.getVoiceEngines(); cfg.voiceEngines = sources.getVoiceEngines();
#endif
ui.tabs->setUpdatesEnabled( false ); ui.tabs->setUpdatesEnabled( false );
// Those hold pointers to dictionaries, we need to free them. // Those hold pointers to dictionaries, we need to free them.
groupInstances.clear(); groupInstances.clear();

View file

@ -5,7 +5,6 @@
namespace Version { namespace Version {
const QLatin1String flags = QLatin1String( const QLatin1String flags = QLatin1String(
"USE_XAPIAN"
#ifdef MAKE_ZIM_SUPPORT #ifdef MAKE_ZIM_SUPPORT
" MAKE_ZIM_SUPPORT" " MAKE_ZIM_SUPPORT"
#endif #endif