CMake: minimize dependencies for CHECK_UPDATES=Off, WITH_SCANNER=Off

This commit is contained in:
tobtoht 2023-04-19 17:41:46 +02:00
parent fde1b7b7c7
commit 2fe4e9e4b4
12 changed files with 68 additions and 25 deletions

View file

@ -64,6 +64,9 @@ get_directory_property(UNBOUND_LIBRARY DIRECTORY "monero" DEFINITION UNBOUND_LIB
get_directory_property(DEVICE_TREZOR_READY DIRECTORY "monero" DEFINITION DEVICE_TREZOR_READY) get_directory_property(DEVICE_TREZOR_READY DIRECTORY "monero" DEFINITION DEVICE_TREZOR_READY)
get_directory_property(TREZOR_DEP_LIBS DIRECTORY "monero" DEFINITION TREZOR_DEP_LIBS) get_directory_property(TREZOR_DEP_LIBS DIRECTORY "monero" DEFINITION TREZOR_DEP_LIBS)
# pthread
find_package(Threads REQUIRED)
# Easylogging # Easylogging
include_directories(${EASYLOGGING_INCLUDE}) include_directories(${EASYLOGGING_INCLUDE})
link_directories(${EASYLOGGING_LIBRARY_DIRS}) link_directories(${EASYLOGGING_LIBRARY_DIRS})
@ -75,22 +78,26 @@ message(STATUS "libsodium: libraries at ${SODIUM_LIBRARY}")
# QrEncode # QrEncode
find_package(QREncode REQUIRED) find_package(QREncode REQUIRED)
# ZBAR
find_package(ZBAR REQUIRED)
message(STATUS "libzbar: include dir at ${ZBAR_INCLUDE_DIR}")
message(STATUS "libzbar: libraries at ${ZBAR_LIBRARIES}")
# Polyseed # Polyseed
find_package(Polyseed REQUIRED) find_package(Polyseed REQUIRED)
if(Polyseed_SUBMODULE) if(Polyseed_SUBMODULE)
add_subdirectory(src/third-party/polyseed EXCLUDE_FROM_ALL) add_subdirectory(src/third-party/polyseed EXCLUDE_FROM_ALL)
endif() endif()
# ZBAR
if(WITH_SCANNER)
find_package(ZBAR REQUIRED)
message(STATUS "libzbar: include dir at ${ZBAR_INCLUDE_DIR}")
message(STATUS "libzbar: libraries at ${ZBAR_LIBRARIES}")
endif()
# libzip # libzip
set(ZLIB_USE_STATIC_LIBS "ON") if(CHECK_UPDATES)
find_package(ZLIB REQUIRED) set(ZLIB_USE_STATIC_LIBS "ON")
find_path(LIBZIP_INCLUDE_DIRS zip.h) find_package(ZLIB REQUIRED)
find_library(LIBZIP_LIBRARIES zip) find_path(LIBZIP_INCLUDE_DIRS zip.h)
find_library(LIBZIP_LIBRARIES zip)
endif()
# Boost # Boost
if(DEBUG) if(DEBUG)
@ -182,8 +189,6 @@ elseif(NOT MSVC AND NOT DEPENDS)
set(EXTRA_LIBRARIES ${RT}) set(EXTRA_LIBRARIES ${RT})
endif() endif()
list(APPEND EXTRA_LIBRARIES ${CMAKE_DL_LIBS})
if(APPLE) if(APPLE)
cmake_policy(SET CMP0042 NEW) cmake_policy(SET CMP0042 NEW)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=default -std=c++11") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=default -std=c++11")

View file

