CMake: add TOR_INSTALLED

This commit is contained in:
tobtoht 2023-04-21 18:59:41 +02:00
parent a89d20887f
commit be5fd97fe0
No known key found for this signature in database
GPG key ID: E45B10DD027D2472
5 changed files with 26 additions and 17 deletions

View file

@ -18,15 +18,24 @@ set(COPYRIGHT_HOLDERS "The Monero Project")
# Configurable options # Configurable options
option(STATIC "Link libraries statically, requires static Qt" OFF) option(STATIC "Link libraries statically, requires static Qt" OFF)
option(SELF_CONTAINED "Disable when building Feather for packages" OFF) option(SELF_CONTAINED "Disable when building Feather for packages" OFF)
option(LOCALMONERO "Include LocalMonero module" ON) option(STACK_TRACE "Dump stack trace on crash (Linux only)" OFF)
option(XMRIG "Include XMRig module" ON) option(DONATE_BEG "Prompt donation window every once in a while" OFF)
option(TOR_DIR "Directory containing Tor binaries to embed inside Feather" OFF)
# Updater
option(CHECK_UPDATES "Enable checking for application updates" OFF) option(CHECK_UPDATES "Enable checking for application updates" OFF)
option(PLATFORM_INSTALLER "Built-in updater fetches installer (windows-only)" OFF) option(PLATFORM_INSTALLER "Built-in updater fetches installer (windows-only)" OFF)
option(USE_DEVICE_TREZOR "Trezor support compilation" ON)
option(DONATE_BEG "Prompt donation window every once in a while" OFF) # Tor
option(TOR_DIR "Directory containing Tor binaries to embed inside Feather" OFF)
option(TOR_VERSION "Tor version for bundled Tor binary" OFF)
option(TOR_INSTALLED "Tor binary is available in the installation directory" OFF)
# Components
option(WITH_SCANNER "Enable webcam QR scanner" ON) option(WITH_SCANNER "Enable webcam QR scanner" ON)
option(STACK_TRACE "Dump stack trace on crash (Linux only)" OFF) option(USE_DEVICE_TREZOR "Trezor support compilation" ON)
option(LOCALMONERO "Include LocalMonero module" ON)
option(XMRIG "Include XMRig module" ON)
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_SOURCE_DIR}/cmake") list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_SOURCE_DIR}/cmake")
include(CheckCCompilerFlag) include(CheckCCompilerFlag)

View file

@ -279,7 +279,7 @@ mkdir -p "$DISTSRC"
*mingw32) *mingw32)
case "$OPTIONS" in case "$OPTIONS" in
installer) installer)
CMAKEVARS+=" -DPLATFORM_INSTALLER=On -DTOR_DIR=Off -DTOR_VERSION=Off" CMAKEVARS+=" -DPLATFORM_INSTALLER=On -DTOR_DIR=Off -DTOR_VERSION=Off -DTOR_INSTALLED=On"
;; ;;
esac esac
;; ;;

View file

@ -187,6 +187,10 @@ if(TOR_DIR)
target_compile_definitions(feather PRIVATE HAS_TOR_BIN=1) target_compile_definitions(feather PRIVATE HAS_TOR_BIN=1)
endif() endif()
if(TOR_INSTALLED)
target_compile_definitions(feather PRIVATE TOR_INSTALLED=1)
endif()
if(XMRIG) if(XMRIG)
target_compile_definitions(feather PRIVATE HAS_XMRIG=1) target_compile_definitions(feather PRIVATE HAS_XMRIG=1)
endif() endif()
@ -318,4 +322,4 @@ else()
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/assets/feather.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/assets/feather.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/assets/images/appicons/256x256.png DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/256x256/apps RENAME "feather.png") install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/assets/images/appicons/256x256.png DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/256x256/apps RENAME "feather.png")
endif() endif()
endif() endif()

View file

@ -21,7 +21,7 @@ TorManager::TorManager(QObject *parent)
connect(m_checkConnectionTimer, &QTimer::timeout, this, &TorManager::checkConnection); connect(m_checkConnectionTimer, &QTimer::timeout, this, &TorManager::checkConnection);
this->torDir = Config::defaultConfigDir().filePath("tor"); this->torDir = Config::defaultConfigDir().filePath("tor");
#if defined(PLATFORM_INSTALLER) #if defined(TOR_INSTALLED)
// When installed, use directory relative to application path. // When installed, use directory relative to application path.
this->torDir = QDir(Utils::applicationPath()).filePath("tor"); this->torDir = QDir(Utils::applicationPath()).filePath("tor");
#endif #endif
@ -73,10 +73,6 @@ void TorManager::start() {
} }
QFile torFile{this->torPath}; QFile torFile{this->torPath};
QString alternativeTorFile = QCoreApplication::applicationDirPath() + "/tor";
if (!torFile.exists() && QFileInfo(alternativeTorFile).isFile()) {
this->torPath = alternativeTorFile;
}
qDebug() << QString("Start process: %1").arg(this->torPath); qDebug() << QString("Start process: %1").arg(this->torPath);
@ -190,7 +186,7 @@ bool TorManager::unpackBins() {
this->torPath = QDir(this->torDir).filePath(torBin); this->torPath = QDir(this->torDir).filePath(torBin);
#if defined(PLATFORM_INSTALLER) #if defined(TOR_INSTALLED)
// We don't need to unpack if Tor was installed using the installer // We don't need to unpack if Tor was installed using the installer
return true; return true;
#endif #endif
@ -254,7 +250,7 @@ bool TorManager::shouldStartTorDaemon() {
} }
// Don't start a Tor daemon if we don't have one // Don't start a Tor daemon if we don't have one
#if !defined(HAS_TOR_BIN) && !defined(PLATFORM_INSTALLER) #if !defined(HAS_TOR_BIN) && !defined(TOR_INSTALLED)
qWarning() << "Feather built without embedded Tor. Assuming --use-local-tor"; qWarning() << "Feather built without embedded Tor. Assuming --use-local-tor";
return false; return false;
#endif #endif

View file

@ -44,7 +44,7 @@ NetworkProxyWidget::NetworkProxyWidget(QWidget *parent)
// [Tor settings] // [Tor settings]
// [Let Feather start and manage a Tor daemon] // [Let Feather start and manage a Tor daemon]
#if !defined(HAS_TOR_BIN) && !defined(PLATFORM_INSTALLER) #if !defined(HAS_TOR_BIN) && !defined(TOR_INSTALLED)
ui->checkBox_torManaged->setChecked(false); ui->checkBox_torManaged->setChecked(false);
ui->checkBox_torManaged->setEnabled(false); ui->checkBox_torManaged->setEnabled(false);
ui->checkBox_torManaged->setToolTip("Feather was bundled without Tor"); ui->checkBox_torManaged->setToolTip("Feather was bundled without Tor");
@ -69,7 +69,7 @@ NetworkProxyWidget::NetworkProxyWidget(QWidget *parent)
// [Show Tor logs] // [Show Tor logs]
ui->frame_torShowLogs->setVisible(!config()->get(Config::useLocalTor).toBool()); ui->frame_torShowLogs->setVisible(!config()->get(Config::useLocalTor).toBool());
#if !defined(HAS_TOR_BIN) && !defined(PLATFORM_INSTALLER) #if !defined(HAS_TOR_BIN) && !defined(TOR_INSTALLED)
ui->frame_torShowLogs->setVisible(false); ui->frame_torShowLogs->setVisible(false);
#endif #endif
connect(ui->btn_torShowLogs, &QPushButton::clicked, [this]{ connect(ui->btn_torShowLogs, &QPushButton::clicked, [this]{