Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsmlu <smlu@s5.net>2021-09-07 05:26:00 +0300
committerJonathan White <support@dmapps.us>2021-09-20 00:16:45 +0300
commit0c6587b5b7325556aa41eadc2322908e95f14003 (patch)
tree51f15098c3d4b138cff989d469cd28d6fc4fae5a
parent24a23ce66eb07d7ee46dade36b23b295c13b6c1f (diff)
Add support for Microsoft Visual Studio buildchain
* Use C++17 when using MSVC compiler * Remove unneeded header files and macros * Removed unnecessary Yubikey cmake file * Enhance release tool * Updated INSTALL.md
-rw-r--r--CMakeLists.txt46
-rw-r--r--INSTALL.md24
-rw-r--r--cmake/FindBotan2.cmake2
-rw-r--r--cmake/FindQREncode.cmake11
-rw-r--r--cmake/FindQuaZip.cmake2
-rw-r--r--cmake/FindYubiKey.cmake27
-rw-r--r--docs/CMakeLists.txt43
-rwxr-xr-xrelease-tool35
-rw-r--r--share/translations/CMakeLists.txt2
-rw-r--r--src/CMakeLists.txt80
-rw-r--r--src/autotype/windows/AutoTypeWindows.h4
-rw-r--r--src/browser/BrowserHost.cpp4
-rw-r--r--src/cli/CMakeLists.txt10
-rw-r--r--src/cli/TextStream.cpp2
-rw-r--r--src/gui/osutils/winutils/WinUtils.h7
-rwxr-xr-xsrc/proxy/CMakeLists.txt2
-rw-r--r--src/proxy/NativeMessagingProxy.cpp8
-rw-r--r--src/qrcode/CMakeLists.txt4
-rw-r--r--src/zxcvbn/zxcvbn.c6
19 files changed, 174 insertions, 145 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 176b7682b..5c9c57a72 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -324,29 +324,46 @@ else()
add_gcc_compiler_cxxflags("-Wno-deprecated-declarations")
endif()
-if(MINGW)
+if (MSVC)
+ if(MSVC_VERSION LESS 1910)
+ message(FATAL_ERROR "Only Microsoft Visual Studio 17 and newer are supported!")
+ endif()
+ set(CMAKE_CXX_STANDARD 17)
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
+ add_compile_options(/permissive- /utf-8)
+endif()
+
+if(WIN32)
set(CMAKE_RC_COMPILER_INIT windres)
enable_language(RC)
- set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
+ if(MINGW)
+ set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
+ endif()
if(NOT (CMAKE_BUILD_TYPE_LOWER STREQUAL "debug" OR CMAKE_BUILD_TYPE_LOWER STREQUAL "relwithdebinfo"))
- # Enable DEP and ASLR
- 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")
+ # Enable DEP, ASLR and on VS additional enable
+ # control flow guard and buffer security check
+ if(MSVC)
+ add_compile_options(/DYNAMICBASE:YES /guard:cf /GS)
+ add_link_options(/NXCOMPAT /guard:cf)
+ 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()
endif()
endif()
endif()
-if(APPLE AND WITH_APP_BUNDLE OR MINGW)
+if(APPLE AND WITH_APP_BUNDLE OR WIN32)
set(PROGNAME KeePassXC)
else()
set(PROGNAME keepassxc)
endif()
-if(MINGW)
+if(WIN32)
set(CLI_INSTALL_DIR ".")
set(PROXY_INSTALL_DIR ".")
set(BIN_INSTALL_DIR ".")
@@ -429,8 +446,8 @@ if(APPLE)
message(FATAL_ERROR "macdeployqt is required to build on macOS")
endif()
message(STATUS "Using macdeployqt: ${MACDEPLOYQT_EXE}")
-elseif(MINGW)
- find_program(WINDEPLOYQT_EXE windeployqt HINTS ${Qt5_PREFIX}/bin ENV PATH)
+elseif(WIN32)
+ find_program(WINDEPLOYQT_EXE windeployqt HINTS ${Qt5_PREFIX}/bin ${Qt5_PREFIX}/tools/qt5/debug/bin ENV PATH)
if(NOT WINDEPLOYQT_EXE)
message(FATAL_ERROR "windeployqt is required to build on Windows")
endif()
@@ -455,9 +472,6 @@ if(ZLIB_VERSION_STRING VERSION_LESS "1.2.0")
endif()
include_directories(SYSTEM ${ZLIB_INCLUDE_DIR})
-# QREncode required for TOTP
-find_package(QREncode REQUIRED)
-
if(UNIX)
check_cxx_source_compiles("#include <sys/prctl.h>
int main() { prctl(PR_SET_DUMPABLE, 0); return 0; }"
diff --git a/INSTALL.md b/INSTALL.md
index 44d63c2af..b6f0ac6d0 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -12,21 +12,19 @@ Build Dependencies
The following tools must exist within your PATH:
* make
-* cmake (>= 2.8.12)
-* g++ (>= 4.7) or clang++ (>= 3.0)
-* asciidoctor (on Linux/MacOS)
+* cmake (>= 3.3.0)
+* g++ (>= 4.7) or clang++ (>= 6.0)
+* asciidoctor
The following libraries are required:
-* Qt 5 (>= 5.2): qtbase and qttools5
-* libgcrypt (>= 1.6)
+* Qt 5 (>= 5.9.5): qtbase5, qtbase5-private, libqt5svg5, qttools5, qt5-image-formats-plugins
+* botan (>= 2.12)
* zlib
-* libmicrohttpd
-* libxi, libxtst, qtx11extras (optional for auto-type on X11)
-* libsodium (>= 1.0.12)
-* libargon2
+* minizip
+* readline (for completion in cli)
+* libqt5x11extras5, libxi, and libxtst (for auto-type on X11)
* qrencode
-* yubikey ykpers (optional to support YubiKey)
Prepare the Building Environment
================================
@@ -40,7 +38,7 @@ Build Steps
We recommend using the release tool to perform builds, please read up-to-date instructions [on our wiki](https://github.com/keepassxreboot/keepassxc/wiki/Building-KeePassXC#building-using-the-release-tool).
To compile from source, open a **Terminal (on Linux/MacOS)** or a **MSYS2-MinGW shell (on Windows)**<br/>
-**Note:** on Windows make sure you are using a **MINGW shell** by checking the label before the current path
+**Note:** on Windows you can also use MSVC to build natively, we recommend Visual Studio 2019
First, download the KeePassXC [source tarball](https://keepassxc.org/download#source)
or check out the latest version from our [Git repository](https://github.com/keepassxreboot/keepassxc).
@@ -65,6 +63,8 @@ For a stable build, it is recommended to checkout the master branch.
git checkout master
```
+NOTE: See the [Windows Build Instructions](https://github.com/keepassxreboot/keepassxc/wiki/Building-KeePassXC#windows) for building with MSVC.
+
Navigate to the directory where you have downloaded KeePassXC and type these commands:
```
@@ -74,7 +74,7 @@ cmake -DWITH_XC_ALL=ON ..
make
```
-If you are on Windows, you may have to add ```-G "MSYS Makefiles"``` to the beginning of the cmake command. See the [Windows Build Instructions](https://github.com/keepassxreboot/keepassxc/wiki/Building-KeePassXC#windows) for more information.
+NOTE: If you are using MSYS2, you may have to add ```-G "MSYS Makefiles"``` to the beginning of the cmake command.
These steps place the compiled KeePassXC binary inside the `./build/src/` directory.
(Note the cmake notes/options below.)
diff --git a/cmake/FindBotan2.cmake b/cmake/FindBotan2.cmake
index a7564f542..49a534564 100644
--- a/cmake/FindBotan2.cmake
+++ b/cmake/FindBotan2.cmake
@@ -64,7 +64,7 @@ find_path(BOTAN2_INCLUDE_DIR
# find the library
find_library(BOTAN2_LIBRARY
- NAMES botan-2 libbotan-2
+ NAMES botan-2 libbotan-2 botan
HINTS
${PC_BOTAN2_LIBDIR}
${PC_BOTAN2_LIBRARY_DIRS}
diff --git a/cmake/FindQREncode.cmake b/cmake/FindQREncode.cmake
index 6328d9699..69850edf5 100644
--- a/cmake/FindQREncode.cmake
+++ b/cmake/FindQREncode.cmake
@@ -13,8 +13,15 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-find_path(QRENCODE_INCLUDE_DIR qrencode.h)
-find_library(QRENCODE_LIBRARY qrencode)
+find_path(QRENCODE_INCLUDE_DIR NAMES qrencode.h)
+
+if (VCPKG_INSTALLED_DIR)
+ find_library(QRENCODE_LIBRARY_RELEASE qrencode)
+ find_library(QRENCODE_LIBRARY_DEBUG qrencoded)
+ set(QRENCODE_LIBRARY optimized ${QRENCODE_LIBRARY_RELEASE} debug ${QRENCODE_LIBRARY_DEBUG})
+else()
+ find_library(QRENCODE_LIBRARY qrencode)
+endif()
mark_as_advanced(QRENCODE_LIBRARY QRENCODE_INCLUDE_DIR)
diff --git a/cmake/FindQuaZip.cmake b/cmake/FindQuaZip.cmake
index a387e2f81..2242baca4 100644
--- a/cmake/FindQuaZip.cmake
+++ b/cmake/FindQuaZip.cmake
@@ -4,7 +4,7 @@
# QUAZIP_LIBRARIES - List of QuaZip libraries
# QUAZIP_ZLIB_INCLUDE_DIR - The include dir of zlib headers
-if(MINGW)
+if(WIN32)
find_library(QUAZIP_LIBRARIES libquazip5)
find_path(QUAZIP_INCLUDE_DIR quazip.h PATH_SUFFIXES quazip5)
find_path(QUAZIP_ZLIB_INCLUDE_DIR zlib.h)
diff --git a/cmake/FindYubiKey.cmake b/cmake/FindYubiKey.cmake
deleted file mode 100644
index d2266b407..000000000
--- a/cmake/FindYubiKey.cmake
+++ /dev/null
@@ -1,27 +0,0 @@
-# Copyright (C) 2014 Kyle Manna <kyle@kylemanna.com>
-#
-# 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/>.
-
-find_path(YUBIKEY_CORE_INCLUDE_DIR yubikey.h)
-find_path(YUBIKEY_PERS_INCLUDE_DIR ykcore.h PATH_SUFFIXES ykpers-1)
-set(YUBIKEY_INCLUDE_DIRS ${YUBIKEY_CORE_INCLUDE_DIR} ${YUBIKEY_PERS_INCLUDE_DIR})
-
-find_library(YUBIKEY_CORE_LIBRARY NAMES yubikey.dll libyubikey.so yubikey)
-find_library(YUBIKEY_PERS_LIBRARY NAMES ykpers-1.dll libykpers-1.so ykpers-1)
-set(YUBIKEY_LIBRARIES ${YUBIKEY_CORE_LIBRARY} ${YUBIKEY_PERS_LIBRARY})
-
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(YubiKey DEFAULT_MSG YUBIKEY_LIBRARIES YUBIKEY_INCLUDE_DIRS)
-
-mark_as_advanced(YUBIKEY_LIBRARIES YUBIKEY_INCLUDE_DIRS)
diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt
index 7ba9f15ec..8dbb81803 100644
--- a/docs/CMakeLists.txt
+++ b/docs/CMakeLists.txt
@@ -24,39 +24,32 @@ set(OUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(REV -a revnumber=${KEEPASSXC_VERSION})
# Build html documentation on all platforms
-file(GLOB html_depends ${DOC_DIR}/topics/* ${DOC_DIR}/styles/* ${DOC_DIR}/images/*)
-add_custom_command(OUTPUT KeePassXC_GettingStarted.html
- COMMAND ${ASCIIDOCTOR_EXE} -D ${OUT_DIR} -o KeePassXC_GettingStarted.html ${REV} ${DOC_DIR}/GettingStarted.adoc
- DEPENDS ${html_depends} ${DOC_DIR}/GettingStarted.adoc
- VERBATIM)
-add_custom_command(OUTPUT KeePassXC_UserGuide.html
- COMMAND ${ASCIIDOCTOR_EXE} -D ${OUT_DIR} -o KeePassXC_UserGuide.html ${REV} ${DOC_DIR}/UserGuide.adoc
- DEPENDS ${html_depends} ${DOC_DIR}/UserGuide.adoc
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- VERBATIM)
-file(GLOB styles_depends ${DOC_DIR}/styles/*)
-add_custom_command(OUTPUT KeePassXC_KeyboardShortcuts.html
- COMMAND ${ASCIIDOCTOR_EXE} -D ${OUT_DIR} -o KeePassXC_KeyboardShortcuts.html ${REV} ${DOC_DIR}/topics/KeyboardShortcuts.adoc
- DEPENDS ${DOC_DIR}/topics/KeyboardShortcuts.adoc ${styles_depends}
+# NOTE: Combine into one long command to prevent MSVC from failing to build all docs
+file(GLOB doc_depends ${DOC_DIR}/*.adoc ${DOC_DIR}/topics/* ${DOC_DIR}/styles/* ${DOC_DIR}/images/*)
+add_custom_command(
+ OUTPUT KeePassXC_GettingStarted.html KeePassXC_UserGuide.html KeePassXC_KeyboardShortcuts.html
+ COMMAND
+ ${ASCIIDOCTOR_EXE} -D ${OUT_DIR} -o KeePassXC_GettingStarted.html ${REV} ${DOC_DIR}/GettingStarted.adoc &&
+ ${ASCIIDOCTOR_EXE} -D ${OUT_DIR} -o KeePassXC_UserGuide.html ${REV} ${DOC_DIR}/UserGuide.adoc &&
+ ${ASCIIDOCTOR_EXE} -D ${OUT_DIR} -o KeePassXC_KeyboardShortcuts.html ${REV} ${DOC_DIR}/topics/KeyboardShortcuts.adoc
+ DEPENDS ${doc_depends}
VERBATIM)
add_custom_target(docs ALL DEPENDS KeePassXC_GettingStarted.html KeePassXC_UserGuide.html KeePassXC_KeyboardShortcuts.html)
install(FILES
- ${OUT_DIR}/KeePassXC_GettingStarted.html
- ${OUT_DIR}/KeePassXC_UserGuide.html
- ${OUT_DIR}/KeePassXC_KeyboardShortcuts.html
- DESTINATION ${DATA_INSTALL_DIR}/docs)
+ ${OUT_DIR}/KeePassXC_GettingStarted.html
+ ${OUT_DIR}/KeePassXC_UserGuide.html
+ ${OUT_DIR}/KeePassXC_KeyboardShortcuts.html
+ DESTINATION ${DATA_INSTALL_DIR}/docs)
# Build Man Pages on Linux and macOS
if(UNIX)
- add_custom_command(OUTPUT keepassxc.1
- COMMAND ${ASCIIDOCTOR_EXE} -D ${OUT_DIR} -b manpage ${REV} ${DOC_DIR}/man/keepassxc.1.adoc
- DEPENDS ${DOC_DIR}/man/keepassxc.1.adoc
- VERBATIM)
- add_custom_command(OUTPUT keepassxc-cli.1
- COMMAND ${ASCIIDOCTOR_EXE} -D ${OUT_DIR} -b manpage ${REV} ${DOC_DIR}/man/keepassxc-cli.1.adoc
- DEPENDS ${DOC_DIR}/man/keepassxc-cli.1.adoc
+ add_custom_command(OUTPUT keepassxc.1 keepassxc-cli.1
+ COMMAND ${ASCIIDOCTOR_EXE} -D ${OUT_DIR} -b manpage ${REV} ./man/keepassxc.1.adoc
+ COMMAND ${ASCIIDOCTOR_EXE} -D ${OUT_DIR} -b manpage ${REV} ./man/keepassxc-cli.1.adoc
+ DEPENDS ${DOC_DIR}/man/keepassxc.1.adoc ${DOC_DIR}/man/keepassxc-cli.1.adoc
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
VERBATIM)
add_custom_target(manpages ALL DEPENDS keepassxc.1 keepassxc-cli.1)
diff --git a/release-tool b/release-tool
index 6ad6c4df6..55fb5ef2c 100755
--- a/release-tool
+++ b/release-tool
@@ -34,6 +34,7 @@ TARGET_BRANCH="master"
TAG_NAME=""
DOCKER_IMAGE=""
DOCKER_CONTAINER_NAME="keepassxc-build-container"
+CMAKE_GENERATOR="Ninja"
CMAKE_OPTIONS=""
CPACK_GENERATORS="WIX;ZIP"
COMPILER="g++"
@@ -116,7 +117,9 @@ Options:
If this option is set, --install-prefix has no effect
--appsign Perform platform specific App Signing before packaging
--timestamp Explicitly set the timestamp server to use for appsign (default: '${TIMESTAMP_SERVER}')
+ --vcpkg Specify VCPKG toolchain file (example: ~/vcpkg/scripts/buildsystems/vcpkg.cmake)
-k, --key Specify the App Signing Key/Identity
+ --cmake-generator Override the default CMake generator (Default: Ninja)
-c, --cmake-options Additional CMake options for compiling the sources
--compiler Compiler to use (default: '${COMPILER}')
-m, --make-options Make options for compiling sources (default: '${MAKE_OPTIONS}')
@@ -783,6 +786,7 @@ build() {
local build_generators=""
local build_appsign=false
local build_key=""
+ local build_vcpkg=""
while [ $# -ge 1 ]; do
local arg="$1"
@@ -832,6 +836,10 @@ build() {
--appimage)
build_appimage=true ;;
+ --cmake-generator)
+ CMAKE_GENERATOR="$2"
+ shift ;;
+
-c|--cmake-options)
CMAKE_OPTIONS="$2"
shift ;;
@@ -840,6 +848,10 @@ build() {
COMPILER="$2"
shift ;;
+ --vcpkg)
+ build_vcpkg="$2"
+ shift ;;
+
-m|--make-options)
MAKE_OPTIONS="$2"
shift ;;
@@ -882,6 +894,10 @@ build() {
build_key="$(realpath "${build_key}")"
fi
+ if [[ -f ${build_vcpkg} ]]; then
+ CMAKE_OPTIONS="${CMAKE_OPTIONS} -DCMAKE_TOOLCHAIN_FILE=${build_vcpkg} -DX_VCPKG_APPLOCAL_DEPS_INSTALL=ON"
+ fi
+
if ${build_snapshot}; then
TAG_NAME="HEAD"
local branch=`git rev-parse --abbrev-ref HEAD`
@@ -961,6 +977,8 @@ build() {
export CC=gcc
elif [ "$COMPILER" == "clang++" ]; then
export CC=clang
+ else
+ export CC="$COMPILER"
fi
export CXX="$COMPILER"
@@ -970,13 +988,12 @@ build() {
export MACOSX_DEPLOYMENT_TARGET
logInfo "Configuring build..."
- cmake -DCMAKE_BUILD_TYPE=Release \
- -DCMAKE_OSX_ARCHITECTURES="$(uname -m)" -DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}" \
- -DCMAKE_PREFIX_PATH="/opt/homebrew/opt/qt/lib/cmake;/usr/local/opt/qt/lib/cmake" \
- ${CMAKE_OPTIONS} "$SRC_DIR"
+ cmake -G "${CMAKE_GENERATOR}" -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="$(uname -m)" \
+ -DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}" ${CMAKE_OPTIONS} "$SRC_DIR"
logInfo "Compiling and packaging sources..."
- make ${MAKE_OPTIONS} package
+ cmake --build . -- ${MAKE_OPTIONS}
+ cpack -G "DragNDrop"
# Appsign the executables if desired
if ${build_appsign}; then
@@ -988,16 +1005,16 @@ build() {
elif [ "$(uname -o)" == "Msys" ]; then
# Building on Windows with Msys2
logInfo "Configuring build..."
- cmake -DCMAKE_BUILD_TYPE=Release -G"MSYS Makefiles" \
- -DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}" ${CMAKE_OPTIONS} "$SRC_DIR"
+ cmake -DCMAKE_BUILD_TYPE=Release -G "${CMAKE_GENERATOR}" -DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}" \
+ ${CMAKE_OPTIONS} "$SRC_DIR"
logInfo "Compiling and packaging sources..."
- mingw32-make ${MAKE_OPTIONS} preinstall
+ cmake --build . --config "Release" -- ${MAKE_OPTIONS}
# Appsign the executables if desired
if ${build_appsign} && [ -f "${build_key}" ]; then
logInfo "Signing executable files"
- appsign "-f" $(find src | $GREP -P '\.exe$|\.dll$') "-k" "${build_key}"
+ appsign "-f" $(find src | $GREP -Pi 'keepassxc.*(.exe$|.dll$)') "-k" "${build_key}"
fi
# Call cpack directly instead of calling make package.
diff --git a/share/translations/CMakeLists.txt b/share/translations/CMakeLists.txt
index ffd4698b0..161b21ac1 100644
--- a/share/translations/CMakeLists.txt
+++ b/share/translations/CMakeLists.txt
@@ -22,7 +22,7 @@ message(STATUS "Including translations...\n")
qt5_add_translation(QM_FILES ${TRANSLATION_FILES})
-if(MINGW)
+if(WIN32)
file(GLOB QTBASE_TRANSLATIONS ${Qt5_PREFIX}/share/qt5/translations/qtbase_*.qm)
elseif(APPLE OR KEEPASSXC_DIST_APPIMAGE)
file(GLOB QTBASE_TRANSLATIONS
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f8f8bacc8..5f3940767 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -207,7 +207,7 @@ if(UNIX AND NOT APPLE)
gui/osutils/nixutils/NixUtils.cpp
gui/osutils/nixutils/X11Funcs.cpp)
endif()
-if(MINGW)
+if(WIN32)
set(keepassx_SOURCES
${keepassx_SOURCES}
gui/osutils/winutils/ScreenLockListenerWin.cpp
@@ -275,7 +275,7 @@ set(autotype_SOURCES
autotype/ShortcutWidget.cpp
autotype/WindowSelectComboBox.cpp)
-if(MINGW)
+if(WIN32)
set(keepassx_SOURCES_MAINEXE ${keepassx_SOURCES_MAINEXE} ${CMAKE_SOURCE_DIR}/share/windows/icon.rc)
endif()
@@ -348,11 +348,11 @@ if(UNIX AND NOT APPLE)
target_link_libraries(keepassx_core Qt5::DBus Qt5::X11Extras X11)
include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS})
endif()
-if(MINGW)
+if(WIN32)
target_link_libraries(keepassx_core Wtsapi32.lib Ws2_32.lib)
endif()
-if(MINGW)
+if(WIN32)
include(GenerateProductVersion)
generate_product_version(
WIN32_ProductVersionFiles
@@ -407,7 +407,7 @@ install(TARGETS ${PROGNAME}
BUNDLE DESTINATION . COMPONENT Runtime
RUNTIME DESTINATION ${BIN_INSTALL_DIR} COMPONENT Runtime)
-if(MINGW)
+if(WIN32)
if(${CMAKE_SIZEOF_VOID_P} EQUAL "8")
set(OUTPUT_FILE_POSTFIX "Win64")
else()
@@ -462,38 +462,54 @@ if(MINGW)
set(CPACK_WIX_EXTENSIONS "WixUtilExtension.dll")
include(CPack)
- install(CODE "set(gp_tool \"objdump\")" COMPONENT Runtime)
+ if(NOT VCPKG_INSTALLED_DIR)
+ install(CODE "set(gp_tool \"objdump\")" COMPONENT Runtime)
- # Deploy all 3rd party library dependencies first
- install(CODE "include(BundleUtilities)
- fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/${PROGNAME}.exe\" \"\" \"\")"
- COMPONENT Runtime)
+ # Deploy all 3rd party library dependencies first
+ install(CODE "include(BundleUtilities)
+ fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/${PROGNAME}.exe\" \"\" \"\")"
+ COMPONENT Runtime)
- # Use windeployqt.exe to setup Qt dependencies
- if(Qt5Core_VERSION VERSION_LESS "5.14.1")
- set(WINDEPLOYQT_MODE "--release")
- if(CMAKE_BUILD_TYPE_LOWER STREQUAL "debug")
- set(WINDEPLOYQT_MODE "--debug")
- endif()
- endif()
-
- install(CODE "execute_process(COMMAND ${WINDEPLOYQT_EXE} ${PROGNAME}.exe ${WINDEPLOYQT_MODE} WORKING_DIRECTORY \${CMAKE_INSTALL_PREFIX} OUTPUT_QUIET)"
- COMPONENT Runtime)
-
- # install CA cert chains
- install(FILES ${Qt5_PREFIX}/ssl/certs/ca-bundle.crt DESTINATION "ssl/certs")
- # install OpenSSL library
- if(WITH_XC_NETWORKING)
- find_file(OPENSSL_DLL NAMES libssl-1_1.dll libssl-1_1-x64.dll)
- if (NOT OPENSSL_DLL)
- message(FATAL_ERROR "Cannot find libssl dll, ensure openssl is properly installed.")
+ # Use windeployqt.exe to setup Qt dependencies
+ if(Qt5Core_VERSION VERSION_LESS "5.14.1")
+ set(WINDEPLOYQT_MODE "--release")
+ if(CMAKE_BUILD_TYPE_LOWER STREQUAL "debug")
+ set(WINDEPLOYQT_MODE "--debug")
+ endif()
endif()
- find_file(CRYPTO_DLL NAMES libcrypto-1_1.dll libcrypto-1_1-x64.dll)
- if (NOT CRYPTO_DLL)
- message(FATAL_ERROR "Cannot find libcrypto dll, ensure openssl is properly installed.")
+ install(CODE "execute_process(COMMAND ${WINDEPLOYQT_EXE} ${PROGNAME}.exe ${WINDEPLOYQT_MODE} WORKING_DIRECTORY \${CMAKE_INSTALL_PREFIX} OUTPUT_QUIET)"
+ COMPONENT Runtime)
+
+ # install OpenSSL library
+ if(WITH_XC_NETWORKING)
+ find_file(OPENSSL_DLL
+ NAMES libssl-1_1.dll libssl-1_1-x64.dll
+ HINTS "${OPENSSL_ROOT_DIR}/bin"
+ )
+ if (NOT OPENSSL_DLL)
+ message(FATAL_ERROR "Cannot find libssl dll, ensure openssl is properly installed.")
+ endif()
+
+ find_file(CRYPTO_DLL
+ NAMES libcrypto-1_1.dll libcrypto-1_1-x64.dll
+ HINTS "${OPENSSL_ROOT_DIR}/bin"
+ )
+ if (NOT CRYPTO_DLL)
+ message(FATAL_ERROR "Cannot find libcrypto dll, ensure openssl is properly installed.")
+ endif()
+
+ install(FILES ${OPENSSL_DLL} ${CRYPTO_DLL} DESTINATION ".")
endif()
+ endif()
- install(FILES ${OPENSSL_DLL} ${CRYPTO_DLL} DESTINATION ".")
+ # install CA cert chains
+ find_file(SSL_CA_BUNDLE ca-bundle.crt PATHS "${Qt5_PREFIX}/ssl/certs")
+ if(SSL_CA_BUNDLE)
+ install(FILES ${SSL_CA_BUNDLE} DESTINATION "ssl/certs")
+ else()
+ file(DOWNLOAD "https://curl.se/ca/cacert.pem" "${CMAKE_BINARY_DIR}/ca-bundle.crt" TLS_VERIFY ON)
+ install(FILES "${CMAKE_BINARY_DIR}/ca-bundle.crt" DESTINATION "ssl/certs")
endif()
+
endif()
diff --git a/src/autotype/windows/AutoTypeWindows.h b/src/autotype/windows/AutoTypeWindows.h
index 883677b57..7b3d577d0 100644
--- a/src/autotype/windows/AutoTypeWindows.h
+++ b/src/autotype/windows/AutoTypeWindows.h
@@ -20,6 +20,10 @@
#define KEEPASSX_AUTOTYPEWINDOWS_H
#include <QtPlugin>
+
+#undef NOMINMAX
+#define NOMINMAX
+#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "autotype/AutoTypeAction.h"
diff --git a/src/browser/BrowserHost.cpp b/src/browser/BrowserHost.cpp
index b58f0f5fb..6ddf7e061 100644
--- a/src/browser/BrowserHost.cpp
+++ b/src/browser/BrowserHost.cpp
@@ -24,8 +24,8 @@
#ifdef Q_OS_WIN
#include <fcntl.h>
-#include <winsock2.h>
-
+#undef NOMINMAX
+#define NOMINMAX
#include <windows.h>
#else
#include <sys/socket.h>
diff --git a/src/cli/CMakeLists.txt b/src/cli/CMakeLists.txt
index 4e6defd14..0b348d3c9 100644
--- a/src/cli/CMakeLists.txt
+++ b/src/cli/CMakeLists.txt
@@ -47,7 +47,7 @@ find_package(Readline)
if (READLINE_FOUND)
target_compile_definitions(cli PUBLIC USE_READLINE)
- target_link_libraries(cli readline)
+ target_link_libraries(cli ${Readline_LIBRARY})
endif()
add_executable(keepassxc-cli keepassxc-cli.cpp)
@@ -60,10 +60,10 @@ install(TARGETS keepassxc-cli
BUNDLE DESTINATION . COMPONENT Runtime
RUNTIME DESTINATION ${CLI_INSTALL_DIR} COMPONENT Runtime)
-if(MINGW)
- install(CODE "include(BundleUtilities)
- fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/keepassxc-cli.exe\" \"\" \"\")"
- COMPONENT Runtime)
+if(WIN32)
+# install(CODE "include(BundleUtilities)
+# fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/keepassxc-cli.exe\" \"\" \"\")"
+# COMPONENT Runtime)
endif()
if(APPLE AND WITH_APP_BUNDLE)
diff --git a/src/cli/TextStream.cpp b/src/cli/TextStream.cpp
index 5757f90e9..e2e6e15f4 100644
--- a/src/cli/TextStream.cpp
+++ b/src/cli/TextStream.cpp
@@ -73,7 +73,7 @@ void TextStream::detectCodec()
auto env = QProcessEnvironment::systemEnvironment();
#ifdef Q_OS_WIN
- WINBOOL success = false;
+ bool success = false;
#ifdef CP_UTF8
success = SetConsoleOutputCP(CP_UTF8);
#endif
diff --git a/src/gui/osutils/winutils/WinUtils.h b/src/gui/osutils/winutils/WinUtils.h
index a4522e08b..ca595dea2 100644
--- a/src/gui/osutils/winutils/WinUtils.h
+++ b/src/gui/osutils/winutils/WinUtils.h
@@ -25,7 +25,12 @@
#include <QScopedPointer>
#include <QSharedPointer>
-#include <windef.h>
+#undef NOMINMAX
+#define NOMINMAX
+#define WIN32_LEAN_AND_MEAN
+#define NOGDI
+#include <windows.h>
+#undef MessageBox
class WinUtils : public OSUtilsBase, QAbstractNativeEventFilter
{
diff --git a/src/proxy/CMakeLists.txt b/src/proxy/CMakeLists.txt
index d013b5307..589d7f7d8 100755
--- a/src/proxy/CMakeLists.txt
+++ b/src/proxy/CMakeLists.txt
@@ -39,7 +39,7 @@ if(WITH_XC_BROWSER)
COMMENT "Deploying keepassxc-proxy")
endif()
- if(MINGW)
+ if(WIN32)
target_link_libraries(keepassxc-proxy Wtsapi32.lib Ws2_32.lib)
endif()
endif()
diff --git a/src/proxy/NativeMessagingProxy.cpp b/src/proxy/NativeMessagingProxy.cpp
index 5cffc6c77..964383dc5 100644
--- a/src/proxy/NativeMessagingProxy.cpp
+++ b/src/proxy/NativeMessagingProxy.cpp
@@ -26,9 +26,8 @@
#ifdef Q_OS_WIN
#include <fcntl.h>
+#include <io.h>
#include <winsock2.h>
-
-#include <windows.h>
#else
#include <sys/socket.h>
#endif
@@ -49,9 +48,14 @@ NativeMessagingProxy::NativeMessagingProxy()
void NativeMessagingProxy::setupStandardInput()
{
#ifdef Q_OS_WIN
+#ifdef Q_CC_MSVC
+ _setmode(_fileno(stdin), _O_BINARY);
+ _setmode(_fileno(stdout), _O_BINARY);
+#else
setmode(fileno(stdin), _O_BINARY);
setmode(fileno(stdout), _O_BINARY);
#endif
+#endif
QtConcurrent::run([this] {
while (std::cin.good()) {
diff --git a/src/qrcode/CMakeLists.txt b/src/qrcode/CMakeLists.txt
index bce692d67..5d01d07b7 100644
--- a/src/qrcode/CMakeLists.txt
+++ b/src/qrcode/CMakeLists.txt
@@ -17,6 +17,8 @@ set(qrcode_SOURCES
QrCode.cpp
)
+find_package(QREncode REQUIRED)
+
add_library(qrcode STATIC ${qrcode_SOURCES})
-target_link_libraries(qrcode Qt5::Core Qt5::Widgets Qt5::Svg ${QRENCODE_LIBRARY})
target_include_directories(qrcode PRIVATE ${QRENCODE_INCLUDE_DIR})
+target_link_libraries(qrcode PUBLIC Qt5::Core Qt5::Widgets Qt5::Svg ${QRENCODE_LIBRARY})
diff --git a/src/zxcvbn/zxcvbn.c b/src/zxcvbn/zxcvbn.c
index 1d6a307c3..23792b4d6 100644
--- a/src/zxcvbn/zxcvbn.c
+++ b/src/zxcvbn/zxcvbn.c
@@ -44,12 +44,6 @@
#endif
#endif
-/* For pre-compiled headers under windows */
-#ifndef __MINGW32__
-#ifdef _WIN32
-#include "stdafx.h"
-#endif
-#endif
/* Minimum number of characters in a incrementing/decrementing sequence match */
#define MIN_SEQUENCE_LEN 3