@ -2,9 +2,6 @@ set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON) set(CMAKE_AUTORCC ON)
# pthread
find_package(Threads REQUIRED)
set(QT_COMPONENTS set(QT_COMPONENTS
Core Core
Widgets Widgets
@ -28,7 +25,9 @@ endif()
set(QAPPLICATION_CLASS QApplication CACHE STRING "Inheritance class for SingleApplication") set(QAPPLICATION_CLASS QApplication CACHE STRING "Inheritance class for SingleApplication")
add_subdirectory(third-party/singleapplication) add_subdirectory(third-party/singleapplication)
add_subdirectory(openpgp) if (CHECK_UPDATES)
add_subdirectory(openpgp)
endif()
qt_add_resources(RESOURCES assets.qrc assets_tor.qrc) qt_add_resources(RESOURCES assets.qrc assets_tor.qrc)
@ -74,6 +73,18 @@ file(GLOB SOURCE_FILES
"plugins/*/*.h" "plugins/*/*.h"
) )
if (CHECK_UPDATES)
file(GLOB UPDATER_FILES
"utils/updater/*.h"
"utils/updater/*.cpp")
endif()
if (WITH_SCANNER)
file(GLOB QRCODE_UTILS_FILES
"qrcode/utils/*.h"
"qrcode/utils/*.cpp")
endif()
if (WITH_SCANNER AND NOT Qt6_FOUND) if (WITH_SCANNER AND NOT Qt6_FOUND)
file(GLOB SCANNER_FILES file(GLOB SCANNER_FILES
"qrcode/scanner/*.h" "qrcode/scanner/*.h"
@ -87,6 +98,8 @@ if (WITH_SCANNER AND Qt6_FOUND)
endif() endif()
list(APPEND SOURCE_FILES list(APPEND SOURCE_FILES
${UPDATER_FILES}
${QRCODE_UTILS_FILES}
${SCANNER_FILES}) ${SCANNER_FILES})
set(EXECUTABLE_FLAG) set(EXECUTABLE_FLAG)
@ -143,12 +156,12 @@ target_include_directories(feather PUBLIC
${QtWebSockets_INCLUDE_DIRS} ${QtWebSockets_INCLUDE_DIRS}
${LIBZIP_INCLUDE_DIRS} ${LIBZIP_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS}
${ZBAR_INCLUDE_DIR}
${POLYSEED_INCLUDE_DIR} ${POLYSEED_INCLUDE_DIR}
) )
if(WITH_SCANNER) if(WITH_SCANNER)
target_include_directories(feather PUBLIC target_include_directories(feather PUBLIC
${ZBAR_INCLUDE_DIR}
${QtMultimedia_INCLUDE_DIRS} ${QtMultimedia_INCLUDE_DIRS}
${QtMultimediaWidgets_INCLUDE_DIRS} ${QtMultimediaWidgets_INCLUDE_DIRS}
) )
@ -230,7 +243,6 @@ target_link_libraries(feather
ringct ringct
${Boost_LIBRARIES} ${Boost_LIBRARIES}
${OPENSSL_LIBRARIES} ${OPENSSL_LIBRARIES}
${CMAKE_DL_LIBS}
${EXTRA_LIBRARIES} ${EXTRA_LIBRARIES}
Qt::Core Qt::Core
Qt::Widgets Qt::Widgets
@ -238,10 +250,8 @@ target_link_libraries(feather
Qt::Network Qt::Network
Qt::Svg Qt::Svg
Qt::WebSockets Qt::WebSockets
openpgp
Threads::Threads Threads::Threads
${QRENCODE_LIBRARY} ${QRENCODE_LIBRARY}
${ZBAR_LIBRARIES}
${POLYSEED_LIBRARY} ${POLYSEED_LIBRARY}
SingleApplication::SingleApplication SingleApplication::SingleApplication
${ICU_LIBRARIES} ${ICU_LIBRARIES}
@ -249,6 +259,10 @@ target_link_libraries(feather
${ZLIB_LIBRARIES} ${ZLIB_LIBRARIES}
) )
if(CHECK_UPDATES)
target_link_libraries(feather openpgp)
endif()
if(DEPENDS) if(DEPENDS)
target_link_libraries(feather ${ICONV_LIBRARIES}) target_link_libraries(feather ${ICONV_LIBRARIES})
endif() endif()
@ -263,6 +277,7 @@ endif()
if (WITH_SCANNER) if (WITH_SCANNER)
target_link_libraries(feather target_link_libraries(feather
${ZBAR_LIBRARIES}
Qt::Multimedia Qt::Multimedia
Qt::MultimediaWidgets Qt::MultimediaWidgets
) )

View file

@ -21,7 +21,6 @@
#include "dialog/ViewOnlyDialog.h" #include "dialog/ViewOnlyDialog.h"
#include "dialog/WalletInfoDialog.h" #include "dialog/WalletInfoDialog.h"
#include "dialog/WalletCacheDebugDialog.h" #include "dialog/WalletCacheDebugDialog.h"
#include "dialog/UpdateDialog.h"
#include "libwalletqt/AddressBook.h" #include "libwalletqt/AddressBook.h"
#include "libwalletqt/CoinsInfo.h" #include "libwalletqt/CoinsInfo.h"
#include "libwalletqt/Transfer.h" #include "libwalletqt/Transfer.h"
@ -31,9 +30,11 @@
#include "utils/Icons.h" #include "utils/Icons.h"
#include "utils/SemanticVersion.h" #include "utils/SemanticVersion.h"
#include "utils/TorManager.h" #include "utils/TorManager.h"
#include "utils/Updater.h"
#include "utils/WebsocketNotifier.h" #include "utils/WebsocketNotifier.h"
#ifdef CHECK_UPDATES
#include "utils/updater/UpdateDialog.h"
#endif
//#include "misc_log_ex.h" //#include "misc_log_ex.h"
MainWindow::MainWindow(WindowManager *windowManager, Wallet *wallet, QWidget *parent) MainWindow::MainWindow(WindowManager *windowManager, Wallet *wallet, QWidget *parent)
@ -55,7 +56,9 @@ MainWindow::MainWindow(WindowManager *windowManager, Wallet *wallet, QWidget *pa
m_splashDialog = new SplashDialog(this); m_splashDialog = new SplashDialog(this);
m_accountSwitcherDialog = new AccountSwitcherDialog(m_wallet, this); m_accountSwitcherDialog = new AccountSwitcherDialog(m_wallet, this);
#ifdef CHECK_UPDATES
m_updater = QSharedPointer<Updater>(new Updater(this)); m_updater = QSharedPointer<Updater>(new Updater(this));
#endif
this->restoreGeo(); this->restoreGeo();
@ -70,7 +73,9 @@ MainWindow::MainWindow(WindowManager *windowManager, Wallet *wallet, QWidget *pa
connect(websocketNotifier(), &WebsocketNotifier::BountyReceived, ui->bountiesWidget->model(), &BountiesModel::updateBounties); connect(websocketNotifier(), &WebsocketNotifier::BountyReceived, ui->bountiesWidget->model(), &BountiesModel::updateBounties);
connect(websocketNotifier(), &WebsocketNotifier::RedditReceived, ui->redditWidget->model(), &RedditModel::updatePosts); connect(websocketNotifier(), &WebsocketNotifier::RedditReceived, ui->redditWidget->model(), &RedditModel::updatePosts);
connect(websocketNotifier(), &WebsocketNotifier::RevuoReceived, ui->revuoWidget, &RevuoWidget::updateItems); connect(websocketNotifier(), &WebsocketNotifier::RevuoReceived, ui->revuoWidget, &RevuoWidget::updateItems);
#ifdef CHECK_UPDATES
connect(websocketNotifier(), &WebsocketNotifier::UpdatesReceived, m_updater.data(), &Updater::wsUpdatesReceived); connect(websocketNotifier(), &WebsocketNotifier::UpdatesReceived, m_updater.data(), &Updater::wsUpdatesReceived);
#endif
#ifdef HAS_XMRIG #ifdef HAS_XMRIG
connect(websocketNotifier(), &WebsocketNotifier::XMRigDownloadsReceived, m_xmrig, &XMRigWidget::onDownloads); connect(websocketNotifier(), &WebsocketNotifier::XMRigDownloadsReceived, m_xmrig, &XMRigWidget::onDownloads);
#endif #endif
@ -86,7 +91,9 @@ MainWindow::MainWindow(WindowManager *windowManager, Wallet *wallet, QWidget *pa
connect(torManager(), &TorManager::connectionStateChanged, this, &MainWindow::onTorConnectionStateChanged); connect(torManager(), &TorManager::connectionStateChanged, this, &MainWindow::onTorConnectionStateChanged);
this->onTorConnectionStateChanged(torManager()->torConnected); this->onTorConnectionStateChanged(torManager()->torConnected);
#ifdef CHECK_UPDATES
connect(m_updater.data(), &Updater::updateAvailable, this, &MainWindow::showUpdateNotification); connect(m_updater.data(), &Updater::updateAvailable, this, &MainWindow::showUpdateNotification);
#endif
ColorScheme::updateFromWidget(this); ColorScheme::updateFromWidget(this);
QTimer::singleShot(1, [this]{this->updateWidgetIcons();}); QTimer::singleShot(1, [this]{this->updateWidgetIcons();});
@ -1402,9 +1409,11 @@ void MainWindow::onHideUpdateNotifications(bool hidden) {
if (hidden) { if (hidden) {
m_statusUpdateAvailable->hide(); m_statusUpdateAvailable->hide();
} }
#ifdef CHECK_UPDATES
else if (m_updater->state == Updater::State::UPDATE_AVAILABLE) { else if (m_updater->state == Updater::State::UPDATE_AVAILABLE) {
m_statusUpdateAvailable->show(); m_statusUpdateAvailable->show();
} }
#endif
} }
void MainWindow::onTorConnectionStateChanged(bool connected) { void MainWindow::onTorConnectionStateChanged(bool connected) {
@ -1419,6 +1428,7 @@ void MainWindow::onTorConnectionStateChanged(bool connected) {
} }
void MainWindow::showUpdateNotification() { void MainWindow::showUpdateNotification() {
#ifdef CHECK_UPDATES
if (config()->get(Config::hideUpdateNotifications).toBool()) { if (config()->get(Config::hideUpdateNotifications).toBool()) {
return; return;
} }
@ -1432,12 +1442,15 @@ void MainWindow::showUpdateNotification() {
m_statusUpdateAvailable->disconnect(); m_statusUpdateAvailable->disconnect();
connect(m_statusUpdateAvailable, &StatusBarButton::clicked, this, &MainWindow::showUpdateDialog); connect(m_statusUpdateAvailable, &StatusBarButton::clicked, this, &MainWindow::showUpdateDialog);
#endif
} }
void MainWindow::showUpdateDialog() { void MainWindow::showUpdateDialog() {
#ifdef CHECK_UPDATES
UpdateDialog updateDialog{this, m_updater}; UpdateDialog updateDialog{this, m_updater};
connect(&updateDialog, &UpdateDialog::restartWallet, m_windowManager, &WindowManager::restartApplication); connect(&updateDialog, &UpdateDialog::restartWallet, m_windowManager, &WindowManager::restartApplication);
updateDialog.exec(); updateDialog.exec();
#endif
} }
void MainWindow::onInitiateTransaction() { void MainWindow::onInitiateTransaction() {

View file

@ -31,7 +31,6 @@
#include "utils/config.h" #include "utils/config.h"
#include "utils/daemonrpc.h" #include "utils/daemonrpc.h"
#include "utils/EventFilter.h" #include "utils/EventFilter.h"
#include "utils/Updater.h"
#include "plugins/ccs/CCSWidget.h" #include "plugins/ccs/CCSWidget.h"
#include "plugins/reddit/RedditWidget.h" #include "plugins/reddit/RedditWidget.h"
#include "widgets/TickerWidget.h" #include "widgets/TickerWidget.h"
@ -46,6 +45,10 @@
#include "WindowManager.h" #include "WindowManager.h"
#ifdef CHECK_UPDATES
#include "utils/updater/Updater.h"
#endif
#ifdef HAS_LOCALMONERO #ifdef HAS_LOCALMONERO
#include "plugins/localmonero/LocalMoneroWidget.h" #include "plugins/localmonero/LocalMoneroWidget.h"
#endif #endif
@ -294,7 +297,9 @@ private:
EventFilter *m_eventFilter = nullptr; EventFilter *m_eventFilter = nullptr;
qint64 m_userLastActive = QDateTime::currentSecsSinceEpoch(); qint64 m_userLastActive = QDateTime::currentSecsSinceEpoch();
#ifdef CHECK_UPDATES
QSharedPointer<Updater> m_updater = nullptr; QSharedPointer<Updater> m_updater = nullptr;
#endif
}; };
#endif // FEATHER_MAINWINDOW_H #endif // FEATHER_MAINWINDOW_H

View file

@ -10,7 +10,7 @@
#include "utils/AsyncTask.h" #include "utils/AsyncTask.h"
#include "utils/Networking.h" #include "utils/Networking.h"
#include "utils/NetworkManager.h" #include "utils/NetworkManager.h"
#include "utils/Updater.h" #include "utils/updater/Updater.h"
#include "utils/Utils.h" #include "utils/Utils.h"
#include "utils/SemanticVersion.h" #include "utils/SemanticVersion.h"

View file

@ -8,7 +8,7 @@
#include <QNetworkReply> #include <QNetworkReply>
#include <QTimer> #include <QTimer>
#include "utils/Updater.h" #include "utils/updater/Updater.h"
namespace Ui { namespace Ui {
class UpdateDialog; class UpdateDialog;

View file

@ -10,9 +10,12 @@
#include <QScrollBar> #include <QScrollBar>
#include "libwalletqt/WalletManager.h" #include "libwalletqt/WalletManager.h"
#include "qrcode/QrCodeUtils.h"
#include "utils/Utils.h" #include "utils/Utils.h"
#if defined(WITH_SCANNER)
#include "qrcode/utils/QrCodeUtils.h"
#endif
PayToEdit::PayToEdit(QWidget *parent) : QPlainTextEdit(parent) PayToEdit::PayToEdit(QWidget *parent) : QPlainTextEdit(parent)
{ {
this->setFont(Utils::getMonospaceFont()); this->setFont(Utils::getMonospaceFont());
@ -108,10 +111,12 @@ void PayToEdit::pasteEvent(const QMimeData *mimeData) {
return; return;
} }
#if defined(WITH_SCANNER)
image.convertTo(QImage::Format_RGB32); image.convertTo(QImage::Format_RGB32);
QString result = QrCodeUtils::scanImage(image); QString result = QrCodeUtils::scanImage(image);
dataPasted(result); dataPasted(result);
#endif
} }
void PayToEdit::checkText() { void PayToEdit::checkText() {