Skip to content

Commit

Permalink
Refactor: move to simple default builds
Browse files Browse the repository at this point in the history
* Remove individual feature flags in favor of a single `KPXC_MINIMAL` flag that removes advanced features from the build. Basic features are no longer guarded by feature flags.
* Basic features: Auto-Type, Yubikey, KeeShare
* Advanced features include: Browser (and passkeys), SSH Agent, and Secret Service
* Networking, Documentation, and Update Checking remain as feature flags to accommodate various distro requirements.
  • Loading branch information
droidmonkey committed Jun 29, 2024
1 parent 166a371 commit 30d2a5d
Show file tree
Hide file tree
Showing 72 changed files with 601 additions and 973 deletions.
475 changes: 186 additions & 289 deletions CMakeLists.txt

Large diffs are not rendered by default.

65 changes: 65 additions & 0 deletions cmake/CompilerFlags.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Copyright (C) 2024 KeePassXC Team <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 or (at your option)
# version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

macro(add_gcc_compiler_cxxflags FLAGS)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS}")
endif()
endmacro()

macro(add_gcc_compiler_cflags FLAGS)
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAGS}")
endif()
endmacro()

macro(add_gcc_compiler_flags FLAGS)
add_gcc_compiler_cxxflags("${FLAGS}")
add_gcc_compiler_cflags("${FLAGS}")
endmacro()

# Copies of above macros that first ensure the compiler understands a given flag
# Because check_*_compiler_flag() sets -D with name, need to provide "safe" FLAGNAME
macro(check_add_gcc_compiler_cxxflag FLAG FLAGNAME)
check_cxx_compiler_flag("${FLAG}" CXX_HAS${FLAGNAME})
if(CXX_HAS${FLAGNAME})
add_gcc_compiler_cxxflags("${FLAG}")
endif()
endmacro()

macro(check_add_gcc_compiler_cflag FLAG FLAGNAME)
check_c_compiler_flag("${FLAG}" CC_HAS${FLAGNAME})
if(CC_HAS${FLAGNAME})
add_gcc_compiler_cflags("${FLAG}")
endif()
endmacro()

# This is the "front-end" for the above macros
# Optionally takes additional parameter(s) with language to check (currently "C" or "CXX")
macro(check_add_gcc_compiler_flag FLAG)
string(REGEX REPLACE "[-=]" "_" FLAGNAME "${FLAG}")
set(check_lang_spec ${ARGN})
list(LENGTH check_lang_spec num_extra_args)
set(langs C CXX)
if(num_extra_args GREATER 0)
set(langs "${check_lang_spec}")
endif()
if("C" IN_LIST langs)
check_add_gcc_compiler_cflag("${FLAG}" "${FLAGNAME}")
endif()
if("CXX" IN_LIST langs)
check_add_gcc_compiler_cxxflag("${FLAG}" "${FLAGNAME}")
endif()
endmacro()
8 changes: 8 additions & 0 deletions cmake/compiler-checks/ptrace_deny_attach.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <sys/ptrace.h>
#include <sys/types.h>

