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
This commit is contained in:
smlu 2021-09-06 22:26:00 -04:00 committed by Jonathan White
parent 24a23ce66e
commit 0c6587b5b7
19 changed files with 174 additions and 145 deletions

View File

@ -324,12 +324,28 @@ else()
add_gcc_compiler_cxxflags("-Wno-deprecated-declarations") add_gcc_compiler_cxxflags("-Wno-deprecated-declarations")
endif() 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) set(CMAKE_RC_COMPILER_INIT windres)
enable_language(RC) enable_language(RC)
if(MINGW)
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>") 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")) if(NOT (CMAKE_BUILD_TYPE_LOWER STREQUAL "debug" OR CMAKE_BUILD_TYPE_LOWER STREQUAL "relwithdebinfo"))
# Enable DEP and ASLR # 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_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--nxcompat -Wl,--dynamicbase")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_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 # Enable high entropy ASLR for 64-bit builds
@ -339,14 +355,15 @@ if(MINGW)
endif() endif()
endif() endif()
endif() endif()
endif()
if(APPLE AND WITH_APP_BUNDLE OR MINGW) if(APPLE AND WITH_APP_BUNDLE OR WIN32)
set(PROGNAME KeePassXC) set(PROGNAME KeePassXC)
else() else()
set(PROGNAME keepassxc) set(PROGNAME keepassxc)
endif() endif()
if(MINGW) if(WIN32)
set(CLI_INSTALL_DIR ".") set(CLI_INSTALL_DIR ".")
set(PROXY_INSTALL_DIR ".") set(PROXY_INSTALL_DIR ".")
set(BIN_INSTALL_DIR ".") set(BIN_INSTALL_DIR ".")
@ -429,8 +446,8 @@ if(APPLE)
message(FATAL_ERROR "macdeployqt is required to build on macOS") message(FATAL_ERROR "macdeployqt is required to build on macOS")
endif() endif()
message(STATUS "Using macdeployqt: ${MACDEPLOYQT_EXE}") message(STATUS "Using macdeployqt: ${MACDEPLOYQT_EXE}")
elseif(MINGW) elseif(WIN32)
find_program(WINDEPLOYQT_EXE windeployqt HINTS ${Qt5_PREFIX}/bin ENV PATH) find_program(WINDEPLOYQT_EXE windeployqt HINTS ${Qt5_PREFIX}/bin ${Qt5_PREFIX}/tools/qt5/debug/bin ENV PATH)
if(NOT WINDEPLOYQT_EXE) if(NOT WINDEPLOYQT_EXE)
message(FATAL_ERROR "windeployqt is required to build on Windows") message(FATAL_ERROR "windeployqt is required to build on Windows")
endif() endif()
@ -455,9 +472,6 @@ if(ZLIB_VERSION_STRING VERSION_LESS "1.2.0")
endif() endif()
include_directories(SYSTEM ${ZLIB_INCLUDE_DIR}) include_directories(SYSTEM ${ZLIB_INCLUDE_DIR})
# QREncode required for TOTP
find_package(QREncode REQUIRED)
if(UNIX) if(UNIX)
check_cxx_source_compiles("#include <sys/prctl.h> check_cxx_source_compiles("#include <sys/prctl.h>
int main() { prctl(PR_SET_DUMPABLE, 0); return 0; }" int main() { prctl(PR_SET_DUMPABLE, 0); return 0; }"

View File

@ -12,21 +12,19 @@ Build Dependencies
The following tools must exist within your PATH: The following tools must exist within your PATH:
* make * make
* cmake (>= 2.8.12) * cmake (>= 3.3.0)
* g++ (>= 4.7) or clang++ (>= 3.0) * g++ (>= 4.7) or clang++ (>= 6.0)
* asciidoctor (on Linux/MacOS) * asciidoctor
The following libraries are required: The following libraries are required:
* Qt 5 (>= 5.2): qtbase and qttools5 * Qt 5 (>= 5.9.5): qtbase5, qtbase5-private, libqt5svg5, qttools5, qt5-image-formats-plugins
* libgcrypt (>= 1.6) * botan (>= 2.12)
* zlib * zlib
* libmicrohttpd * minizip
* libxi, libxtst, qtx11extras (optional for auto-type on X11) * readline (for completion in cli)
* libsodium (>= 1.0.12) * libqt5x11extras5, libxi, and libxtst (for auto-type on X11)
* libargon2
* qrencode * qrencode
* yubikey ykpers (optional to support YubiKey)
Prepare the Building Environment 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). 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/> 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) 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). 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 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: Navigate to the directory where you have downloaded KeePassXC and type these commands:
``` ```
@ -74,7 +74,7 @@ cmake -DWITH_XC_ALL=ON ..
make 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. These steps place the compiled KeePassXC binary inside the `./build/src/` directory.
(Note the cmake notes/options below.) (Note the cmake notes/options below.)

