Separate GUI sources from core sources.

This PR splits the GUI source files from the core
source files. The immediate goal is to allow the
CLI to require only a minimum number of dynamic
libraries. The long term goal is to create an
architectural boundary around the core module,
in preparation of libkdbx.
This commit is contained in:
louib 2022-09-17 21:45:43 -04:00
parent 3e3e87d3c5
commit a7ffd28e26
16 changed files with 75 additions and 64 deletions

View File

@ -89,6 +89,19 @@ set(keepassx_SOURCES
format/OpVaultReaderAttachments.cpp
format/OpVaultReaderBandEntry.cpp
format/OpVaultReaderSections.cpp
keys/CompositeKey.cpp
keys/FileKey.cpp
keys/PasswordKey.cpp
keys/ChallengeResponseKey.cpp
streams/HashedBlockStream.cpp
streams/HmacBlockStream.cpp
streams/LayeredStream.cpp
streams/qtiocompressor.cpp
streams/StoreDataStream.cpp
streams/SymmetricCipherStream.cpp
totp/totp.cpp)
set(gui_SOURCES
gui/styles/styles.qrc
gui/styles/StateColorPalette.cpp
gui/styles/base/phantomcolor.cpp
@ -182,52 +195,41 @@ set(keepassx_SOURCES
gui/wizard/NewDatabaseWizardPage.cpp
gui/wizard/NewDatabaseWizardPageMetaData.cpp
gui/wizard/NewDatabaseWizardPageEncryption.cpp
gui/wizard/NewDatabaseWizardPageDatabaseKey.cpp
keys/CompositeKey.cpp
keys/FileKey.cpp
keys/PasswordKey.cpp
keys/ChallengeResponseKey.cpp
streams/HashedBlockStream.cpp
streams/HmacBlockStream.cpp
streams/LayeredStream.cpp
streams/qtiocompressor.cpp
streams/StoreDataStream.cpp
streams/SymmetricCipherStream.cpp
totp/totp.cpp)
gui/wizard/NewDatabaseWizardPageDatabaseKey.cpp)
if(APPLE)
set(keepassx_SOURCES
${keepassx_SOURCES}
core/MacPasteboard.cpp
set(gui_SOURCES
${gui_SOURCES}
gui/osutils/macutils/MacUtils.cpp
gui/osutils/macutils/ScreenLockListenerMac.cpp
gui/osutils/macutils/AppKitImpl.mm
gui/osutils/macutils/AppKit.h)
endif()
if(UNIX AND NOT APPLE)
set(keepassx_SOURCES
${keepassx_SOURCES}
set(gui_SOURCES
${gui_SOURCES}
gui/osutils/nixutils/ScreenLockListenerDBus.cpp
gui/osutils/nixutils/NixUtils.cpp)
if(WITH_XC_X11)
list(APPEND keepassx_SOURCES
list(APPEND gui_SOURCES
gui/osutils/nixutils/X11Funcs.cpp)
endif()
qt5_add_dbus_adaptor(keepassx_SOURCES
qt5_add_dbus_adaptor(gui_SOURCES
gui/org.keepassxc.KeePassXC.MainWindow.xml
gui/MainWindow.h
MainWindow)
endif()
if(WIN32)
set(keepassx_SOURCES
${keepassx_SOURCES}
set(gui_SOURCES
${gui_SOURCES}
gui/osutils/winutils/ScreenLockListenerWin.cpp
gui/osutils/winutils/WinUtils.cpp)
if (MSVC)
list(APPEND keepassx_SOURCES winhello/WindowsHello.cpp)
list(APPEND gui_SOURCES winhello/WindowsHello.cpp)
endif()
endif()
set(keepassx_SOURCES ${keepassx_SOURCES}
set(gui_SOURCES ${gui_SOURCES}
../share/icons/icons.qrc
../share/wizard/wizard.qrc)
@ -248,10 +250,10 @@ add_subdirectory(browser)
add_subdirectory(proxy)
if(WITH_XC_BROWSER)
set(keepassxcbrowser_LIB keepassxcbrowser)
set(keepassx_SOURCES ${keepassx_SOURCES} gui/dbsettings/DatabaseSettingsWidgetBrowser.cpp)
set(keepassx_SOURCES ${keepassx_SOURCES} gui/entry/EntryURLModel.cpp)
set(keepassx_SOURCES ${keepassx_SOURCES} gui/reports/ReportsWidgetBrowserStatistics.cpp)
set(keepassx_SOURCES ${keepassx_SOURCES} gui/reports/ReportsPageBrowserStatistics.cpp)
set(gui_SOURCES ${gui_SOURCES} gui/dbsettings/DatabaseSettingsWidgetBrowser.cpp)
set(gui_SOURCES ${gui_SOURCES} gui/entry/EntryURLModel.cpp)
set(gui_SOURCES ${gui_SOURCES} gui/reports/ReportsWidgetBrowserStatistics.cpp)
set(gui_SOURCES ${gui_SOURCES} gui/reports/ReportsPageBrowserStatistics.cpp)
endif()
add_subdirectory(autotype)
@ -277,7 +279,6 @@ endif()
add_subdirectory(thirdparty)
set(autotype_SOURCES
core/Tools.cpp
autotype/AutoType.cpp
autotype/AutoTypeAction.cpp
autotype/AutoTypeMatchModel.cpp
@ -305,13 +306,13 @@ else()
endif()
if(WITH_XC_NETWORKING)
list(APPEND keepassx_SOURCES
core/HibpDownloader.cpp
core/NetworkManager.cpp
list(APPEND gui_SOURCES
networking/HibpDownloader.cpp
networking/NetworkManager.cpp
networking/UpdateChecker.cpp
gui/UpdateCheckDialog.cpp
gui/IconDownloader.cpp
gui/IconDownloaderDialog.cpp
updatecheck/UpdateChecker.cpp)
gui/IconDownloaderDialog.cpp)
endif()
if(APPLE)
@ -328,51 +329,61 @@ target_link_libraries(autotype Qt5::Core Qt5::Widgets)
add_library(keepassx_core STATIC ${keepassx_SOURCES})
set_target_properties(keepassx_core PROPERTIES COMPILE_DEFINITIONS KEEPASSX_BUILDING_CORE)
target_link_libraries(keepassx_core
autotype
${keepassxcbrowser_LIB}
set(gui_SOURCES
${gui_SOURCES}
${keepassx_SOURCES})
set(keepassx_core_LIBRARIES
${qrcode_LIB}
${fdosecrets_LIB}
Qt5::Core
Qt5::Concurrent
Qt5::Network
Qt5::Widgets
${BOTAN2_LIBRARIES}
${PCSC_LIBRARIES}
${ZXCVBN_LIBRARIES}
${ZLIB_LIBRARIES}
${ARGON2_LIBRARIES}
${thirdparty_LIBRARIES}
)
${thirdparty_LIBRARIES})
add_library(keepassx_gui STATIC ${gui_SOURCES})
target_link_libraries(keepassx_gui
${keepassx_core_LIBRARIES}
Qt5::Network
Qt5::Widgets
autotype
${keepassxcbrowser_LIB}
${fdosecrets_LIB}
)
set_target_properties(keepassx_core PROPERTIES COMPILE_DEFINITIONS KEEPASSX_BUILDING_CORE)
target_link_libraries(keepassx_core ${keepassx_core_LIBRARIES})
if(WITH_XC_SSHAGENT)
target_link_libraries(keepassx_core sshagent)
target_link_libraries(keepassx_gui sshagent)
endif()
if(WITH_XC_KEESHARE)
target_link_libraries(keepassx_core keeshare)
target_link_libraries(keepassx_gui keeshare)
endif()
if(APPLE)
target_link_libraries(keepassx_core "-framework Foundation -framework AppKit -framework Carbon -framework Security -framework LocalAuthentication")
target_link_libraries(keepassx_gui "-framework Foundation -framework AppKit -framework Carbon -framework Security -framework LocalAuthentication")
if(Qt5MacExtras_FOUND)
target_link_libraries(keepassx_core Qt5::MacExtras)
target_link_libraries(keepassx_gui Qt5::MacExtras)
endif()
endif()
if(HAIKU)
target_link_libraries(keepassx_core network)
target_link_libraries(keepassx_gui network)
endif()
if(UNIX AND NOT APPLE)
target_link_libraries(keepassx_core Qt5::DBus)
target_link_libraries(keepassx_gui Qt5::DBus)
if(WITH_XC_X11)
target_link_libraries(keepassx_core Qt5::X11Extras X11)
target_link_libraries(keepassx_gui Qt5::X11Extras X11)
endif()
include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS})
endif()
if(WIN32)
target_link_libraries(keepassx_core Wtsapi32.lib Ws2_32.lib)
target_link_libraries(keepassx_gui Wtsapi32.lib Ws2_32.lib)
if (MSVC)
target_link_libraries(keepassx_core WindowsApp.lib)
target_link_libraries(keepassx_gui WindowsApp.lib)
endif()
endif()
@ -389,7 +400,7 @@ if(WIN32)
endif()
add_executable(${PROGNAME} WIN32 ${keepassx_SOURCES_MAINEXE} ${WIN32_ProductVersionFiles})
target_link_libraries(${PROGNAME} keepassx_core)
target_link_libraries(${PROGNAME} keepassx_gui)
set_target_properties(${PROGNAME} PROPERTIES ENABLE_EXPORTS ON)
@ -532,5 +543,5 @@ if(WIN32)
endif()
# The install commands in this subdirectory will be executed after all the install commands in the
# current scope are ran. It is required for correct functtioning of macdeployqt.
# current scope are ran. It is required for correct functioning of macdeployqt.
add_subdirectory(post_install)

View File

@ -1,4 +1,4 @@
set(autotype_test_SOURCES AutoTypeTest.cpp)
add_library(keepassxc-autotype-test MODULE ${autotype_test_SOURCES})
target_link_libraries(keepassxc-autotype-test keepassx_core ${autotype_LIB} Qt5::Core Qt5::Widgets)
target_link_libraries(keepassxc-autotype-test keepassx_gui ${autotype_LIB} Qt5::Core Qt5::Widgets)

View File

@ -1,7 +1,7 @@
set(autotype_win_SOURCES AutoTypeWindows.cpp)
add_library(keepassxc-autotype-windows MODULE ${autotype_win_SOURCES})
target_link_libraries(keepassxc-autotype-windows keepassx_core ${autotype_LIB} Qt5::Core Qt5::Widgets)
target_link_libraries(keepassxc-autotype-windows keepassx_gui ${autotype_LIB} Qt5::Core Qt5::Widgets)
install(TARGETS keepassxc-autotype-windows
BUNDLE DESTINATION . COMPONENT Runtime
LIBRARY DESTINATION ${PLUGIN_INSTALL_DIR} COMPONENT Runtime)

View File

@ -3,7 +3,7 @@ include_directories(SYSTEM ${X11_X11_INCLUDE_PATH})
set(autotype_XCB_SOURCES AutoTypeXCB.cpp)
add_library(keepassxc-autotype-xcb MODULE ${autotype_XCB_SOURCES})
target_link_libraries(keepassxc-autotype-xcb keepassx_core Qt5::Core Qt5::Widgets Qt5::X11Extras ${X11_X11_LIB} ${X11_Xi_LIB} ${X11_XTest_LIB})
target_link_libraries(keepassxc-autotype-xcb keepassx_gui Qt5::Core Qt5::Widgets Qt5::X11Extras ${X11_X11_LIB} ${X11_Xi_LIB} ${X11_XTest_LIB})
install(TARGETS keepassxc-autotype-xcb
BUNDLE DESTINATION . COMPONENT Runtime
LIBRARY DESTINATION ${PLUGIN_INSTALL_DIR} COMPONENT Runtime)

View File

@ -17,7 +17,7 @@
#include "IconDownloader.h"
#include "core/Config.h"
#include "core/NetworkManager.h"
#include "networking/NetworkManager.h"
#include <QBuffer>
#include <QHostInfo>

View File

@ -48,7 +48,7 @@
#ifdef WITH_XC_UPDATECHECK
#include "gui/UpdateCheckDialog.h"
#include "updatecheck/UpdateChecker.h"
#include "networking/UpdateChecker.h"
#endif
#ifdef WITH_XC_SSHAGENT

View File

@ -22,7 +22,7 @@
#include "config-keepassx.h"
#include "gui/Icons.h"
#include "updatecheck/UpdateChecker.h"
#include "networking/UpdateChecker.h"
UpdateCheckDialog::UpdateCheckDialog(QWidget* parent)
: QDialog(parent)

View File

@ -24,7 +24,7 @@
#include <QWidget>
#ifdef WITH_XC_NETWORKING
#include "core/HibpDownloader.h"
#include "networking/HibpDownloader.h"
#endif
class Database;

View File

@ -16,7 +16,7 @@
*/
#include "HibpDownloader.h"
#include "core/NetworkManager.h"
#include "NetworkManager.h"
#include <QCryptographicHash>
#include <QNetworkReply>

View File

@ -17,10 +17,10 @@
#include "UpdateChecker.h"
#include "NetworkManager.h"
#include "config-keepassx.h"
#include "core/Clock.h"
#include "core/Config.h"
#include "core/NetworkManager.h"
#include <QJsonArray>
#include <QJsonDocument>

View File

@ -90,7 +90,7 @@ macro(add_unit_test)
endif()
endmacro(add_unit_test)
set(TEST_LIBRARIES keepassx_core Qt5::Test)
set(TEST_LIBRARIES keepassx_gui Qt5::Test)
set(testsupport_SOURCES
modeltest.cpp

View File

@ -17,7 +17,7 @@
#include "TestUpdateCheck.h"
#include "crypto/Crypto.h"
#include "updatecheck/UpdateChecker.h"
#include "networking/UpdateChecker.h"
#include <QTest>