int main()
{
ptrace(PT_DENY_ATTACH, 0, 0, 0);
return 0;
}
29 changes: 10 additions & 19 deletions share/translations/keepassxc_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5698,17 +5698,6 @@ Are you sure you want to continue with this file?</source>
<source>Don&apos;t show again for this version</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>WARNING: You are using an unstable build of KeePassXC.
There is a high risk of corruption, maintain a backup of your databases.
This version is not meant for production use.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NOTE: You are using a pre-release version of KeePassXC.
Expect some bugs and minor issues, this version is meant for testing purposes.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No Tags</source>
<translation type="unfinished"></translation>
Expand Down Expand Up @@ -6047,6 +6036,12 @@ Expect some bugs and minor issues, this version is meant for testing purposes.</
<source>Setup Remote Sync…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>WARNING: You are using a development snapshot build of KeePassXC.
Maintain a backup of your databases in the event of unknown bugs.
This version is not meant for production use.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ManageDatabase</name>
Expand Down Expand Up @@ -8289,10 +8284,6 @@ Kernel: %3 %4</source>
<source>KeeShare</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>YubiKey</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Quick Unlock</source>
<translation type="unfinished"></translation>
Expand All @@ -8301,10 +8292,6 @@ Kernel: %3 %4</source>
<source>Secret Service Integration</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>None</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enabled extensions:</source>
<translation type="unfinished"></translation>
Expand Down Expand Up @@ -8898,6 +8885,10 @@ This option is deprecated, use --set-key-file instead.</source>
<source>Only PBKDF and Argon2 are supported, cannot decrypt json file</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hardware Keys</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QtIOCompressor</name>
Expand Down
127 changes: 41 additions & 86 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2023 KeePassXC Team <[email protected]>
# Copyright (C) 2024 KeePassXC Team <[email protected]>
# Copyright (C) 2010 Felix Geyer <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
Expand All @@ -16,18 +16,6 @@

include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})

add_feature_info(Auto-Type WITH_XC_AUTOTYPE "Automatic password typing")
add_feature_info(Networking WITH_XC_NETWORKING "Compile KeePassXC with network access code (e.g. for downloading website icons)")
add_feature_info(KeePassXC-Browser WITH_XC_BROWSER "Browser integration with KeePassXC-Browser")
add_feature_info(Passkeys WITH_XC_BROWSER_PASSKEYS "Passkeys support for browser integration")
add_feature_info(SSHAgent WITH_XC_SSHAGENT "SSH agent integration compatible with KeeAgent")
add_feature_info(KeeShare WITH_XC_KEESHARE "Sharing integration with KeeShare")
add_feature_info(YubiKey WITH_XC_YUBIKEY "YubiKey HMAC-SHA1 challenge-response")
add_feature_info(UpdateCheck WITH_XC_UPDATECHECK "Automatic update checking")
if(UNIX AND NOT APPLE)
add_feature_info(FdoSecrets WITH_XC_FDOSECRETS "Implement freedesktop.org Secret Storage Spec server side API.")
endif()