View File

@ -64,7 +64,7 @@ find_path(BOTAN2_INCLUDE_DIR
# find the library # find the library
find_library(BOTAN2_LIBRARY find_library(BOTAN2_LIBRARY
NAMES botan-2 libbotan-2 NAMES botan-2 libbotan-2 botan
HINTS HINTS
${PC_BOTAN2_LIBDIR} ${PC_BOTAN2_LIBDIR}
${PC_BOTAN2_LIBRARY_DIRS} ${PC_BOTAN2_LIBRARY_DIRS}

View File

@ -13,8 +13,15 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
find_path(QRENCODE_INCLUDE_DIR qrencode.h) 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) find_library(QRENCODE_LIBRARY qrencode)
endif()
mark_as_advanced(QRENCODE_LIBRARY QRENCODE_INCLUDE_DIR) mark_as_advanced(QRENCODE_LIBRARY QRENCODE_INCLUDE_DIR)

View File

@ -4,7 +4,7 @@
# QUAZIP_LIBRARIES - List of QuaZip libraries # QUAZIP_LIBRARIES - List of QuaZip libraries
# QUAZIP_ZLIB_INCLUDE_DIR - The include dir of zlib headers # QUAZIP_ZLIB_INCLUDE_DIR - The include dir of zlib headers
if(MINGW) if(WIN32)
find_library(QUAZIP_LIBRARIES libquazip5) find_library(QUAZIP_LIBRARIES libquazip5)
find_path(QUAZIP_INCLUDE_DIR quazip.h PATH_SUFFIXES quazip5) find_path(QUAZIP_INCLUDE_DIR quazip.h PATH_SUFFIXES quazip5)
find_path(QUAZIP_ZLIB_INCLUDE_DIR zlib.h) find_path(QUAZIP_ZLIB_INCLUDE_DIR zlib.h)

View File

@ -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)

View File

@ -24,20 +24,15 @@ set(OUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(REV -a revnumber=${KEEPASSXC_VERSION}) set(REV -a revnumber=${KEEPASSXC_VERSION})
# Build html documentation on all platforms # Build html documentation on all platforms
file(GLOB html_depends ${DOC_DIR}/topics/* ${DOC_DIR}/styles/* ${DOC_DIR}/images/*) # NOTE: Combine into one long command to prevent MSVC from failing to build all docs
add_custom_command(OUTPUT KeePassXC_GettingStarted.html file(GLOB doc_depends ${DOC_DIR}/*.adoc ${DOC_DIR}/topics/* ${DOC_DIR}/styles/* ${DOC_DIR}/images/*)
COMMAND ${ASCIIDOCTOR_EXE} -D ${OUT_DIR} -o KeePassXC_GettingStarted.html ${REV} ${DOC_DIR}/GettingStarted.adoc add_custom_command(
DEPENDS ${html_depends} ${DOC_DIR}/GettingStarted.adoc OUTPUT KeePassXC_GettingStarted.html KeePassXC_UserGuide.html KeePassXC_KeyboardShortcuts.html
VERBATIM) COMMAND
add_custom_command(OUTPUT KeePassXC_UserGuide.html ${ASCIIDOCTOR_EXE} -D ${OUT_DIR} -o KeePassXC_GettingStarted.html ${REV} ${DOC_DIR}/GettingStarted.adoc &&
COMMAND ${ASCIIDOCTOR_EXE} -D ${OUT_DIR} -o KeePassXC_UserGuide.html ${REV} ${DOC_DIR}/UserGuide.adoc ${ASCIIDOCTOR_EXE} -D ${OUT_DIR} -o KeePassXC_UserGuide.html ${REV} ${DOC_DIR}/UserGuide.adoc &&
DEPENDS ${html_depends} ${DOC_DIR}/UserGuide.adoc ${ASCIIDOCTOR_EXE} -D ${OUT_DIR} -o KeePassXC_KeyboardShortcuts.html ${REV} ${DOC_DIR}/topics/KeyboardShortcuts.adoc
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS ${doc_depends}
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}
VERBATIM) VERBATIM)
add_custom_target(docs ALL DEPENDS KeePassXC_GettingStarted.html KeePassXC_UserGuide.html KeePassXC_KeyboardShortcuts.html) add_custom_target(docs ALL DEPENDS KeePassXC_GettingStarted.html KeePassXC_UserGuide.html KeePassXC_KeyboardShortcuts.html)
@ -50,13 +45,11 @@ install(FILES
# Build Man Pages on Linux and macOS # Build Man Pages on Linux and macOS
if(UNIX) if(UNIX)
add_custom_command(OUTPUT keepassxc.1 add_custom_command(OUTPUT keepassxc.1 keepassxc-cli.1
COMMAND ${ASCIIDOCTOR_EXE} -D ${OUT_DIR} -b manpage ${REV} ${DOC_DIR}/man/keepassxc.1.adoc COMMAND ${ASCIIDOCTOR_EXE} -D ${OUT_DIR} -b manpage ${REV} ./man/keepassxc.1.adoc
DEPENDS ${DOC_DIR}/man/keepassxc.1.adoc COMMAND ${ASCIIDOCTOR_EXE} -D ${OUT_DIR} -b manpage ${REV} ./man/keepassxc-cli.1.adoc
VERBATIM) DEPENDS ${DOC_DIR}/man/keepassxc.1.adoc ${DOC_DIR}/man/keepassxc-cli.1.adoc
add_custom_command(OUTPUT keepassxc-cli.1 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${ASCIIDOCTOR_EXE} -D ${OUT_DIR} -b manpage ${REV} ${DOC_DIR}/man/keepassxc-cli.1.adoc
DEPENDS ${DOC_DIR}/man/keepassxc-cli.1.adoc
VERBATIM) VERBATIM)
add_custom_target(manpages ALL DEPENDS keepassxc.1 keepassxc-cli.1) add_custom_target(manpages ALL DEPENDS keepassxc.1 keepassxc-cli.1)

View File

@ -34,6 +34,7 @@ TARGET_BRANCH="master"
TAG_NAME="" TAG_NAME=""
DOCKER_IMAGE="" DOCKER_IMAGE=""
DOCKER_CONTAINER_NAME="keepassxc-build-container" DOCKER_CONTAINER_NAME="keepassxc-build-container"
CMAKE_GENERATOR="Ninja"
CMAKE_OPTIONS="" CMAKE_OPTIONS=""
CPACK_GENERATORS="WIX;ZIP" CPACK_GENERATORS="WIX;ZIP"
COMPILER="g++" COMPILER="g++"
@ -116,7 +117,9 @@ Options:
If this option is set, --install-prefix has no effect If this option is set, --install-prefix has no effect
--appsign Perform platform specific App Signing before packaging --appsign Perform platform specific App Signing before packaging
--timestamp Explicitly set the timestamp server to use for appsign (default: '${TIMESTAMP_SERVER}') --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 -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 -c, --cmake-options Additional CMake options for compiling the sources
--compiler Compiler to use (default: '${COMPILER}') --compiler Compiler to use (default: '${COMPILER}')
-m, --make-options Make options for compiling sources (default: '${MAKE_OPTIONS}') -m, --make-options Make options for compiling sources (default: '${MAKE_OPTIONS}')
@ -783,6 +786,7 @@ build() {
local build_generators="" local build_generators=""
local build_appsign=false local build_appsign=false
local build_key="" local build_key=""
local build_vcpkg=""
while [ $# -ge 1 ]; do while [ $# -ge 1 ]; do
local arg="$1" local arg="$1"
@ -832,6 +836,10 @@ build() {
--appimage) --appimage)
build_appimage=true ;; build_appimage=true ;;
--cmake-generator)
CMAKE_GENERATOR="$2"
shift ;;
-c|--cmake-options) -c|--cmake-options)
CMAKE_OPTIONS="$2" CMAKE_OPTIONS="$2"
shift ;; shift ;;
@ -840,6 +848,10 @@ build() {
COMPILER="$2" COMPILER="$2"
shift ;; shift ;;
--vcpkg)
build_vcpkg="$2"
shift ;;
-m|--make-options) -m|--make-options)
MAKE_OPTIONS="$2" MAKE_OPTIONS="$2"
shift ;; shift ;;
@ -882,6 +894,10 @@ build() {
build_key="$(realpath "${build_key}")" build_key="$(realpath "${build_key}")"
fi 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 if ${build_snapshot}; then
TAG_NAME="HEAD" TAG_NAME="HEAD"
local branch=`git rev-parse --abbrev-ref HEAD` local branch=`git rev-parse --abbrev-ref HEAD`
@ -961,6 +977,8 @@ build() {
export CC=gcc export CC=gcc
elif [ "$COMPILER" == "clang++" ]; then elif [ "$COMPILER" == "clang++" ]; then
export CC=clang export CC=clang
else
export CC="$COMPILER"
fi fi
export CXX="$COMPILER" export CXX="$COMPILER"
@ -970,13 +988,12 @@ build() {
export MACOSX_DEPLOYMENT_TARGET export MACOSX_DEPLOYMENT_TARGET
logInfo "Configuring build..." logInfo "Configuring build..."
cmake -DCMAKE_BUILD_TYPE=Release \ cmake -G "${CMAKE_GENERATOR}" -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="$(uname -m)" \
-DCMAKE_OSX_ARCHITECTURES="$(uname -m)" -DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}" \ -DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}" ${CMAKE_OPTIONS} "$SRC_DIR"
-DCMAKE_PREFIX_PATH="/opt/homebrew/opt/qt/lib/cmake;/usr/local/opt/qt/lib/cmake" \
${CMAKE_OPTIONS} "$SRC_DIR"
logInfo "Compiling and packaging sources..." logInfo "Compiling and packaging sources..."
make ${MAKE_OPTIONS} package cmake --build . -- ${MAKE_OPTIONS}
cpack -G "DragNDrop"
# Appsign the executables if desired # Appsign the executables if desired
if ${build_appsign}; then if ${build_appsign}; then
@ -988,16 +1005,16 @@ build() {
elif [ "$(uname -o)" == "Msys" ]; then elif [ "$(uname -o)" == "Msys" ]; then
# Building on Windows with Msys2 # Building on Windows with Msys2
logInfo "Configuring build..." logInfo "Configuring build..."
cmake -DCMAKE_BUILD_TYPE=Release -G"MSYS Makefiles" \ cmake -DCMAKE_BUILD_TYPE=Release -G "${CMAKE_GENERATOR}" -DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}" \
-DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}" ${CMAKE_OPTIONS} "$SRC_DIR" ${CMAKE_OPTIONS} "$SRC_DIR"
logInfo "Compiling and packaging sources..." logInfo "Compiling and packaging sources..."
mingw32-make ${MAKE_OPTIONS} preinstall cmake --build . --config "Release" -- ${MAKE_OPTIONS}
# Appsign the executables if desired # Appsign the executables if desired
if ${build_appsign} && [ -f "${build_key}" ]; then if ${build_appsign} && [ -f "${build_key}" ]; then
logInfo "Signing executable files" 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 fi
# Call cpack directly instead of calling make package. # Call cpack directly instead of calling make package.

View File

@ -22,7 +22,7 @@ message(STATUS "Including translations...\n")
qt5_add_translation(QM_FILES ${TRANSLATION_FILES}) qt5_add_translation(QM_FILES ${TRANSLATION_FILES})
if(MINGW) if(WIN32)
file(GLOB QTBASE_TRANSLATIONS ${Qt5_PREFIX}/share/qt5/translations/qtbase_*.qm) file(GLOB QTBASE_TRANSLATIONS ${Qt5_PREFIX}/share/qt5/translations/qtbase_*.qm)
elseif(APPLE OR KEEPASSXC_DIST_APPIMAGE) elseif(APPLE OR KEEPASSXC_DIST_APPIMAGE)
file(GLOB QTBASE_TRANSLATIONS file(GLOB QTBASE_TRANSLATIONS

View File

@ -207,7 +207,7 @@ if(UNIX AND NOT APPLE)
gui/osutils/nixutils/NixUtils.cpp gui/osutils/nixutils/NixUtils.cpp
gui/osutils/nixutils/X11Funcs.cpp) gui/osutils/nixutils/X11Funcs.cpp)
endif() endif()
if(MINGW) if(WIN32)
set(keepassx_SOURCES set(keepassx_SOURCES
${keepassx_SOURCES} ${keepassx_SOURCES}
gui/osutils/winutils/ScreenLockListenerWin.cpp gui/osutils/winutils/ScreenLockListenerWin.cpp
@ -275,7 +275,7 @@ set(autotype_SOURCES
autotype/ShortcutWidget.cpp autotype/ShortcutWidget.cpp
autotype/WindowSelectComboBox.cpp) autotype/WindowSelectComboBox.cpp)
if(MINGW) if(WIN32)
set(keepassx_SOURCES_MAINEXE ${keepassx_SOURCES_MAINEXE} ${CMAKE_SOURCE_DIR}/share/windows/icon.rc) set(keepassx_SOURCES_MAINEXE ${keepassx_SOURCES_MAINEXE} ${CMAKE_SOURCE_DIR}/share/windows/icon.rc)
endif() endif()
@ -348,11 +348,11 @@ if(UNIX AND NOT APPLE)
target_link_libraries(keepassx_core Qt5::DBus Qt5::X11Extras X11) target_link_libraries(keepassx_core Qt5::DBus Qt5::X11Extras X11)
include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS}) include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS})
endif() endif()
if(MINGW) if(WIN32)
target_link_libraries(keepassx_core Wtsapi32.lib Ws2_32.lib) target_link_libraries(keepassx_core Wtsapi32.lib Ws2_32.lib)
endif() endif()
if(MINGW) if(WIN32)
include(GenerateProductVersion) include(GenerateProductVersion)
generate_product_version( generate_product_version(
WIN32_ProductVersionFiles WIN32_ProductVersionFiles
@ -407,7 +407,7 @@ install(TARGETS ${PROGNAME}
BUNDLE DESTINATION . COMPONENT Runtime BUNDLE DESTINATION . COMPONENT Runtime
RUNTIME DESTINATION ${BIN_INSTALL_DIR} COMPONENT Runtime) RUNTIME DESTINATION ${BIN_INSTALL_DIR} COMPONENT Runtime)
if(MINGW) if(WIN32)
if(${CMAKE_SIZEOF_VOID_P} EQUAL "8") if(${CMAKE_SIZEOF_VOID_P} EQUAL "8")
set(OUTPUT_FILE_POSTFIX "Win64") set(OUTPUT_FILE_POSTFIX "Win64")
else() else()
@ -462,6 +462,7 @@ if(MINGW)
set(CPACK_WIX_EXTENSIONS "WixUtilExtension.dll") set(CPACK_WIX_EXTENSIONS "WixUtilExtension.dll")
include(CPack) include(CPack)
if(NOT VCPKG_INSTALLED_DIR)
install(CODE "set(gp_tool \"objdump\")" COMPONENT Runtime) install(CODE "set(gp_tool \"objdump\")" COMPONENT Runtime)
# Deploy all 3rd party library dependencies first # Deploy all 3rd party library dependencies first
@ -480,16 +481,20 @@ if(MINGW)
install(CODE "execute_process(COMMAND ${WINDEPLOYQT_EXE} ${PROGNAME}.exe ${WINDEPLOYQT_MODE} WORKING_DIRECTORY \${CMAKE_INSTALL_PREFIX} OUTPUT_QUIET)" install(CODE "execute_process(COMMAND ${WINDEPLOYQT_EXE} ${PROGNAME}.exe ${WINDEPLOYQT_MODE} WORKING_DIRECTORY \${CMAKE_INSTALL_PREFIX} OUTPUT_QUIET)"
COMPONENT Runtime) COMPONENT Runtime)
# install CA cert chains
install(FILES ${Qt5_PREFIX}/ssl/certs/ca-bundle.crt DESTINATION "ssl/certs")
# install OpenSSL library # install OpenSSL library
if(WITH_XC_NETWORKING) if(WITH_XC_NETWORKING)
find_file(OPENSSL_DLL NAMES libssl-1_1.dll libssl-1_1-x64.dll) find_file(OPENSSL_DLL
NAMES libssl-1_1.dll libssl-1_1-x64.dll
HINTS "${OPENSSL_ROOT_DIR}/bin"
)
if (NOT OPENSSL_DLL) if (NOT OPENSSL_DLL)
message(FATAL_ERROR "Cannot find libssl dll, ensure openssl is properly installed.") message(FATAL_ERROR "Cannot find libssl dll, ensure openssl is properly installed.")
endif() endif()
find_file(CRYPTO_DLL NAMES libcrypto-1_1.dll libcrypto-1_1-x64.dll) find_file(CRYPTO_DLL
NAMES libcrypto-1_1.dll libcrypto-1_1-x64.dll
HINTS "${OPENSSL_ROOT_DIR}/bin"
)
if (NOT CRYPTO_DLL) if (NOT CRYPTO_DLL)
message(FATAL_ERROR "Cannot find libcrypto dll, ensure openssl is properly installed.") message(FATAL_ERROR "Cannot find libcrypto dll, ensure openssl is properly installed.")
endif() endif()
@ -497,3 +502,14 @@ if(MINGW)
install(FILES ${OPENSSL_DLL} ${CRYPTO_DLL} DESTINATION ".") install(FILES ${OPENSSL_DLL} ${CRYPTO_DLL} DESTINATION ".")
endif() endif()
endif() endif()
# 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()

View File

@ -20,6 +20,10 @@
#define KEEPASSX_AUTOTYPEWINDOWS_H #define KEEPASSX_AUTOTYPEWINDOWS_H
#include <QtPlugin> #include <QtPlugin>
#undef NOMINMAX
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include "autotype/AutoTypeAction.h" #include "autotype/AutoTypeAction.h"

View File

@ -24,8 +24,8 @@
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#include <fcntl.h> #include <fcntl.h>
#include <winsock2.h> #undef NOMINMAX
#define NOMINMAX
#include <windows.h> #include <windows.h>
#else #else
#include <sys/socket.h> #include <sys/socket.h>

View File

@ -47,7 +47,7 @@ find_package(Readline)
if (READLINE_FOUND) if (READLINE_FOUND)
target_compile_definitions(cli PUBLIC USE_READLINE) target_compile_definitions(cli PUBLIC USE_READLINE)
target_link_libraries(cli readline) target_link_libraries(cli ${Readline_LIBRARY})
endif() endif()
add_executable(keepassxc-cli keepassxc-cli.cpp) add_executable(keepassxc-cli keepassxc-cli.cpp)
@ -60,10 +60,10 @@ install(TARGETS keepassxc-cli
BUNDLE DESTINATION . COMPONENT Runtime BUNDLE DESTINATION . COMPONENT Runtime
RUNTIME DESTINATION ${CLI_INSTALL_DIR} COMPONENT Runtime) RUNTIME DESTINATION ${CLI_INSTALL_DIR} COMPONENT Runtime)
if(MINGW) if(WIN32)
install(CODE "include(BundleUtilities) # install(CODE "include(BundleUtilities)
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/keepassxc-cli.exe\" \"\" \"\")" # fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/keepassxc-cli.exe\" \"\" \"\")"
COMPONENT Runtime) # COMPONENT Runtime)
endif() endif()
if(APPLE AND WITH_APP_BUNDLE) if(APPLE AND WITH_APP_BUNDLE)

View File

@ -73,7 +73,7 @@ void TextStream::detectCodec()
auto env = QProcessEnvironment::systemEnvironment(); auto env = QProcessEnvironment::systemEnvironment();
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
WINBOOL success = false; bool success = false;
#ifdef CP_UTF8 #ifdef CP_UTF8
success = SetConsoleOutputCP(CP_UTF8); success = SetConsoleOutputCP(CP_UTF8);
#endif #endif

View File

@ -25,7 +25,12 @@
#include <QScopedPointer> #include <QScopedPointer>
#include <QSharedPointer> #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 class WinUtils : public OSUtilsBase, QAbstractNativeEventFilter
{ {

View File

@ -39,7 +39,7 @@ if(WITH_XC_BROWSER)
COMMENT "Deploying keepassxc-proxy") COMMENT "Deploying keepassxc-proxy")
endif() endif()
if(MINGW) if(WIN32)
target_link_libraries(keepassxc-proxy Wtsapi32.lib Ws2_32.lib) target_link_libraries(keepassxc-proxy Wtsapi32.lib Ws2_32.lib)
endif() endif()
endif() endif()

View File

@ -26,9 +26,8 @@
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#include <fcntl.h> #include <fcntl.h>
#include <io.h>
#include <winsock2.h> #include <winsock2.h>
#include <windows.h>
#else #else
#include <sys/socket.h> #include <sys/socket.h>
#endif #endif
@ -49,8 +48,13 @@ NativeMessagingProxy::NativeMessagingProxy()
void NativeMessagingProxy::setupStandardInput() void NativeMessagingProxy::setupStandardInput()
{ {
#ifdef Q_OS_WIN #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(stdin), _O_BINARY);
setmode(fileno(stdout), _O_BINARY); setmode(fileno(stdout), _O_BINARY);
#endif
#endif #endif
QtConcurrent::run([this] { QtConcurrent::run([this] {

View File

@ -17,6 +17,8 @@ set(qrcode_SOURCES
QrCode.cpp QrCode.cpp
) )
find_package(QREncode REQUIRED)
add_library(qrcode STATIC ${qrcode_SOURCES}) 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_include_directories(qrcode PRIVATE ${QRENCODE_INCLUDE_DIR})
target_link_libraries(qrcode PUBLIC Qt5::Core Qt5::Widgets Qt5::Svg ${QRENCODE_LIBRARY})

View File

@ -44,12 +44,6 @@
#endif #endif
#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 */ /* Minimum number of characters in a incrementing/decrementing sequence match */
#define MIN_SEQUENCE_LEN 3 #define MIN_SEQUENCE_LEN 3