mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Allow for building without QtKeychain (#3318)
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
parent
4b903d7fcf
commit
fc4387014e
|
@ -49,6 +49,7 @@
|
||||||
- Dev: Add GitHub action to test builds without precompiled headers enabled. (#3327)
|
- Dev: Add GitHub action to test builds without precompiled headers enabled. (#3327)
|
||||||
- Dev: Renamed CMake's build option `USE_SYSTEM_QT5KEYCHAIN` to `USE_SYSTEM_QTKEYCHAIN`. (#3103)
|
- Dev: Renamed CMake's build option `USE_SYSTEM_QT5KEYCHAIN` to `USE_SYSTEM_QTKEYCHAIN`. (#3103)
|
||||||
- Dev: Add benchmarks that can be compiled with the `BUILD_BENCHMARKS` CMake flag. Off by default. (#3038)
|
- Dev: Add benchmarks that can be compiled with the `BUILD_BENCHMARKS` CMake flag. Off by default. (#3038)
|
||||||
|
- Dev: Added CMake build option `BUILD_WITH_QTKEYCHAIN` to build with or without Qt5Keychain support (On by default). (#3318)
|
||||||
|
|
||||||
## 2.3.4
|
## 2.3.4
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ option(BUILD_BENCHMARKS "Build the benchmarks for Chatterino" OFF)
|
||||||
option(USE_SYSTEM_PAJLADA_SETTINGS "Use system pajlada settings library" OFF)
|
option(USE_SYSTEM_PAJLADA_SETTINGS "Use system pajlada settings library" OFF)
|
||||||
option(USE_SYSTEM_LIBCOMMUNI "Use system communi library" OFF)
|
option(USE_SYSTEM_LIBCOMMUNI "Use system communi library" OFF)
|
||||||
option(USE_SYSTEM_QTKEYCHAIN "Use system QtKeychain library" OFF)
|
option(USE_SYSTEM_QTKEYCHAIN "Use system QtKeychain library" OFF)
|
||||||
|
option(BUILD_WITH_QTKEYCHAIN "Build Chatterino with support for your system key chain" ON)
|
||||||
option(USE_PRECOMPILED_HEADERS "Use precompiled headers" ON)
|
option(USE_PRECOMPILED_HEADERS "Use precompiled headers" ON)
|
||||||
option(BUILD_WITH_QT6 "Use Qt6 instead of default Qt5" OFF)
|
option(BUILD_WITH_QT6 "Use Qt6 instead of default Qt5" OFF)
|
||||||
|
|
||||||
|
@ -77,20 +78,21 @@ else()
|
||||||
add_subdirectory("${LIBCOMMUNI_ROOT_LIB_FOLDER}" EXCLUDE_FROM_ALL)
|
add_subdirectory("${LIBCOMMUNI_ROOT_LIB_FOLDER}" EXCLUDE_FROM_ALL)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Link QtKeychain statically
|
if (BUILD_WITH_QTKEYCHAIN)
|
||||||
option(QTKEYCHAIN_STATIC "" ON)
|
# Link QtKeychain statically
|
||||||
|
option(QTKEYCHAIN_STATIC "" ON)
|
||||||
|
if (USE_SYSTEM_QTKEYCHAIN)
|
||||||
|
find_package(Qt${MAJOR_QT_VERSION}Keychain REQUIRED)
|
||||||
|
else()
|
||||||
|
set(QTKEYCHAIN_ROOT_LIB_FOLDER "${CMAKE_SOURCE_DIR}/lib/qtkeychain")
|
||||||
|
if (NOT EXISTS "${QTKEYCHAIN_ROOT_LIB_FOLDER}/CMakeLists.txt")
|
||||||
|
message(FATAL_ERROR "Submodules probably not loaded, unable to find lib/qtkeychain/CMakeLists.txt")
|
||||||
|
endif()
|
||||||
|
|
||||||
if (USE_SYSTEM_QTKEYCHAIN)
|
add_subdirectory("${QTKEYCHAIN_ROOT_LIB_FOLDER}" EXCLUDE_FROM_ALL)
|
||||||
find_package(Qt${MAJOR_QT_VERSION}Keychain REQUIRED)
|
if (NOT TARGET qt${MAJOR_QT_VERSION}keychain)
|
||||||
else()
|
message(FATAL_ERROR "qt${MAJOR_QT_VERSION}keychain target was not created :@")
|
||||||
set(QTKEYCHAIN_ROOT_LIB_FOLDER "${CMAKE_SOURCE_DIR}/lib/qtkeychain")
|
endif()
|
||||||
if (NOT EXISTS "${QTKEYCHAIN_ROOT_LIB_FOLDER}/CMakeLists.txt")
|
|
||||||
message(FATAL_ERROR "Submodules probably not loaded, unable to find lib/qtkeychain/CMakeLists.txt")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_subdirectory("${QTKEYCHAIN_ROOT_LIB_FOLDER}" EXCLUDE_FROM_ALL)
|
|
||||||
if (NOT TARGET qt${MAJOR_QT_VERSION}keychain)
|
|
||||||
message(FATAL_ERROR "qt${MAJOR_QT_VERSION}keychain target was not created :@")
|
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -492,7 +492,6 @@ target_link_libraries(${LIBRARY_PROJECT}
|
||||||
Qt${MAJOR_QT_VERSION}::Concurrent
|
Qt${MAJOR_QT_VERSION}::Concurrent
|
||||||
|
|
||||||
LibCommuni::LibCommuni
|
LibCommuni::LibCommuni
|
||||||
qt${MAJOR_QT_VERSION}keychain
|
|
||||||
Pajlada::Serialize
|
Pajlada::Serialize
|
||||||
Pajlada::Settings
|
Pajlada::Settings
|
||||||
Pajlada::Signals
|
Pajlada::Signals
|
||||||
|
@ -501,6 +500,17 @@ target_link_libraries(${LIBRARY_PROJECT}
|
||||||
RapidJSON::RapidJSON
|
RapidJSON::RapidJSON
|
||||||
LRUCache
|
LRUCache
|
||||||
)
|
)
|
||||||
|
if (BUILD_WITH_QTKEYCHAIN)
|
||||||
|
target_link_libraries(${LIBRARY_PROJECT}
|
||||||
|
PUBLIC
|
||||||
|
qt${MAJOR_QT_VERSION}keychain
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
target_compile_definitions(${LIBRARY_PROJECT}
|
||||||
|
PUBLIC
|
||||||
|
NO_QTKEYCHAIN
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (BUILD_APP)
|
if (BUILD_APP)
|
||||||
add_executable(${EXECUTABLE_PROJECT} main.cpp)
|
add_executable(${EXECUTABLE_PROJECT} main.cpp)
|
||||||
|
|
|
@ -9,10 +9,12 @@
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
|
||||||
#ifdef CMAKE_BUILD
|
#ifndef NO_QTKEYCHAIN
|
||||||
# include "qt5keychain/keychain.h"
|
# ifdef CMAKE_BUILD
|
||||||
#else
|
# include "qt5keychain/keychain.h"
|
||||||
# include "keychain.h"
|
# else
|
||||||
|
# include "keychain.h"
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#include <QSaveFile>
|
#include <QSaveFile>
|
||||||
#include <boost/variant.hpp>
|
#include <boost/variant.hpp>
|
||||||
|
@ -28,6 +30,9 @@ namespace chatterino {
|
||||||
namespace {
|
namespace {
|
||||||
bool useKeyring()
|
bool useKeyring()
|
||||||
{
|
{
|
||||||
|
#ifdef NO_QTKEYCHAIN
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
if (getPaths()->isPortable())
|
if (getPaths()->isPortable())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -104,6 +109,7 @@ namespace {
|
||||||
|
|
||||||
static void runNextJob()
|
static void runNextJob()
|
||||||
{
|
{
|
||||||
|
#ifndef NO_QTKEYCHAIN
|
||||||
auto &&queue = jobQueue();
|
auto &&queue = jobQueue();
|
||||||
|
|
||||||
if (!queue.empty())
|
if (!queue.empty())
|
||||||
|
@ -140,6 +146,7 @@ namespace {
|
||||||
|
|
||||||
queue.pop();
|
queue.pop();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void queueJob(Job &&job)
|
static void queueJob(Job &&job)
|
||||||
|
@ -174,6 +181,8 @@ void Credentials::get(const QString &provider, const QString &name_,
|
||||||
|
|
||||||
if (useKeyring())
|
if (useKeyring())
|
||||||
{
|
{
|
||||||
|
#ifndef NO_QTKEYCHAIN
|
||||||
|
// if NO_QTKEYCHAIN is set, then this code is never used either way
|
||||||
auto job = new QKeychain::ReadPasswordJob("chatterino");
|
auto job = new QKeychain::ReadPasswordJob("chatterino");
|
||||||
job->setAutoDelete(true);
|
job->setAutoDelete(true);
|
||||||
job->setKey(name);
|
job->setKey(name);
|
||||||
|
@ -184,6 +193,7 @@ void Credentials::get(const QString &provider, const QString &name_,
|
||||||
},
|
},
|
||||||
Qt::DirectConnection);
|
Qt::DirectConnection);
|
||||||
job->start();
|
job->start();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -140,9 +140,11 @@ AboutPage::AboutPage()
|
||||||
addLicense(form.getElement(), "Websocketpp",
|
addLicense(form.getElement(), "Websocketpp",
|
||||||
"https://www.zaphoyd.com/websocketpp/",
|
"https://www.zaphoyd.com/websocketpp/",
|
||||||
":/licenses/websocketpp.txt");
|
":/licenses/websocketpp.txt");
|
||||||
|
#ifndef NO_QTKEYCHAIN
|
||||||
addLicense(form.getElement(), "QtKeychain",
|
addLicense(form.getElement(), "QtKeychain",
|
||||||
"https://github.com/frankosterfeld/qtkeychain",
|
"https://github.com/frankosterfeld/qtkeychain",
|
||||||
":/licenses/qtkeychain.txt");
|
":/licenses/qtkeychain.txt");
|
||||||
|
#endif
|
||||||
addLicense(form.getElement(), "lrucache",
|
addLicense(form.getElement(), "lrucache",
|
||||||
"https://github.com/lamerman/cpp-lru-cache",
|
"https://github.com/lamerman/cpp-lru-cache",
|
||||||
":/licenses/lrucache.txt");
|
":/licenses/lrucache.txt");
|
||||||
|
|
|
@ -584,7 +584,7 @@ void GeneralPage::initLayout(GeneralPageView &layout)
|
||||||
|
|
||||||
layout.addCheckbox("Restart on crash", s.restartOnCrash);
|
layout.addCheckbox("Restart on crash", s.restartOnCrash);
|
||||||
|
|
||||||
#ifdef Q_OS_LINUX
|
#if defined(Q_OS_LINUX) && !defined(NO_QTKEYCHAIN)
|
||||||
if (!getPaths()->isPortable())
|
if (!getPaths()->isPortable())
|
||||||
{
|
{
|
||||||
layout.addCheckbox(
|
layout.addCheckbox(
|
||||||
|
|
Loading…
Reference in a new issue