Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: CMake problems found by the openBSD package #1422

Merged
Merged
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
29 changes: 10 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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_EPWING_SUPPORT "Enable epwing support" ON)
option(WITH_XAPIAN "enable Xapian support" ON)
option(WITH_ZIM "enable zim support" ON)
option(WITH_TTS "enable QTexttoSpeech support" ON)

Expand Down Expand Up @@ -36,18 +35,13 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)

#### Qt

find_package(Qt6 REQUIRED COMPONENTS
Concurrent
Core5Compat
LinguistTools
Multimedia
PrintSupport
WebEngineWidgets
Widgets
Svg
Xml
TextToSpeech
)
set(GD_QT_COMPONENTS Concurrent Core5Compat LinguistTools Multimedia PrintSupport WebEngineWidgets Widgets Svg Xml)

if (WITH_TTS)
list(APPEND GD_QT_COMPONENTS TextToSpeech)
endif ()

find_package(Qt6 REQUIRED COMPONENTS ${GD_QT_COMPONENTS})

qt_standard_project_setup() # availiable after find_package(Qt6 .... Core
set(CMAKE_AUTORCC ON) # not included in the qt_standard_project_setup
Expand Down Expand Up @@ -130,9 +124,11 @@ target_link_libraries(${GOLDENDICT} PRIVATE
Qt6::WebEngineWidgets
Qt6::Widgets
Qt6::Svg
Qt6::TextToSpeech
)

if (WITH_TTS)
target_link_libraries(${GOLDENDICT} PRIVATE Qt6::TextToSpeech)
endif ()

target_include_directories(${GOLDENDICT} PRIVATE
${PROJECT_SOURCE_DIR}/thirdparty/qtsingleapplication/src
Expand Down Expand Up @@ -172,11 +168,6 @@ if (NOT WITH_EPWING_SUPPORT)
target_compile_definitions(${GOLDENDICT} PUBLIC NO_EPWING_SUPPORT)
endif ()


if (WITH_XAPIAN)
target_compile_definitions(${GOLDENDICT} PUBLIC USE_XAPIAN)
endif ()

if (WITH_ZIM)
target_compile_definitions(${GOLDENDICT} PUBLIC MAKE_ZIM_SUPPORT)
endif ()
Expand Down
13 changes: 3 additions & 10 deletions CMake_Unix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,10 @@ endif ()

##### Finding packages from package manager


find_package(PkgConfig REQUIRED)
# Provided by Cmake
find_package(ZLIB REQUIRED)
find_package(BZip2 REQUIRED)


# Consider all PkgConfig dependencies as one
pkg_check_modules(PKGCONFIG_DEPS IMPORTED_TARGET
hunspell
Expand All @@ -43,7 +40,8 @@ pkg_check_modules(PKGCONFIG_DEPS IMPORTED_TARGET
vorbis # .ogg
vorbisfile
liblzma
)
xapian-core
)

target_link_libraries(${GOLDENDICT} PRIVATE
PkgConfig::PKGCONFIG_DEPS
Expand All @@ -69,15 +67,10 @@ if (WITH_FFMPEG_PLAYER)
libavformat
libavutil
libswresample
)
)
target_link_libraries(${GOLDENDICT} PRIVATE PkgConfig::FFMPEG)
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)
find_library(EB_LIBRARY eb REQUIRED)
target_link_libraries(${GOLDENDICT} PRIVATE ${EB_LIBRARY})
Expand Down
6 changes: 4 additions & 2 deletions src/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ Class load()
// Upgrading
c.dictServers = makeDefaultDictServers();
}

#ifndef NO_TTS_SUPPORT
QDomNode ves = root.namedItem( "voiceEngines" );

if ( !ves.isNull() ) {
Expand All @@ -872,6 +872,7 @@ Class load()
c.voiceEngines.push_back( v );
}
}
#endif

c.mutedDictionaries = loadMutedDictionaries( root.namedItem( "mutedDictionaries" ) );
c.popupMutedDictionaries = loadMutedDictionaries( root.namedItem( "popupMutedDictionaries" ) );
Expand Down Expand Up @@ -1664,7 +1665,7 @@ void save( Class const & c )
p.setAttributeNode( icon );
}
}

#ifndef NO_TTS_SUPPORT
{
QDomNode ves = dd.createElement( "voiceEngines" );
root.appendChild( ves );
Expand Down Expand Up @@ -1706,6 +1707,7 @@ void save( Class const & c )
v.setAttributeNode( rate );
}
}
#endif

