Skip to content
This repository was archived by the owner on May 8, 2024. It is now read-only.

Commit c2feea4

Browse files
committed
Fix cxx detection, update flags, and fix warnings.
1 parent 2fa77d2 commit c2feea4

File tree

7 files changed

+32
-21
lines changed

7 files changed

+32
-21
lines changed

CMakeLists.txt

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,25 @@ include(CMakePackageConfigHelpers)
2121
include(ECMSetupVersion)
2222
include(ECMGenerateHeaders)
2323

24-
include(CheckCXXCompilerFlag)
25-
26-
check_cxx_compiler_flag("-std=gnu++17" SUPPORT_CXX17)
27-
28-
if(NOT SUPPORT_CXX11)
29-
message(FATAL_ERROR "need c++ 17 compatible compiler to compile")
24+
set(CMAKE_CXX_EXTENSIONS OFF)
25+
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
26+
set(CMAKE_CXX_STANDARD 17)
27+
28+
set(CMAKE_C_FLAGS "-Wall -Wextra ${CMAKE_C_FLAGS}")
29+
set(CMAKE_CXX_FLAGS "-Wall -Wextra ${CMAKE_CXX_FLAGS}")
30+
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined -Wl,--as-needed ${CMAKE_SHARED_LINKER_FLAGS}")
31+
set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--no-undefined -Wl,--as-needed ${CMAKE_MODULE_LINKER_FLAGS}")
32+
33+
set(CMAKE_C_VISIBILITY_PRESET hidden)
34+
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
35+
set(CMAKE_VISIBILITY_INLINES_HIDDEN On)
36+
37+
if (POLICY CMP0063)
38+
# No sane project should be affected by CMP0063, so suppress the warnings
39+
# generated by the above visibility settings in CMake >= 3.3
40+
cmake_policy(SET CMP0063 NEW)
3041
endif()
3142

32-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++17 -Wall")
33-
3443
find_package(XKBCommon 0.5.0 REQUIRED COMPONENTS XKBCommon)
3544

3645
if (ENABLE_LIBRARY)

qt5/platforminputcontext/fcitxwatcher.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ void FcitxWatcher::unwatchSocketFile() {
265265
m_fsWatcher->disconnect(SIGNAL(directoryChanged(QString)));
266266
}
267267

