2018-10-19 15:41:56 -04:00
|
|
|
# Copyright (C) 2018 KeePassXC Team <team@keepassxc.org>
|
2018-01-16 18:56:47 -05:00
|
|
|
# Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
|
2010-08-07 09:10:44 -04:00
|
|
|
#
|
|
|
|
# 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/>.
|
|
|
|
|
2020-06-09 11:45:13 -04:00
|
|
|
cmake_minimum_required(VERSION 3.3.0)
|
2017-12-20 03:25:55 -05:00
|
|
|
|
|
|
|
project(KeePassXC)
|
2022-04-04 19:04:18 -04:00
|
|
|
set(APP_ID "org.keepassxc.${PROJECT_NAME}")
|
2017-12-20 03:25:55 -05:00
|
|
|
|
2013-11-24 16:09:52 -05:00
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
2018-10-19 15:41:56 -04:00
|
|
|
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
|
2019-04-20 12:12:00 -04:00
|
|
|
"Choose the type of build, options are: Debug Release RelWithDebInfo Profile"
|
2018-10-19 15:41:56 -04:00
|
|
|
FORCE)
|
2013-11-24 16:09:52 -05:00
|
|
|
endif()
|
2019-04-20 12:12:00 -04:00
|
|
|
string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER)
|
2021-12-07 23:14:10 -05:00
|
|
|
if(CMAKE_BUILD_TYPE_LOWER STREQUAL "debug" OR CMAKE_BUILD_TYPE_LOWER STREQUAL "relwithdebinfo")
|
|
|
|
set(IS_DEBUG_BUILD TRUE)
|
|
|
|
endif()
|
2013-11-24 16:09:52 -05:00
|
|
|
|
2012-05-21 17:37:29 -04:00
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
2010-09-11 13:49:30 -04:00
|
|
|
|
2017-05-05 20:20:27 -04:00
|
|
|
# Support Visual Studio Code
|
|
|
|
include(CMakeToolsHelpers OPTIONAL)
|
2019-12-16 03:53:57 -05:00
|
|
|
include(FeatureSummary)
|
2022-03-08 06:30:17 -05:00
|
|
|
include(KPXCMacDeployHelpers)
|
2017-05-05 20:20:27 -04:00
|
|
|
|
2012-05-21 14:33:33 -04:00
|
|
|
include(CheckCCompilerFlag)
|
|
|
|
include(CheckCXXCompilerFlag)
|
|
|
|
include(CheckCXXSourceCompiles)
|
|
|
|
|
2010-08-13 12:08:06 -04:00
|
|
|
option(WITH_TESTS "Enable building of unit tests" ON)
|
2011-12-26 13:18:21 -05:00
|
|
|
option(WITH_GUI_TESTS "Enable building of GUI tests" OFF)
|
2015-10-13 16:51:31 -04:00
|
|
|
option(WITH_DEV_BUILD "Use only for development. Disables/warns about deprecated methods." OFF)
|
2017-10-15 18:27:07 -04:00
|
|
|
option(WITH_ASAN "Enable address sanitizer checks (Linux / macOS only)" OFF)
|
2017-03-15 10:26:40 -04:00
|
|
|
option(WITH_COVERAGE "Use to build with coverage tests (GCC only)." OFF)
|
2017-10-15 08:54:27 -04:00
|
|
|
option(WITH_APP_BUNDLE "Enable Application Bundle for macOS" ON)
|
2020-01-07 17:44:08 -05:00
|
|
|
option(WITH_CCACHE "Use ccache for build" OFF)
|
2010-08-07 09:10:44 -04:00
|
|
|
|
2019-02-21 16:28:45 -05:00
|
|
|
set(WITH_XC_ALL OFF CACHE BOOL "Build in all available plugins")
|
2017-11-27 22:46:03 -05:00
|
|
|
|
2017-03-02 22:07:42 -05:00
|
|
|
option(WITH_XC_AUTOTYPE "Include Auto-Type." ON)
|
2019-05-07 12:56:55 -04:00
|
|
|
option(WITH_XC_NETWORKING "Include networking code (e.g. for downloading website icons)." OFF)
|
2018-01-16 18:56:47 -05:00
|
|
|
option(WITH_XC_BROWSER "Include browser integration with keepassxc-browser." OFF)
|
2017-02-25 11:11:02 -05:00
|
|
|
option(WITH_XC_YUBIKEY "Include YubiKey support." OFF)
|
2017-10-29 11:17:24 -04:00
|
|
|
option(WITH_XC_SSHAGENT "Include SSH agent support." OFF)
|
2021-05-16 20:16:01 -04:00
|
|
|
option(WITH_XC_KEESHARE "Sharing integration with KeeShare" OFF)
|
2019-04-09 21:06:13 -04:00
|
|
|
option(WITH_XC_UPDATECHECK "Include automatic update checks; disable for controlled distributions" ON)
|
Add Freedesktop.org Secret Storage Spec Server Side API (Fix #1403)
This plugin implements the Secret Storage specification version 0.2.
While running KeePassXC, it acts as a Secret Service server, registered
on DBus, so clients like seahorse, python-secretstorage, or other
implementations can connect and access the exposed database in KeePassXC.
Squashed commits:
- Initial code
- Add SessionAdaptor and fix build
- The skeletons for all dbus objects are in place
- Implement collection creation and deletion
- Emit collectionChanged signal
- Implement app-wise settings page
- Implement error message on GUI
- Implement settings
- Fix uuid to dbus path
- Implement app level settings
- Add freedesktop logo
- Implement database settings page
- Change database settings to a treeview
- Move all settings read/write to one place
- Rename SecretServiceOptionsPage to SettingsWidgetFdoSecrets
- Fix selected group can not be saved if the user hasn't click on the item
- Show selected group per database in app settings
- Disable editing of various readonly widgets
- Remove unused warning about non exposed database
- Fix method signature on dbus adaptors
- Fix type derived from DBusObject not recognized as QDBusContext
- Resolve a few TODOs around error handling
- Remove const when passing DBus exposed objects
- Move dismiss to PromptBase
- Implement per collection locking/unlocking
- Fix const correctness on Item::setSecret
- Implement SecretService::getSecrets
- Rework the signal connections around collections.
- Remove generateId from DBusObject
- Per spec, use encoded label as DBus object path for collections
- Fix some corner cases around collection name changes
- Implement alias
- Fix wrong alias dbus path
- Implement encryption per spec
- Cleanup SessionCipher
- Implement searchItems for SecretService
- Use Tools::uuidToHex
- Implement Item attributes and delete
- Implement createItem
- Always check if the database is unlocked before perform any operation
- Add missing ReadAlias/SetAlias on service
- Reorganize and fix OpenSession always returning empty output
- Overhaul error handling
- Make sure default alias is always present
- Remove collection aliases early in doDelete
- Handles all content types, fix setProperties not working
- Fix sometimes there is an extraneous leading zero when converting from MPI
- Fix session encryption negotiation
- Do not expose recycle bin
- Protect against the methods not called from DBus
- Also emit collectionChanged signal when lock state changes
- Show notification when entry secret is requested
- Add a README file
- Actually close session when client disconnects
- Gracefully return alternative label when collection is locked
- Reorganize, rename secretservice to fdosecrets
- Fix issues reported by clazy
- Unify UI strings and fix icon
- Implement a setting to skip confirmation when deleting entries from DBus
- Remove some unused debugging log
- Simply ignore errors when DBus context is not available. QtDBus won't set QDBusContext when deliver property get/set, and there is no way to get a QDBusMessage in property getter/setter.
- Simplify GcryptMPI using std::unique_ptr and add unit test
- Format code in fdosecrets
- Move DBusReturnImpl to details namespace
- Fix crash when locking a database: don't modify exposedGroup setting in customData when database is deleted
- Make sure Collection::searchItems works, whether it's locked or not
- Fix FdoSecrets::Collection becomes empty after a database reload
- Fix crash when looping while modifying the list
2019-03-25 23:07:18 -04:00
|
|
|
if(UNIX AND NOT APPLE)
|
|
|
|
option(WITH_XC_FDOSECRETS "Implement freedesktop.org Secret Storage Spec server side API." OFF)
|
|
|
|
endif()
|
2020-07-03 13:41:33 -04:00
|
|
|
option(WITH_XC_DOCS "Enable building of documentation" ON)
|
2018-01-16 18:56:47 -05:00
|
|
|
|
2020-01-07 17:44:08 -05:00
|
|
|
if(WITH_CCACHE)
|
|
|
|
# Use the Compiler Cache (ccache) program
|
|
|
|
# (install with: sudo apt get ccache)
|
2020-02-16 10:35:08 -05:00
|
|
|
find_program(CCACHE_FOUND ccache)
|
2020-09-27 03:16:30 -04:00
|
|
|
if(NOT CCACHE_FOUND)
|
2020-01-07 17:44:08 -05:00
|
|
|
message(FATAL_ERROR "ccache requested but cannot be found.")
|
|
|
|
endif()
|
2020-09-27 03:16:30 -04:00
|
|
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_FOUND})
|
2020-01-07 17:44:08 -05:00
|
|
|
endif()
|
|
|
|
|
2017-11-27 22:46:03 -05:00
|
|
|
if(WITH_XC_ALL)
|
2020-07-03 13:41:33 -04:00
|
|
|
# Enable all options (except update check and docs)
|
2018-10-19 15:41:56 -04:00
|
|
|
set(WITH_XC_AUTOTYPE ON)
|
|
|
|
set(WITH_XC_NETWORKING ON)
|
|
|
|
set(WITH_XC_BROWSER ON)
|
|
|
|
set(WITH_XC_YUBIKEY ON)
|
|
|
|
set(WITH_XC_SSHAGENT ON)
|
2019-01-04 03:33:00 -05:00
|
|
|
set(WITH_XC_KEESHARE ON)
|
Add Freedesktop.org Secret Storage Spec Server Side API (Fix #1403)
This plugin implements the Secret Storage specification version 0.2.
While running KeePassXC, it acts as a Secret Service server, registered
on DBus, so clients like seahorse, python-secretstorage, or other
implementations can connect and access the exposed database in KeePassXC.
Squashed commits:
- Initial code
- Add SessionAdaptor and fix build
- The skeletons for all dbus objects are in place
- Implement collection creation and deletion
- Emit collectionChanged signal
- Implement app-wise settings page
- Implement error message on GUI
- Implement settings
- Fix uuid to dbus path
- Implement app level settings
- Add freedesktop logo
- Implement database settings page
- Change database settings to a treeview
- Move all settings read/write to one place
- Rename SecretServiceOptionsPage to SettingsWidgetFdoSecrets
- Fix selected group can not be saved if the user hasn't click on the item
- Show selected group per database in app settings
- Disable editing of various readonly widgets
- Remove unused warning about non exposed database
- Fix method signature on dbus adaptors
- Fix type derived from DBusObject not recognized as QDBusContext
- Resolve a few TODOs around error handling
- Remove const when passing DBus exposed objects
- Move dismiss to PromptBase
- Implement per collection locking/unlocking
- Fix const correctness on Item::setSecret
- Implement SecretService::getSecrets
- Rework the signal connections around collections.
- Remove generateId from DBusObject
- Per spec, use encoded label as DBus object path for collections
- Fix some corner cases around collection name changes
- Implement alias
- Fix wrong alias dbus path
- Implement encryption per spec
- Cleanup SessionCipher
- Implement searchItems for SecretService
- Use Tools::uuidToHex
- Implement Item attributes and delete
- Implement createItem
- Always check if the database is unlocked before perform any operation
- Add missing ReadAlias/SetAlias on service
- Reorganize and fix OpenSession always returning empty output
- Overhaul error handling
- Make sure default alias is always present
- Remove collection aliases early in doDelete
- Handles all content types, fix setProperties not working
- Fix sometimes there is an extraneous leading zero when converting from MPI
- Fix session encryption negotiation
- Do not expose recycle bin
- Protect against the methods not called from DBus
- Also emit collectionChanged signal when lock state changes
- Show notification when entry secret is requested
- Add a README file
- Actually close session when client disconnects
- Gracefully return alternative label when collection is locked
- Reorganize, rename secretservice to fdosecrets
- Fix issues reported by clazy
- Unify UI strings and fix icon
- Implement a setting to skip confirmation when deleting entries from DBus
- Remove some unused debugging log
- Simply ignore errors when DBus context is not available. QtDBus won't set QDBusContext when deliver property get/set, and there is no way to get a QDBusMessage in property getter/setter.
- Simplify GcryptMPI using std::unique_ptr and add unit test
- Format code in fdosecrets
- Move DBusReturnImpl to details namespace
- Fix crash when locking a database: don't modify exposedGroup setting in customData when database is deleted
- Make sure Collection::searchItems works, whether it's locked or not
- Fix FdoSecrets::Collection becomes empty after a database reload
- Fix crash when looping while modifying the list
2019-03-25 23:07:18 -04:00
|
|
|
if(UNIX AND NOT APPLE)
|
|
|
|
set(WITH_XC_FDOSECRETS ON)
|
|
|
|
endif()
|
2017-11-27 22:46:03 -05:00
|
|
|
endif()
|
|
|
|
|
2019-05-07 12:56:55 -04:00
|
|
|
# Prefer WITH_XC_NETWORKING setting over WITH_XC_UPDATECHECK
|
|
|
|
if(NOT WITH_XC_NETWORKING AND WITH_XC_UPDATECHECK)
|
|
|
|
message(STATUS "Disabling WITH_XC_UPDATECHECK because WITH_XC_NETWORKING is disabled")
|
|
|
|
set(WITH_XC_UPDATECHECK OFF)
|
2019-04-09 21:06:13 -04:00
|
|
|
endif()
|
|
|
|
|
2017-05-06 11:50:05 -04:00
|
|
|
set(KEEPASSXC_VERSION_MAJOR "2")
|
2020-10-24 10:58:23 -04:00
|
|
|
set(KEEPASSXC_VERSION_MINOR "7")
|
2022-04-05 22:09:15 -04:00
|
|
|
set(KEEPASSXC_VERSION_PATCH "1")
|
2017-05-06 11:50:05 -04:00
|
|
|
set(KEEPASSXC_VERSION "${KEEPASSXC_VERSION_MAJOR}.${KEEPASSXC_VERSION_MINOR}.${KEEPASSXC_VERSION_PATCH}")
|
2019-03-21 16:21:45 -04:00
|
|
|
set(OVERRIDE_VERSION "" CACHE STRING "Override the KeePassXC Version for Snapshot builds")
|
2010-08-13 12:08:06 -04:00
|
|
|
|
2018-02-17 11:46:19 -05:00
|
|
|
set(KEEPASSXC_BUILD_TYPE "Snapshot" CACHE STRING "Set KeePassXC build type to distinguish between stable releases and snapshots")
|
|
|
|
set_property(CACHE KEEPASSXC_BUILD_TYPE PROPERTY STRINGS Snapshot Release PreRelease)
|
|
|
|
|
2019-01-30 15:00:47 -05:00
|
|
|
# Retrieve git HEAD revision hash
|
|
|
|
set(GIT_HEAD_OVERRIDE "" CACHE STRING "Manually set the Git HEAD hash when missing (eg, when no .git folder exists)")
|
|
|
|
execute_process(COMMAND git rev-parse --short=7 HEAD
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
|
|
OUTPUT_VARIABLE GIT_HEAD
|
|
|
|
ERROR_QUIET)
|
|
|
|
string(STRIP "${GIT_HEAD}" GIT_HEAD)
|
2019-03-21 16:21:45 -04:00
|
|
|
if(GIT_HEAD STREQUAL "" AND NOT GIT_HEAD_OVERRIDE STREQUAL "")
|
2019-01-30 15:00:47 -05:00
|
|
|
string(SUBSTRING "${GIT_HEAD_OVERRIDE}" 0 7 GIT_HEAD)
|
2019-03-21 16:21:45 -04:00
|
|
|
elseif(EXISTS ${CMAKE_SOURCE_DIR}/.gitrev)
|
|
|
|
file(READ ${CMAKE_SOURCE_DIR}/.gitrev GIT_HEAD)
|
2019-01-30 15:00:47 -05:00
|
|
|
endif()
|
|
|
|
message(STATUS "Found Git HEAD Revision: ${GIT_HEAD}\n")
|
|
|
|
|
2018-01-29 23:00:52 -05:00
|
|
|
# Check if on a tag, if so build as a release
|
|
|
|
execute_process(COMMAND git tag --points-at HEAD
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
2019-01-30 15:00:47 -05:00
|
|
|
OUTPUT_VARIABLE GIT_TAG
|
|
|
|
ERROR_QUIET)
|
2022-04-05 07:14:03 -04:00
|
|
|
string(REGEX REPLACE "latest" "" GIT_TAG "${GIT_TAG}")
|
|
|
|
if(GIT_TAG MATCHES "[0-9]+\.[0-9]+\.[0-9]+")
|
2019-01-30 15:00:47 -05:00
|
|
|
string(STRIP "${GIT_TAG}" GIT_TAG)
|
2018-10-19 15:41:56 -04:00
|
|
|
set(OVERRIDE_VERSION ${GIT_TAG})
|
2018-03-01 08:39:22 -05:00
|
|
|
elseif(EXISTS ${CMAKE_SOURCE_DIR}/.version)
|
2018-10-19 15:41:56 -04:00
|
|
|
file(READ ${CMAKE_SOURCE_DIR}/.version OVERRIDE_VERSION)
|
2018-02-22 15:31:32 -05:00
|
|
|
endif()
|
2018-02-17 11:46:19 -05:00
|
|
|
|
2018-02-22 15:31:32 -05:00
|
|
|
string(REGEX REPLACE "(\r?\n)+" "" OVERRIDE_VERSION "${OVERRIDE_VERSION}")
|
|
|
|
if(OVERRIDE_VERSION)
|
2022-04-05 07:14:03 -04:00
|
|
|
if(OVERRIDE_VERSION MATCHES "^[\\.0-9]+-beta[0-9]*")
|
|
|
|
set(KEEPASSXC_BUILD_TYPE "PreRelease")
|
2018-10-19 15:41:56 -04:00
|
|
|
set(KEEPASSXC_VERSION ${OVERRIDE_VERSION})
|
|
|
|
elseif(OVERRIDE_VERSION MATCHES "^[\\.0-9]+$")
|
2022-04-05 07:14:03 -04:00
|
|
|
set(KEEPASSXC_BUILD_TYPE "Release")
|
2018-10-19 15:41:56 -04:00
|
|
|
set(KEEPASSXC_VERSION ${OVERRIDE_VERSION})
|
2019-03-21 16:21:45 -04:00
|
|
|
else()
|
2022-04-05 07:14:03 -04:00
|
|
|
set(KEEPASSXC_BUILD_TYPE "Snapshot")
|
2019-03-21 16:21:45 -04:00
|
|
|
set(KEEPASSXC_VERSION ${OVERRIDE_VERSION})
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
if(KEEPASSXC_BUILD_TYPE STREQUAL "PreRelease")
|
|
|
|
set(KEEPASSXC_VERSION "${KEEPASSXC_VERSION}-preview")
|
|
|
|
elseif(KEEPASSXC_BUILD_TYPE STREQUAL "Snapshot")
|
|
|
|
set(KEEPASSXC_VERSION "${KEEPASSXC_VERSION}-snapshot")
|
2018-10-19 15:41:56 -04:00
|
|
|
endif()
|
2017-11-27 22:46:03 -05:00
|
|
|
endif()
|
|
|
|
|
2018-02-17 11:46:19 -05:00
|
|
|
if(KEEPASSXC_BUILD_TYPE STREQUAL "Release")
|
2018-10-19 15:41:56 -04:00
|
|
|
set(KEEPASSXC_BUILD_TYPE_RELEASE ON)
|
2018-02-17 11:46:19 -05:00
|
|
|
elseif(KEEPASSXC_BUILD_TYPE STREQUAL "PreRelease")
|
2018-10-19 15:41:56 -04:00
|
|
|
set(KEEPASSXC_BUILD_TYPE_PRE_RELEASE ON)
|
2018-02-17 11:46:19 -05:00
|
|
|
else()
|
2018-10-19 15:41:56 -04:00
|
|
|
set(KEEPASSXC_BUILD_TYPE_SNAPSHOT ON)
|
2018-02-17 11:46:19 -05:00
|
|
|
endif()
|
|
|
|
|
2017-11-27 22:46:03 -05:00
|
|
|
message(STATUS "Setting up build for KeePassXC v${KEEPASSXC_VERSION}\n")
|
|
|
|
|
2017-10-16 11:47:19 -04:00
|
|
|
# Distribution info
|
2018-02-17 11:46:19 -05:00
|
|
|
set(KEEPASSXC_DIST ON)
|
|
|
|
set(KEEPASSXC_DIST_TYPE "Other" CACHE STRING "KeePassXC Distribution Type")
|
2022-04-04 19:04:18 -04:00
|
|
|
set_property(CACHE KEEPASSXC_DIST_TYPE PROPERTY STRINGS Snap AppImage Flatpak Other)
|
2017-10-17 06:56:42 -04:00
|
|
|
if(KEEPASSXC_DIST_TYPE STREQUAL "Snap")
|
2018-10-19 15:41:56 -04:00
|
|
|
set(KEEPASSXC_DIST_SNAP ON)
|
2017-10-17 06:56:42 -04:00
|
|
|
elseif(KEEPASSXC_DIST_TYPE STREQUAL "AppImage")
|
2018-10-19 15:41:56 -04:00
|
|
|
set(KEEPASSXC_DIST_APPIMAGE ON)
|
2022-04-04 19:04:18 -04:00
|
|
|
elseif(KEEPASSXC_DIST_TYPE STREQUAL "Flatpak")
|
|
|
|
set(KEEPASSXC_DIST_FLATPAK ON)
|
2017-10-17 06:56:42 -04:00
|
|
|
elseif(KEEPASSXC_DIST_TYPE STREQUAL "Other")
|
2018-10-19 15:41:56 -04:00
|
|
|
unset(KEEPASSXC_DIST)
|
2017-10-16 11:47:19 -04:00
|
|
|
endif()
|
2017-10-03 12:29:39 -04:00
|
|
|
|
2021-10-20 06:57:29 -04:00
|
|
|
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.14.0")
|
|
|
|
cmake_policy(SET CMP0083 NEW)
|
|
|
|
include(CheckPIESupported)
|
|
|
|
check_pie_supported()
|
|
|
|
endif()
|
|
|
|
|
2021-10-13 09:15:59 -04:00
|
|
|
# Create position independent code for shared libraries and executables
|
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
|
|
|
2018-05-09 06:47:34 -04:00
|
|
|
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "4")
|
2018-10-19 15:41:56 -04:00
|
|
|
set(IS_32BIT TRUE)
|
2018-05-09 06:47:34 -04:00
|
|
|
endif()
|
|
|
|
|
2019-05-19 15:58:52 -04:00
|
|
|
set(CLANG_COMPILER_ID_REGEX "^(Apple)?[Cc]lang$")
|
2019-02-21 16:28:45 -05:00
|
|
|
if("${CMAKE_C_COMPILER}" MATCHES "clang$"
|
|
|
|
OR "${CMAKE_EXTRA_GENERATOR_C_SYSTEM_DEFINED_MACROS}" MATCHES "__clang__"
|
2019-05-19 15:58:52 -04:00
|
|
|
OR "${CMAKE_C_COMPILER_ID}" MATCHES ${CLANG_COMPILER_ID_REGEX})
|
2018-10-19 15:41:56 -04:00
|
|
|
set(CMAKE_COMPILER_IS_CLANG 1)
|
2012-05-21 17:37:29 -04:00
|
|
|
endif()
|
2012-04-21 13:47:39 -04:00
|
|
|
|
2019-02-21 16:28:45 -05:00
|
|
|
if("${CMAKE_CXX_COMPILER}" MATCHES "clang(\\+\\+)?$"
|
|
|
|
OR "${CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS}" MATCHES "__clang__"
|
2019-05-19 15:58:52 -04:00
|
|
|
OR "${CMAKE_CXX_COMPILER_ID}" MATCHES ${CLANG_COMPILER_ID_REGEX})
|
2018-10-19 15:41:56 -04:00
|
|
|
set(CMAKE_COMPILER_IS_CLANGXX 1)
|
2012-05-21 17:37:29 -04:00
|
|
|
endif()
|
2012-04-18 10:10:40 -04:00
|
|
|
|
2012-04-21 13:47:39 -04:00
|
|
|
macro(add_gcc_compiler_cxxflags FLAGS)
|
2018-10-19 15:41:56 -04:00
|
|
|
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS}")
|
|
|
|
endif()
|
2012-04-21 13:47:39 -04:00
|
|
|
endmacro(add_gcc_compiler_cxxflags)
|
|
|
|
|
|
|
|
macro(add_gcc_compiler_cflags FLAGS)
|
2018-10-19 15:41:56 -04:00
|
|
|
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAGS}")
|
|
|
|
endif()
|
2012-04-21 13:47:39 -04:00
|
|
|
endmacro(add_gcc_compiler_cflags)
|
|
|
|
|
|
|
|
macro(add_gcc_compiler_flags FLAGS)
|
2018-10-19 15:41:56 -04:00
|
|
|
add_gcc_compiler_cxxflags("${FLAGS}")
|
|
|
|
add_gcc_compiler_cflags("${FLAGS}")
|
2012-04-21 13:47:39 -04:00
|
|
|
endmacro(add_gcc_compiler_flags)
|
2012-04-18 10:10:40 -04:00
|
|
|
|
2020-06-01 15:08:26 -04:00
|
|
|
# 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(check_add_gcc_compiler_cxxflag)
|
|
|
|
|
|
|
|
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(check_add_gcc_compiler_cflag)
|
|
|
|
|
2020-06-09 11:45:13 -04:00
|
|
|
# This is the "front-end" for the above macros
|
|
|
|
# Optionally takes additional parameter(s) with language to check (currently "C" or "CXX")
|
2020-06-01 15:08:26 -04:00
|
|
|
macro(check_add_gcc_compiler_flag FLAG)
|
|
|
|
string(REGEX REPLACE "[-=]" "_" FLAGNAME "${FLAG}")
|
2020-06-09 11:45:13 -04:00
|
|
|
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()
|
2020-06-01 15:08:26 -04:00
|
|
|
endmacro(check_add_gcc_compiler_flag)
|
|
|
|
|
2016-11-02 21:01:02 -04:00
|
|
|
add_definitions(-DQT_NO_EXCEPTIONS -DQT_STRICT_ITERATORS -DQT_NO_CAST_TO_ASCII)
|
2022-03-22 15:09:53 -04:00
|
|
|
if(NOT IS_DEBUG_BUILD)
|
|
|
|
add_definitions(-DQT_NO_DEBUG_OUTPUT)
|
|
|
|
endif()
|
2011-11-20 04:14:50 -05:00
|
|
|
|
2017-05-05 13:49:52 -04:00
|
|
|
if(WITH_APP_BUNDLE)
|
2018-10-19 15:41:56 -04:00
|
|
|
add_definitions(-DWITH_APP_BUNDLE)
|
2017-05-05 13:49:52 -04:00
|
|
|
endif()
|
|
|
|
|
2017-03-10 12:09:46 -05:00
|
|
|
add_gcc_compiler_flags("-fno-common")
|
2021-11-23 07:34:35 -05:00
|
|
|
find_package(OpenMP)
|
|
|
|
if(OpenMP_FOUND)
|
|
|
|
add_gcc_compiler_cflags(${OpenMP_C_FLAGS})
|
|
|
|
add_gcc_compiler_cxxflags(${OpenMP_CXX_FLAGS})
|
|
|
|
endif()
|
2018-03-03 08:19:51 -05:00
|
|
|
add_gcc_compiler_flags("-Wall -Wextra -Wundef -Wpointer-arith -Wno-long-long")
|
2012-05-21 14:33:33 -04:00
|
|
|
add_gcc_compiler_flags("-Wformat=2 -Wmissing-format-attribute")
|
2013-04-05 15:04:02 -04:00
|
|
|
add_gcc_compiler_flags("-fvisibility=hidden")
|
|
|
|
add_gcc_compiler_cxxflags("-fvisibility-inlines-hidden")
|
2012-04-18 10:10:40 -04:00
|
|
|
|
2019-04-20 12:12:00 -04:00
|
|
|
if(CMAKE_BUILD_TYPE_LOWER STREQUAL "debug")
|
2020-06-01 15:08:26 -04:00
|
|
|
check_add_gcc_compiler_flag("-Wshadow-compatible-local")
|
|
|
|
check_add_gcc_compiler_flag("-Wshadow-local")
|
2018-10-19 15:41:56 -04:00
|
|
|
add_gcc_compiler_flags("-Werror")
|
2018-03-03 08:19:51 -05:00
|
|
|
endif()
|
|
|
|
|
2019-03-24 09:26:34 -04:00
|
|
|
if (NOT HAIKU)
|
2021-03-13 14:07:49 -05:00
|
|
|
if((CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.8.999) OR CMAKE_COMPILER_IS_CLANGXX)
|
|
|
|
add_gcc_compiler_flags("-fstack-protector-strong")
|
|
|
|
else()
|
|
|
|
add_gcc_compiler_flags("-fstack-protector --param=ssp-buffer-size=4")
|
|
|
|
endif()
|
2019-03-24 09:26:34 -04:00
|
|
|
endif()
|
2017-03-10 12:09:46 -05:00
|
|
|
|
2012-04-21 13:47:39 -04:00
|
|
|
add_gcc_compiler_cxxflags("-Wnon-virtual-dtor -Wold-style-cast -Woverloaded-virtual")
|
2012-05-21 14:33:33 -04:00
|
|
|
add_gcc_compiler_cflags("-Wchar-subscripts -Wwrite-strings")
|
2017-10-15 08:54:27 -04:00
|
|
|
|
2017-03-14 09:29:09 -04:00
|
|
|
if(WITH_ASAN)
|
2018-10-19 15:41:56 -04:00
|
|
|
if(NOT (CMAKE_SYSTEM_NAME STREQUAL "Linux" OR APPLE))
|
|
|
|
message(FATAL_ERROR "WITH_ASAN is only supported on Linux / macOS at the moment.")
|
|
|
|
endif()
|
2017-03-14 16:24:32 -04:00
|
|
|
|
2018-10-19 15:41:56 -04:00
|
|
|
add_gcc_compiler_flags("-fsanitize=address -DWITH_ASAN")
|
2017-03-14 09:53:29 -04:00
|
|
|
|
2018-10-19 15:41:56 -04:00
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
|
|
if(NOT (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9))
|
|
|
|
add_gcc_compiler_flags("-fsanitize=leak -DWITH_LSAN")
|
|
|
|
endif()
|
2017-10-15 08:54:27 -04:00
|
|
|
endif()
|
|
|
|
|
2017-03-14 09:29:09 -04:00
|
|
|
endif()
|
2012-05-21 14:33:33 -04:00
|
|
|
|
2018-10-19 15:41:56 -04:00
|
|
|
if(CMAKE_BUILD_TYPE_LOWER MATCHES "(release|relwithdebinfo|minsizerel)")
|
|
|
|
add_gcc_compiler_flags("-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2")
|
2013-11-24 15:40:19 -05:00
|
|
|
endif()
|
|
|
|
|
2020-06-01 15:08:26 -04:00
|
|
|
check_add_gcc_compiler_flag("-Werror=format-security")
|
2020-06-09 11:45:13 -04:00
|
|
|
check_add_gcc_compiler_flag("-Werror=implicit-function-declaration" C)
|
2020-06-01 15:08:26 -04:00
|
|
|
check_add_gcc_compiler_flag("-Wcast-align")
|
2012-04-21 13:47:39 -04:00
|
|
|
|
2020-12-13 23:23:25 -05:00
|
|
|
if(UNIX AND NOT APPLE)
|
2020-06-01 15:08:26 -04:00
|
|
|
check_add_gcc_compiler_flag("-Qunused-arguments")
|
2018-10-19 15:41:56 -04:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-add-needed -Wl,--as-needed -Wl,--no-undefined")
|
2020-12-13 23:23:25 -05:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,relro,-z,now -pie")
|
2018-10-19 15:41:56 -04:00
|
|
|
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-add-needed -Wl,--as-needed")
|
|
|
|
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-z,relro,-z,now")
|
2012-05-21 17:37:29 -04:00
|
|
|
endif()
|
2010-08-07 09:10:44 -04:00
|
|
|
|
2021-11-29 04:57:59 -05:00
|
|
|
set(CMAKE_C_STANDARD 99)
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
2021-12-07 23:14:10 -05:00
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
2012-04-18 14:18:48 -04:00
|
|
|
|
2021-11-24 13:01:00 -05:00
|
|
|
check_cxx_compiler_flag("-fsized-deallocation" CXX_HAS_fsized_deallocation)
|
|
|
|
if(CXX_HAS_fsized_deallocation)
|
|
|
|
# Do additional check: the deallocation functions must be there too.
|
|
|
|
set(CMAKE_REQUIRED_FLAGS "-fsized-deallocation")
|
|
|
|
check_cxx_source_compiles("#include <new>
|
|
|
|
int main() { void * ptr = nullptr; std::size_t size = 1; ::operator delete(ptr, size); }"
|
|
|
|
HAVE_DEALLOCATION_FUNCTIONS)
|
|
|
|
if(HAVE_DEALLOCATION_FUNCTIONS)
|
|
|
|
check_add_gcc_compiler_flag("-fsized-deallocation" CXX)
|
|
|
|
endif()
|
|
|
|
unset(CMAKE_REQUIRED_FLAGS)
|
|
|
|
endif()
|
2019-02-21 16:28:45 -05:00
|
|
|
|
2019-05-19 15:58:52 -04:00
|
|
|
if(APPLE AND CMAKE_COMPILER_IS_CLANGXX)
|
2018-10-19 15:41:56 -04:00
|
|
|
add_gcc_compiler_cxxflags("-stdlib=libc++")
|
2012-05-21 17:37:29 -04:00
|
|
|
endif()
|
2012-04-18 14:18:48 -04:00
|
|
|
|
2015-10-13 16:51:31 -04:00
|
|
|
if(WITH_DEV_BUILD)
|
2021-04-04 08:56:00 -04:00
|
|
|
add_definitions(-DQT_DEPRECATED_WARNINGS)
|
2019-12-30 11:54:50 -05:00
|
|
|
else()
|
|
|
|
add_definitions(-DQT_NO_DEPRECATED_WARNINGS)
|
|
|
|
add_gcc_compiler_cxxflags("-Wno-deprecated-declarations")
|
2012-06-29 08:14:58 -04:00
|
|
|
endif()
|
|
|
|
|
2021-12-07 23:14:10 -05:00
|
|
|
# MSVC specific options
|
2021-09-06 22:26:00 -04:00
|
|
|
if (MSVC)
|
2021-12-07 23:14:10 -05:00
|
|
|
if(MSVC_TOOLSET_VERSION LESS 141)
|
2021-09-06 22:26:00 -04:00
|
|
|
message(FATAL_ERROR "Only Microsoft Visual Studio 17 and newer are supported!")
|
|
|
|
endif()
|
|
|
|
add_compile_options(/permissive- /utf-8)
|
2021-12-07 23:14:10 -05:00
|
|
|
if(IS_DEBUG_BUILD)
|
|
|
|
add_compile_options(/Zf)
|
|
|
|
if(MSVC_TOOLSET_VERSION GREATER 141)
|
|
|
|
add_compile_definitions(/fsanitize=address)
|
|
|
|
endif()
|
|
|
|
endif()
|
2021-09-06 22:26:00 -04:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WIN32)
|
2018-10-19 15:41:56 -04:00
|
|
|
set(CMAKE_RC_COMPILER_INIT windres)
|
|
|
|
enable_language(RC)
|
2021-09-06 22:26:00 -04:00
|
|
|
if(MINGW)
|
|
|
|
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
|
|
|
|
endif()
|
2021-12-07 23:14:10 -05:00
|
|
|
if(NOT IS_DEBUG_BUILD)
|
2021-09-06 22:26:00 -04:00
|
|
|
if(MSVC)
|
2021-12-07 23:14:10 -05:00
|
|
|
# By default MSVC enables NXCOMPAT
|
|
|
|
add_compile_options(/guard:cf)
|
|
|
|
add_link_options(/DYNAMICBASE /HIGHENTROPYVA /GUARD:CF)
|
2021-09-06 22:26:00 -04:00
|
|
|
else(MINGW)
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--nxcompat -Wl,--dynamicbase")
|
|
|
|
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--nxcompat -Wl,--dynamicbase")
|
|
|
|
# Enable high entropy ASLR for 64-bit builds
|
|
|
|
if(NOT IS_32BIT)
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--high-entropy-va")
|
|
|
|
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--high-entropy-va")
|
|
|
|
endif()
|
2018-10-19 15:41:56 -04:00
|
|
|
endif()
|
2018-05-09 06:47:34 -04:00
|
|
|
endif()
|
2012-10-23 08:52:59 -04:00
|
|
|
endif()
|
|
|
|
|
2021-09-06 22:26:00 -04:00
|
|
|
if(APPLE AND WITH_APP_BUNDLE OR WIN32)
|
2018-10-19 15:41:56 -04:00
|
|
|
set(PROGNAME KeePassXC)
|
2012-05-21 17:37:29 -04:00
|
|
|
else()
|
2018-10-19 15:41:56 -04:00
|
|
|
set(PROGNAME keepassxc)
|
2012-05-21 17:37:29 -04:00
|
|
|
endif()
|
2010-08-07 09:10:44 -04:00
|
|
|
|
2021-09-06 22:26:00 -04:00
|
|
|
if(WIN32)
|
2018-10-19 15:41:56 -04:00
|
|
|
set(CLI_INSTALL_DIR ".")
|
|
|
|
set(PROXY_INSTALL_DIR ".")
|
|
|
|
set(BIN_INSTALL_DIR ".")
|
|
|
|
set(PLUGIN_INSTALL_DIR ".")
|
|
|
|
set(DATA_INSTALL_DIR "share")
|
2017-05-05 13:49:52 -04:00
|
|
|
elseif(APPLE AND WITH_APP_BUNDLE)
|
2020-03-24 19:24:27 -04:00
|
|
|
set(BUNDLE_INSTALL_DIR "${PROGNAME}.app/Contents")
|
|
|
|
set(CMAKE_INSTALL_MANDIR "${BUNDLE_INSTALL_DIR}/Resources/man")
|
|
|
|
set(CLI_INSTALL_DIR "${BUNDLE_INSTALL_DIR}/MacOS")
|
|
|
|
set(PROXY_INSTALL_DIR "${BUNDLE_INSTALL_DIR}/MacOS")
|
|
|
|
set(BIN_INSTALL_DIR "${BUNDLE_INSTALL_DIR}/MacOS")
|
|
|
|
set(PLUGIN_INSTALL_DIR "${BUNDLE_INSTALL_DIR}/PlugIns")
|
|
|
|
set(DATA_INSTALL_DIR "${BUNDLE_INSTALL_DIR}/Resources")
|
2012-05-21 17:37:29 -04:00
|
|
|
else()
|
2018-10-19 15:41:56 -04:00
|
|
|
include(GNUInstallDirs)
|
2013-04-29 16:17:31 -04:00
|
|
|
|
2018-10-19 15:41:56 -04:00
|
|
|
set(CLI_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}")
|
|
|
|
set(PROXY_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}")
|
|
|
|
set(BIN_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}")
|
|
|
|
set(PLUGIN_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/keepassxc")
|
|
|
|
set(DATA_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/keepassxc")
|
2012-05-21 17:37:29 -04:00
|
|
|
endif()
|
2011-12-29 17:50:22 -05:00
|
|
|
|
2012-05-21 17:37:29 -04:00
|
|
|
if(WITH_TESTS)
|
2018-10-19 15:41:56 -04:00
|
|
|
enable_testing()
|
2012-05-21 17:37:29 -04:00
|
|
|
endif(WITH_TESTS)
|
2010-08-13 12:08:06 -04:00
|
|
|
|
2018-09-29 08:55:33 -04:00
|
|
|
if(WITH_COVERAGE)
|
2018-10-19 15:41:56 -04:00
|
|
|
# Include code coverage, use with -DCMAKE_BUILD_TYPE=Debug
|
|
|
|
include(CodeCoverage)
|
|
|
|
append_coverage_compiler_flags()
|
2021-09-26 06:35:42 -04:00
|
|
|
|
2021-09-27 08:13:30 -04:00
|
|
|
set(COVERAGE_EXCLUDES
|
|
|
|
"'^(.+/)?(thirdparty|zxcvbn)/.*'"
|
|
|
|
"'^(.+/)?main\\.cpp$$'"
|
|
|
|
"'^(.+/)?cli/keepassxc-cli\\.cpp$$'"
|
|
|
|
"'^(.+/)?proxy/keepassxc-proxy\\.cpp$$'")
|
2021-09-26 06:35:42 -04:00
|
|
|
if(WITH_COVERAGE AND CMAKE_COMPILER_IS_CLANGXX)
|
|
|
|
set(MAIN_BINARIES
|
|
|
|
"$<TARGET_FILE:${PROGNAME}>"
|
|
|
|
"$<TARGET_FILE:keepassxc-cli>"
|
|
|
|
"$<TARGET_FILE:keepassxc-proxy>")
|
|
|
|
setup_target_for_coverage_llvm(
|
|
|
|
NAME coverage
|
|
|
|
BINARY ${MAIN_BINARIES}
|
2021-09-27 08:13:30 -04:00
|
|
|
SOURCES_ROOT ${CMAKE_SOURCE_DIR}/src
|
2021-09-26 06:35:42 -04:00
|
|
|
)
|
|
|
|
else()
|
|
|
|
setup_target_for_coverage_gcovr(
|
|
|
|
NAME coverage
|
2021-09-27 08:13:30 -04:00
|
|
|
SOURCES_ROOT ${CMAKE_SOURCE_DIR}/src
|
2021-09-26 06:35:42 -04:00
|
|
|
)
|
|
|
|
endif()
|
2018-09-29 08:55:33 -04:00
|
|
|
endif()
|
|
|
|
|
2018-01-14 10:11:00 -05:00
|
|
|
include(CLangFormat)
|
|
|
|
|
2018-10-19 15:41:56 -04:00
|
|
|
set(QT_COMPONENTS Core Network Concurrent Gui Svg Widgets Test LinguistTools)
|
2017-10-15 18:27:07 -04:00
|
|
|
if(UNIX AND NOT APPLE)
|
2020-12-13 23:23:25 -05:00
|
|
|
find_package(Qt5 COMPONENTS ${QT_COMPONENTS} DBus X11Extras REQUIRED)
|
2017-10-15 18:27:07 -04:00
|
|
|
elseif(APPLE)
|
2021-02-01 11:54:28 -05:00
|
|
|
find_package(Qt5 COMPONENTS ${QT_COMPONENTS} REQUIRED HINTS
|
|
|
|
/usr/local/opt/qt/lib/cmake
|
|
|
|
/usr/local/Cellar/qt/*/lib/cmake
|
|
|
|
/opt/homebrew/opt/qt/lib/cmake
|
|
|
|
ENV PATH)
|
|
|
|
find_package(Qt5 COMPONENTS MacExtras HINTS
|
|
|
|
/usr/local/opt/qt/lib/cmake
|
|
|
|
/usr/local/Cellar/qt/*/lib/cmake
|
|
|
|
/opt/homebrew/opt/qt/lib/cmake
|
|
|
|
ENV PATH)
|
2017-10-15 18:27:07 -04:00
|
|
|
else()
|
2018-10-19 15:41:56 -04:00
|
|
|
find_package(Qt5 COMPONENTS ${QT_COMPONENTS} REQUIRED)
|
2017-10-15 18:27:07 -04:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(Qt5Core_VERSION VERSION_LESS "5.2.0")
|
2018-10-19 15:41:56 -04:00
|
|
|
message(FATAL_ERROR "Qt version 5.2.0 or higher is required")
|
2017-02-09 09:28:52 -05:00
|
|
|
endif()
|
2017-10-15 18:27:07 -04:00
|
|
|
|
2018-02-21 17:01:02 -05:00
|
|
|
get_filename_component(Qt5_PREFIX ${Qt5_DIR}/../../.. REALPATH)
|
|
|
|
|
2018-09-12 06:13:14 -04:00
|
|
|
# Process moc automatically
|
2015-07-22 10:59:38 -04:00
|
|
|
set(CMAKE_AUTOMOC ON)
|
2018-09-12 06:13:14 -04:00
|
|
|
# Process .ui files automatically
|
2017-10-15 18:27:07 -04:00
|
|
|
set(CMAKE_AUTOUIC ON)
|
2018-09-12 06:13:14 -04:00
|
|
|
# Process .qrc files automatically
|
2017-10-15 18:27:07 -04:00
|
|
|
set(CMAKE_AUTORCC ON)
|
|
|
|
|
|
|
|
if(APPLE)
|
2018-10-19 15:41:56 -04:00
|
|
|
set(CMAKE_MACOSX_RPATH TRUE)
|
2021-11-13 11:01:03 -05:00
|
|
|
find_program(MACDEPLOYQT_EXE macdeployqt HINTS ${Qt5_PREFIX}/bin ${Qt5_PREFIX}/tools/qt5/bin ENV PATH)
|
2018-10-19 15:41:56 -04:00
|
|
|
if(NOT MACDEPLOYQT_EXE)
|
2019-04-20 12:12:00 -04:00
|
|
|
message(FATAL_ERROR "macdeployqt is required to build on macOS")
|
2018-10-19 15:41:56 -04:00
|
|
|
endif()
|
2020-09-27 03:16:30 -04:00
|
|
|
message(STATUS "Using macdeployqt: ${MACDEPLOYQT_EXE}")
|
2022-03-08 06:30:17 -05:00
|
|
|
set(MACDEPLOYQT_EXTRA_BINARIES "")
|
2021-09-06 22:26:00 -04:00
|
|
|
elseif(WIN32)
|
2021-11-13 11:01:03 -05:00
|
|
|
find_program(WINDEPLOYQT_EXE windeployqt HINTS ${Qt5_PREFIX}/bin ${Qt5_PREFIX}/tools/qt5/bin ENV PATH)
|
2019-04-20 12:12:00 -04:00
|
|
|
if(NOT WINDEPLOYQT_EXE)
|
|
|
|
message(FATAL_ERROR "windeployqt is required to build on Windows")
|
|
|
|
endif()
|
2020-09-27 03:16:30 -04:00
|
|
|
message(STATUS "Using windeployqt: ${WINDEPLOYQT_EXE}")
|
2017-10-15 18:27:07 -04:00
|
|
|
endif()
|
2012-05-26 10:20:32 -04:00
|
|
|
|
2021-03-13 14:07:49 -05:00
|
|
|
# Debian sets the build type to None for package builds.
|
2014-11-04 12:50:07 -05:00
|
|
|
# Make sure we don't enable asserts there.
|
|
|
|
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_NONE QT_NO_DEBUG)
|
2010-08-07 09:10:44 -04:00
|
|
|
|
2021-04-04 08:56:00 -04:00
|
|
|
# Find Botan2
|
|
|
|
find_package(Botan2 REQUIRED)
|
|
|
|
if(BOTAN2_VERSION VERSION_LESS "2.11.0")
|
|
|
|
message(FATAL_ERROR "Botan2 2.11.0 or higher is required")
|
|
|
|
endif()
|
|
|
|
include_directories(SYSTEM ${BOTAN2_INCLUDE_DIR})
|
2022-03-05 10:45:57 -05:00
|
|
|
# Find Argon2 -- Botan 2.18 and below does not support threaded Argon2
|
|
|
|
find_library(ARGON2_LIBRARIES NAMES argon2)
|
|
|
|
find_path(ARGON2_INCLUDE_DIR NAMES argon2.h PATH_SUFFIXES local/include)
|
|
|
|
include_directories(SYSTEM ${ARGON2_INCLUDE_DIR})
|
2017-08-13 06:07:05 -04:00
|
|
|
|
2021-04-04 08:56:00 -04:00
|
|
|
# Find zlib
|
|
|
|
find_package(ZLIB REQUIRED)
|
2017-10-15 08:02:34 -04:00
|
|
|
if(ZLIB_VERSION_STRING VERSION_LESS "1.2.0")
|
2018-10-19 15:41:56 -04:00
|
|
|
message(FATAL_ERROR "zlib 1.2.0 or higher is required to use the gzip format")
|
2012-05-21 17:37:29 -04:00
|
|
|
endif()
|
2021-04-04 08:56:00 -04:00
|
|
|
include_directories(SYSTEM ${ZLIB_INCLUDE_DIR})
|
2010-09-24 07:32:05 -04:00
|
|
|
|
Implement support for Yubikeys and potential other tokens via wireless NFC using smartcard readers (Rebase) (#6895)
* Support NFC readers for hardware tokens using PC/SC
This requires a new library dependency: PCSC.
The PCSC library provides methods to access smartcards. On Linux, the third-party pcsc-lite package is used. On Windows, the native Windows API (Winscard.dll) is used. On Mac OSX, the native OSX API (framework-PCSC) is used.
* Split hardware key access into multiple classes to handle different methods of communicating with the keys.
* Since the Yubikey can now be a wireless token as well, the verb "plug in" was replaced with a more
generic "interface with". This shall indicate that the user has to present their token to the reader, or plug it in via USB.
* Add PC/SC interface for YubiKey challenge-response
This new interface uses the PC/SC protocol and API
instead of the USB protocol via ykpers. Many YubiKeys expose their functionality as a CCID device, which can be interfaced with using PC/SC. This is especially useful for NFC-only or NFC-capable Yubikeys, when they are used together with a PC/SC compliant NFC reader device.
Although many (not all) Yubikeys expose their CCID functionality over their own USB connection as well, the HMAC-SHA1 functionality is often locked in this mode, as it requires eg. a touch on the gold button. When accessing the CCID functionality wirelessly via NFC (like this code can do using a reader), then the user interaction is to present the key to the reader.
This implementation has been tested on Linux using pcsc-lite, Windows using the native Winscard.dll library, and Mac OSX using the native PCSC-framework library.
* Remove PC/SC ATR whitelist, instead scan for AIDs
Before, a whitelist of ATR codes (answer to reset, hardware-specific)
was used to scan for compatible (Yubi)Keys.
Now, every connected smartcard is scanned for AIDs (applet identifier),
which are known to implement the HMAC-SHA1 protocol.
This enables the support of currently unknown or unreleased hardware.
Co-authored-by: Jonathan White <support@dmapps.us>
2021-10-01 10:39:07 -04:00
|
|
|
if(WITH_XC_YUBIKEY)
|
|
|
|
find_package(PCSC REQUIRED)
|
|
|
|
include_directories(SYSTEM ${PCSC_INCLUDE_DIRS})
|
|
|
|
endif()
|
|
|
|
|
2012-10-13 05:05:50 -04:00
|
|
|
if(UNIX)
|
2018-10-19 15:41:56 -04:00
|
|
|
check_cxx_source_compiles("#include <sys/prctl.h>
|
2012-10-13 05:05:50 -04:00
|
|
|
int main() { prctl(PR_SET_DUMPABLE, 0); return 0; }"
|
2018-10-19 15:41:56 -04:00
|
|
|
HAVE_PR_SET_DUMPABLE)
|
2012-10-13 05:05:50 -04:00
|
|
|
|
2019-10-26 16:50:49 -04:00
|
|
|
check_cxx_source_compiles("#include <malloc.h>
|
|
|
|
int main() { return 0; }"
|
|
|
|
HAVE_MALLOC_H)
|
|
|
|
|
|
|
|
check_cxx_source_compiles("#include <malloc.h>
|
2022-03-21 21:07:37 -04:00
|
|
|
int main() { malloc_usable_size(NULL); return 0; }"
|
2019-10-26 16:50:49 -04:00
|
|
|
HAVE_MALLOC_USABLE_SIZE)
|
|
|
|
|
2018-10-19 15:41:56 -04:00
|
|
|
check_cxx_source_compiles("#include <sys/resource.h>
|
2012-10-13 05:05:50 -04:00
|
|
|
int main() {
|
|
|
|
struct rlimit limit;
|
|
|
|
limit.rlim_cur = 0;
|
|
|
|
limit.rlim_max = 0;
|
|
|
|
setrlimit(RLIMIT_CORE, &limit);
|
|
|
|
return 0;
|
|
|
|
}" HAVE_RLIMIT_CORE)
|
|
|
|
|
2018-10-19 15:41:56 -04:00
|
|
|
if(APPLE)
|
|
|
|
check_cxx_source_compiles("#include <sys/types.h>
|
2012-10-23 11:06:50 -04:00
|
|
|
#include <sys/ptrace.h>
|
2012-10-13 05:05:50 -04:00
|
|
|
int main() { ptrace(PT_DENY_ATTACH, 0, 0, 0); return 0; }"
|
2018-10-19 15:41:56 -04:00
|
|
|
HAVE_PT_DENY_ATTACH)
|
|
|
|
endif()
|
2012-10-13 05:05:50 -04:00
|
|
|
endif()
|
|
|
|
|
2021-04-04 08:56:00 -04:00
|
|
|
include_directories(SYSTEM ${ZLIB_INCLUDE_DIR})
|
2011-11-12 08:30:16 -05:00
|
|
|
|
2010-08-07 09:10:44 -04:00
|
|
|
add_subdirectory(src)
|
2011-12-29 17:50:22 -05:00
|
|
|
add_subdirectory(share)
|
2012-05-21 17:37:29 -04:00
|
|
|
if(WITH_TESTS)
|
2018-10-19 15:41:56 -04:00
|
|
|
add_subdirectory(tests)
|
2012-05-21 17:37:29 -04:00
|
|
|
endif(WITH_TESTS)
|
2013-06-30 08:07:25 -04:00
|
|
|
|
2020-07-03 13:41:33 -04:00
|
|
|
if(WITH_XC_DOCS)
|
|
|
|
add_subdirectory(docs)
|
|
|
|
endif()
|
|
|
|
|
2013-06-30 08:07:25 -04:00
|
|
|
if(PRINT_SUMMARY)
|
2018-10-19 15:41:56 -04:00
|
|
|
# This will print ENABLED, REQUIRED and DISABLED
|
|
|
|
feature_summary(WHAT ALL)
|
2016-12-04 13:57:24 -05:00
|
|
|
else()
|
2018-10-19 15:41:56 -04:00
|
|
|
# This will only print ENABLED and DISABLED feature
|
|
|
|
feature_summary(WHAT ENABLED_FEATURES DESCRIPTION "Enabled features:")
|
|
|
|
feature_summary(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:")
|
2013-06-30 08:07:25 -04:00
|
|
|
endif()
|