set(core_SOURCES
core/Alloc.cpp
core/AutoTypeAssociations.cpp
Expand Down Expand Up @@ -94,6 +82,11 @@ set(core_SOURCES
keys/FileKey.cpp
keys/PasswordKey.cpp
keys/ChallengeResponseKey.cpp
keys/drivers/YubiKey.h
keys/drivers/YubiKey.cpp
keys/drivers/YubiKeyInterface.cpp
keys/drivers/YubiKeyInterfaceUSB.cpp
keys/drivers/YubiKeyInterfacePCSC.cpp
streams/HashedBlockStream.cpp
streams/HmacBlockStream.cpp
streams/LayeredStream.cpp
Expand Down Expand Up @@ -189,6 +182,7 @@ set(gui_SOURCES
gui/reports/ReportsPageHibp.cpp
gui/reports/ReportsWidgetStatistics.cpp
gui/reports/ReportsPageStatistics.cpp
gui/osutils/DeviceListener.cpp
gui/osutils/OSUtilsBase.cpp
gui/osutils/ScreenLockListener.cpp
gui/osutils/ScreenLockListenerPrivate.cpp
Expand All @@ -210,6 +204,7 @@ set(gui_SOURCES

if(APPLE)
list(APPEND gui_SOURCES
gui/osutils/macutils/DeviceListenerMac.cpp
gui/osutils/macutils/MacPasteboard.cpp
gui/osutils/macutils/MacUtils.cpp
gui/osutils/macutils/ScreenLockListenerMac.cpp
Expand All @@ -223,14 +218,16 @@ endif()

if(UNIX AND NOT APPLE)
list(APPEND gui_SOURCES
gui/osutils/nixutils/DeviceListenerLibUsb.cpp
gui/osutils/nixutils/NixUtils.cpp
gui/osutils/nixutils/ScreenLockListenerDBus.cpp
gui/osutils/nixutils/NixUtils.cpp)
)
if("${CMAKE_SYSTEM}" MATCHES "Linux")
list(APPEND core_SOURCES
quickunlock/Polkit.cpp
quickunlock/PolkitDbusTypes.cpp)
endif()
if(WITH_XC_X11)
if(WITH_X11)
list(APPEND gui_SOURCES
gui/osutils/nixutils/X11Funcs.cpp)
endif()
Expand All @@ -248,15 +245,11 @@ if(UNIX AND NOT APPLE)
quickunlock/dbus/org.freedesktop.PolicyKit1.Authority.xml
polkit_dbus
)

find_library(KEYUTILS_LIBRARIES NAMES keyutils)
if(NOT KEYUTILS_LIBRARIES)
message(FATAL_ERROR "Could not find libkeyutils")
endif()
endif()

if(WIN32)
list(APPEND gui_SOURCES
gui/osutils/winutils/DeviceListenerWin.cpp
gui/osutils/winutils/ScreenLockListenerWin.cpp
gui/osutils/winutils/WinUtils.cpp
../share/windows/icon.rc)
Expand All @@ -265,101 +258,63 @@ if(WIN32)
endif()
endif()

if(WITH_XC_YUBIKEY)
list(APPEND gui_SOURCES gui/osutils/DeviceListener.cpp)
if(APPLE)
list(APPEND gui_SOURCES gui/osutils/macutils/DeviceListenerMac.cpp)
elseif(UNIX)
list(APPEND gui_SOURCES gui/osutils/nixutils/DeviceListenerLibUsb.cpp)
elseif(WIN32)
list(APPEND gui_SOURCES gui/osutils/winutils/DeviceListenerWin.cpp)
endif()
endif()

add_subdirectory(browser)
add_subdirectory(proxy)
if(WITH_XC_BROWSER)
if(KPXC_FEATURE_BROWSER)
set(browser_LIB browser)
list(APPEND gui_SOURCES
gui/dbsettings/DatabaseSettingsWidgetBrowser.cpp
gui/entry/EntryURLModel.cpp
gui/reports/ReportsPageBrowserStatistics.cpp
gui/reports/ReportsPagePasskeys.cpp
gui/reports/ReportsWidgetBrowserStatistics.cpp
gui/reports/ReportsPageBrowserStatistics.cpp)
endif()

if(WITH_XC_BROWSER_PASSKEYS)
list(APPEND gui_SOURCES
gui/reports/ReportsWidgetPasskeys.cpp
gui/reports/ReportsPagePasskeys.cpp
gui/passkeys/PasskeyExporter.cpp
gui/passkeys/PasskeyExportDialog.cpp
gui/passkeys/PasskeyImporter.cpp
gui/passkeys/PasskeyImportDialog.cpp)
endif()

add_subdirectory(autotype)
if(KPXC_FEATURE_NETWORK)
list(APPEND gui_SOURCES
networking/HibpDownloader.cpp
networking/NetworkManager.cpp
networking/UpdateChecker.cpp
gui/UpdateCheckDialog.cpp
gui/IconDownloader.cpp
gui/IconDownloaderDialog.cpp)
endif()

add_subdirectory(cli)
add_subdirectory(thirdparty)

add_subdirectory(autotype)
set(autotype_LIB autotype)

# TODO: Refactor to gui sources
add_subdirectory(qrcode)
set(qrcode_LIB qrcode)

# TODO: Move to gui sources on refactor
add_subdirectory(keeshare)
if(WITH_XC_KEESHARE)
set(keeshare_LIB keeshare)
endif()
set(keeshare_LIB keeshare)

add_subdirectory(sshagent)
if(WITH_XC_SSHAGENT)
if(KPXC_FEATURE_SSHAGENT)
set(sshagent_LIB sshagent)
endif()

add_subdirectory(fdosecrets)
if(WITH_XC_FDOSECRETS)
if(KPXC_FEATURE_FDOSECRETS)
set(fdosecrets_LIB fdosecrets)
endif()

add_subdirectory(thirdparty)

set(autotype_SOURCES
autotype/AutoType.cpp
autotype/AutoTypeAction.cpp
autotype/AutoTypeMatchModel.cpp
autotype/AutoTypeMatchView.cpp
autotype/AutoTypeSelectDialog.cpp
autotype/PickcharsDialog.cpp
autotype/WindowSelectComboBox.cpp)

add_library(autotype STATIC ${autotype_SOURCES})
target_link_libraries(autotype Qt5::Core Qt5::Widgets)

if(WITH_XC_YUBIKEY)
list(APPEND core_SOURCES
keys/drivers/YubiKey.h
keys/drivers/YubiKey.cpp
keys/drivers/YubiKeyInterface.cpp
keys/drivers/YubiKeyInterfaceUSB.cpp
keys/drivers/YubiKeyInterfacePCSC.cpp)
else()
list(APPEND core_SOURCES
keys/drivers/YubiKey.h
keys/drivers/YubiKeyStub.cpp)
endif()

if(WITH_XC_NETWORKING)
list(APPEND gui_SOURCES
networking/HibpDownloader.cpp
networking/NetworkManager.cpp
networking/UpdateChecker.cpp
gui/UpdateCheckDialog.cpp
gui/IconDownloader.cpp
gui/IconDownloaderDialog.cpp)
endif()

configure_file(config-keepassx.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-keepassx.h)
configure_file(git-info.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/git-info.h)

# Core Library Definition
add_library(keepassxc_core STATIC ${core_SOURCES})
set_target_properties(keepassxc_core PROPERTIES COMPILE_DEFINITIONS KEEPASSX_BUILDING_CORE)
set_target_properties(keepassxc_core PROPERTIES COMPILE_DEFINITIONS KPXC_BUILDING_CORE)
target_link_libraries(keepassxc_core
${qrcode_LIB}
Qt5::Core
Expand All @@ -375,12 +330,12 @@ target_link_libraries(keepassxc_core

# GUI Library Definition
add_library(keepassxc_gui STATIC ${gui_SOURCES})
set_target_properties(keepassxc_gui PROPERTIES COMPILE_DEFINITIONS KEEPASSX_BUILDING_CORE)
set_target_properties(keepassxc_gui PROPERTIES COMPILE_DEFINITIONS KPXC_BUILDING_CORE)
target_link_libraries(keepassxc_gui
keepassxc_core
Qt5::Network
Qt5::Widgets
autotype
${autotype_LIB}
${browser_LIB}
${fdosecrets_LIB}
${keeshare_LIB}
Expand All @@ -397,7 +352,7 @@ if(HAIKU)
endif()
if(UNIX AND NOT APPLE)
target_link_libraries(keepassxc_core Qt5::DBus ${LIBUSB_LIBRARIES})
if(WITH_XC_X11)
if(WITH_X11)
target_link_libraries(keepassxc_gui Qt5::X11Extras X11)
endif()
include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS})
Expand Down Expand Up @@ -534,7 +489,7 @@ if(WIN32)
COMPONENT Runtime)

# install OpenSSL library
if(WITH_XC_NETWORKING)
if(KPXC_FEATURE_NETWORK)
find_file(OPENSSL_DLL
NAMES libssl-3.dll libssl-3-x64.dll
HINTS "${OPENSSL_ROOT_DIR}/bin"
Expand Down
2 changes: 0 additions & 2 deletions src/autotype/AutoType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,7 @@ AutoType::AutoType(QObject* parent, bool test)
QString pluginPath = resources()->pluginPath(pluginName);

if (!pluginPath.isEmpty()) {
#ifdef WITH_XC_AUTOTYPE
loadPlugin(pluginPath);
#endif
}

connect(qApp, SIGNAL(aboutToQuit()), SLOT(unloadPlugin()));
Expand Down
Loading

0 comments on commit 30d2a5d

Please sign in to comment.