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

@@ -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")
# 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 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(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.")
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.")
endif()
install(FILES ${OPENSSL_DLL} ${CRYPTO_DLL} DESTINATION ".")
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
#include <QtPlugin>
#undef NOMINMAX
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "autotype/AutoTypeAction.h"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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,8 +48,13 @@ 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] {

View File

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

View File

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