268-
void FcitxWatcher::imChanged(const QString &service, const QString &oldOwner,
268+
void FcitxWatcher::imChanged(const QString &service, const QString &,
269269
const QString &newOwner) {
270270
if (service == m_serviceName) {
271271
if (!newOwner.isEmpty()) {

qt5/quickphrase-editor/editor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ QString ListEditor::addon() { return "fcitx-quickphrase"; }
116116

117117
bool ListEditor::asyncSave() { return true; }
118118

119-
void ListEditor::changeFile(int newIndex) {
119+
void ListEditor::changeFile(int) {
120120
if (m_model->needSave()) {
121121
int ret = QMessageBox::question(
122122
this, _("Save Changes"),

qt5/quickphrase-editor/filelistmodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fcitx::FileListModel::FileListModel(QObject *parent)
2828

2929
fcitx::FileListModel::~FileListModel() {}
3030

31-
int fcitx::FileListModel::rowCount(const QModelIndex &parent) const {
31+
int fcitx::FileListModel::rowCount(const QModelIndex &) const {
3232
return m_fileList.size();
3333
}
3434

qt5/quickphrase-editor/model.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ void QuickPhraseModel::deleteAllItem() {
103103

104104
Qt::ItemFlags QuickPhraseModel::flags(const QModelIndex &index) const {
105105
if (!index.isValid())
106-
return 0;
106+
return {};
107107

108108
return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
109109
}

qt5/widgetsaddons/fcitxqtkeysequencewidget.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class FcitxQtKeySequenceWidgetPrivate {
8888
}
8989

9090
// private slot
91-
void doneRecording(bool validate = true);
91+
void doneRecording();
9292

9393
// members
9494
FcitxQtKeySequenceWidget *const q;
@@ -198,6 +198,7 @@ QKeySequence FcitxQtKeySequenceWidget::keySequence() const {
198198
void FcitxQtKeySequenceWidget::setKeySequence(
199199
const QKeySequence &seq, FcitxQtModifierSide side,
200200
FcitxQtKeySequenceWidget::Validation validate) {
201+
Q_UNUSED(validate);
201202
// oldKeySequence holds the key sequence before recording started, if
202203
// setKeySequence()
203204
// is called while not recording then set oldKeySequence to the existing
@@ -212,7 +213,7 @@ void FcitxQtKeySequenceWidget::setKeySequence(
212213

213214
d->side = side;
214215
d->keySequence = seq;
215-
d->doneRecording(validate == Validate);
216+
d->doneRecording();
216217
}
217218

218219
// slot
@@ -240,7 +241,7 @@ void FcitxQtKeySequenceWidgetPrivate::startRecording() {
240241
updateShortcutDisplay();
241242
}
242243

243-
void FcitxQtKeySequenceWidgetPrivate::doneRecording(bool validate) {
244+
void FcitxQtKeySequenceWidgetPrivate::doneRecording() {
244245
modifierlessTimeout.stop();
245246
isRecording = false;
246247
keyButton->releaseKeyboard();

qt5/widgetsaddons/qtkeytrans.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <QTextCodec>
2424
#include <ctype.h>
2525
#include <fcitx-config/hotkey.h>
26+
#include <algorithm>
2627

2728
#define _ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
2829
#define _ARRAY_END(a) (a + _ARRAY_SIZE(a))
@@ -36,14 +37,14 @@ void qEventToSym(int key, const QString &text, Qt::KeyboardModifiers mod,
3637
break;
3738
int uni = text[0].unicode();
3839
int *result =
39-
qBinaryFind(unicodeHasKey, _ARRAY_END(unicodeHasKey), uni);
40+
std::lower_bound(unicodeHasKey, _ARRAY_END(unicodeHasKey), uni);
4041
if (result != _ARRAY_END(unicodeHasKey)) {
4142
sym = *result + 0x1000000;
4243
break;
4344
}
4445

4546
Unicode2Key *keyMap =
46-
qBinaryFind(unicodeKeyMap, _ARRAY_END(unicodeKeyMap), uni);
47+
std::lower_bound(unicodeKeyMap, _ARRAY_END(unicodeKeyMap), uni);
4748
if (keyMap != _ARRAY_END(unicodeKeyMap)) {
4849
sym = keyMap->key;
4950
break;
@@ -56,26 +57,26 @@ void qEventToSym(int key, const QString &text, Qt::KeyboardModifiers mod,
5657

5758
QtCode2Key *result = nullptr;
5859
if (mod & Qt::KeypadModifier) {
59-
result = qBinaryFind(keyPadQtCodeToKey,
60+
result = std::lower_bound(keyPadQtCodeToKey,
6061
_ARRAY_END(keyPadQtCodeToKey), key);
6162
if (result == _ARRAY_END(keyPadQtCodeToKey))
6263
result = nullptr;
6364
} else {
6465
if (text.isNull()) {
65-
result = qBinaryFind(qtCodeToKeyBackup,
66+
result = std::lower_bound(qtCodeToKeyBackup,
6667
_ARRAY_END(qtCodeToKeyBackup), key);
6768
if (result == _ARRAY_END(qtCodeToKeyBackup))
6869
result = nullptr;
6970
}
7071
if (!result) {
71-
result = qBinaryFind(qtCodeToKey, _ARRAY_END(qtCodeToKey), key);
72+
result = std::lower_bound(qtCodeToKey, _ARRAY_END(qtCodeToKey), key);
7273

7374
if (result == _ARRAY_END(qtCodeToKey))
7475
result = nullptr;
7576
}
7677

7778
if (!result) {
78-
result = qBinaryFind(keyPadQtCodeToKey,
79+
result = std::lower_bound(keyPadQtCodeToKey,
7980
_ARRAY_END(keyPadQtCodeToKey), key);
8081
if (result == _ARRAY_END(keyPadQtCodeToKey))
8182
result = nullptr;

0 commit comments

Comments
 (0)