{
QDomElement muted = dd.createElement( "mutedDictionaries" );
Expand Down
4 changes: 4 additions & 0 deletions src/config.hh
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ struct Program

typedef QVector< Program > Programs;

#ifndef NO_TTS_SUPPORT
struct VoiceEngine
{
bool enabled;
Expand Down Expand Up @@ -823,6 +824,7 @@ struct VoiceEngine
};

typedef QVector< VoiceEngine > VoiceEngines;
#endif

struct HeadwordsDialog
{
Expand Down Expand Up @@ -856,7 +858,9 @@ struct Class
Lingua lingua;
Forvo forvo;
Programs programs;
#ifndef NO_TTS_SUPPORT
VoiceEngines voiceEngines;
#endif

unsigned lastMainGroupId; // Last used group in main window
unsigned lastPopupGroupId; // Last used group in popup window
Expand Down
2 changes: 2 additions & 0 deletions src/dict/loaddictionaries.cc
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,9 @@ void loadDictionaries( QWidget * parent,
addDicts( Forvo::makeDictionaries( loadDicts, cfg.forvo, dictNetMgr ) );
addDicts( Lingua::makeDictionaries( loadDicts, cfg.lingua, dictNetMgr ) );
addDicts( Programs::makeDictionaries( cfg.programs ) );
#ifndef NO_TTS_SUPPORT
addDicts( VoiceEngines::makeDictionaries( cfg.voiceEngines ) );
#endif
addDicts( DictServer::makeDictionaries( cfg.dictServers ) );


Expand Down
4 changes: 4 additions & 0 deletions src/dict/sources.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ Sources::Sources( QWidget * parent, Config::Class const & cfg ):
#ifdef MAKE_CHINESE_CONVERSION_SUPPORT
chineseConversion( new ChineseConversion( this, cfg.transliteration.chinese ) ),
#endif
#ifndef NO_TTS_SUPPORT
textToSpeechSource( nullptr ),
#endif
itemDelegate( new QItemDelegate( this ) ),
itemEditorFactory( new QItemEditorFactory() ),
mediawikisModel( this, cfg.mediawikis ),
Expand Down Expand Up @@ -317,12 +319,14 @@ void Sources::on_removeProgram_clicked()
programsModel.removeProgram( current.row() );
}

#ifndef NO_TTS_SUPPORT
Config::VoiceEngines Sources::getVoiceEngines() const
{
if ( !textToSpeechSource )
return Config::VoiceEngines();
return textToSpeechSource->getVoiceEnginesModel().getCurrentVoiceEngines();
}
#endif

Config::Hunspell Sources::getHunspell() const
{
Expand Down
8 changes: 4 additions & 4 deletions src/dict/sources.hh
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,9 @@ public:
{
return programsModel.getCurrentPrograms();
}

#ifndef NO_TTS_SUPPORT
Config::VoiceEngines getVoiceEngines() const;

#endif
Config::Hunspell getHunspell() const;

Config::Transliteration getTransliteration() const;
Expand All @@ -318,9 +318,9 @@ private:
#ifdef MAKE_CHINESE_CONVERSION_SUPPORT
ChineseConversion * chineseConversion;
#endif

#ifndef NO_TTS_SUPPORT
TextToSpeechSource * textToSpeechSource;

#endif
QItemDelegate * itemDelegate;
QScopedPointer< QItemEditorFactory > itemEditorFactory;

Expand Down
25 changes: 14 additions & 11 deletions src/dict/voiceengines.cc
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
/* This file is (c) 2013 Timon Wong <timon86.wang@gmail.com>
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
#ifndef NO_TTS_SUPPORT

#include "voiceengines.hh"
#include "audiolink.hh"
#include "htmlescape.hh"
#include "utf8.hh"
#include "wstring_qt.hh"
#include "voiceengines.hh"
#include "audiolink.hh"
#include "htmlescape.hh"
#include "utf8.hh"
#include "wstring_qt.hh"

#include <string>
#include <map>
#include <string>
#include <map>

#include <QDir>
#include <QFileInfo>
#include <QCryptographicHash>
#include <QDir>
#include <QFileInfo>
#include <QCryptographicHash>

#include "utils.hh"
#include "utils.hh"

namespace VoiceEngines {

Expand Down Expand Up @@ -137,3 +138,5 @@ vector< sptr< Dictionary::Class > > makeDictionaries( Config::VoiceEngines const
}

} // namespace VoiceEngines

#endif
13 changes: 6 additions & 7 deletions src/dict/voiceengines.hh
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
/* This file is (c) 2013 Timon Wong <timon86.wang@gmail.com>
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
#pragma once
#ifndef NO_TTS_SUPPORT

#ifndef __VOICEENGINES_HH_INCLUDED__
#define __VOICEENGINES_HH_INCLUDED__
#include "dictionary.hh"
#include "config.hh"
#include "wstring.hh"

#include "dictionary.hh"
#include "config.hh"
#include "wstring.hh"

#include <QCryptographicHash>
#include <QCryptographicHash>


namespace VoiceEngines {
Expand Down
2 changes: 2 additions & 0 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,9 @@ int main( int argc, char ** argv )

if ( gdcl.notts ) {
cfg.notts = true;
#ifndef NO_TTS_SUPPORT
cfg.voiceEngines.clear();
#endif
}

cfg.resetState = gdcl.resetState;
Expand Down
12 changes: 8 additions & 4 deletions src/speechclient.cc
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#include "speechclient.hh"
#ifndef NO_TTS_SUPPORT

#include <QtCore>
#include <QLocale>
#include <QDebug>
#include "speechclient.hh"

#include <QtCore>
#include <QLocale>
#include <QDebug>
SpeechClient::SpeechClient( Config::VoiceEngine const & e, QObject * parent ):
QObject( parent ),
internalData( new InternalData( e ) )
Expand Down Expand Up @@ -67,3 +69,5 @@ bool SpeechClient::tell( QString const & text ) const
{
return tell( text, internalData->engine.volume, internalData->engine.rate );
}

#endif
18 changes: 9 additions & 9 deletions src/speechclient.hh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#ifndef __SPEECHCLIENT_HH_INCLUDED__
#define __SPEECHCLIENT_HH_INCLUDED__
#pragma once
#ifndef NO_TTS_SUPPORT

#include <QObject>
#include "config.hh"
#include <QTextToSpeech>
#include <memory>
#include <QDebug>
#include <QSharedPointer>
#include <QObject>
#include "config.hh"
#include <QTextToSpeech>
#include <memory>
#include <QDebug>
#include <QSharedPointer>

class SpeechClient: public QObject
{
Expand Down Expand Up @@ -81,4 +81,4 @@ private:
QSharedPointer< InternalData > internalData;
};

#endif // __SPEECHCLIENT_HH_INCLUDED__
#endif
11 changes: 7 additions & 4 deletions src/texttospeechsource.cc
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/* This file is (c) 2013 Timon Wong <timon86.wang@gmail.com>
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
#ifndef NO_TTS_SUPPORT

#include "texttospeechsource.hh"
#include <QVariant>
#include <QMessageBox>
#include <memory>
#include "texttospeechsource.hh"
#include <QVariant>
#include <QMessageBox>
#include <memory>

TextToSpeechSource::TextToSpeechSource( QWidget * parent, Config::VoiceEngines voiceEngines ):
QWidget( parent ),
Expand Down Expand Up @@ -431,3 +432,5 @@ void VoiceEngineItemDelegate::setModelData( QWidget * uncastedEditor,
model->setData( engineIdIndex, editor->engineId() );
model->setData( engineNameIndex, editor->engineName() );
}

#endif
17 changes: 9 additions & 8 deletions src/texttospeechsource.hh
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
/* This file is (c) 2013 Timon Wong <timon86.wang@gmail.com>
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */

#ifndef __TEXTTOSPEECHSOURCE_HH_INCLUDED__
#define __TEXTTOSPEECHSOURCE_HH_INCLUDED__
#pragma once

#include "ui_texttospeechsource.h"
#include "config.hh"
#include "speechclient.hh"
#ifndef NO_TTS_SUPPORT

#include <QComboBox>
#include <QStyledItemDelegate>
#include "ui_texttospeechsource.h"
#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
class VoiceEnginesModel: public QAbstractItemModel
Expand Down Expand Up @@ -116,4 +117,4 @@ private:
void adjustSliders();
};

#endif // __TEXTTOSPEECHSOURCE_HH_INCLUDED__
#endif
Loading
Loading