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 /CMakeLists.txt
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
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt46
1 files changed, 30 insertions, 16 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; }"