From 640b09c6b23a5c53776b503ea4f9e066c063b515 Mon Sep 17 00:00:00 2001 From: Gianfranco Costamagna Date: Wed, 28 Jun 2017 14:58:29 +0200 Subject: [PATCH 1/2] Add code to detect a system library for zxcvbn, with fallback to the embedded one in case it is not found --- src/CMakeLists.txt | 12 ++++++++---- src/cli/CMakeLists.txt | 2 +- src/cli/EntropyMeter.cpp | 2 +- src/core/PasswordGenerator.cpp | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 791685576..05642ea8d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -27,6 +27,13 @@ if (NOT GIT_HEAD OR NOT GIT_DESCRIBE) set(GIT_DESCRIBE "") endif() +find_library(ZXCVBN_FOUND zxcvbn) +if(NOT ZXCVBN_FOUND) + add_library(zxcvbn STATIC zxcvbn/zxcvbn.cpp) + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/zxcvbn) + set(ZXCVBN_FOUND zxcvbn) +endif(NOT ZXCVBN_FOUND) + configure_file(version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/version.h @ONLY) set(keepassx_SOURCES @@ -203,9 +210,6 @@ else() list(APPEND keepassx_SOURCES keys/drivers/YubiKeyStub.cpp) endif() -add_library(zxcvbn STATIC zxcvbn/zxcvbn.cpp) -target_link_libraries(zxcvbn) - add_library(autotype STATIC ${autotype_SOURCES}) target_link_libraries(autotype Qt5::Core Qt5::Widgets) @@ -218,7 +222,7 @@ target_link_libraries(keepassx_core ${keepasshttp_LIB} ${autotype_LIB} ${YUBIKEY_LIBRARIES} - zxcvbn + ${ZXCVBN_FOUND} Qt5::Core Qt5::Network Qt5::Concurrent diff --git a/src/cli/CMakeLists.txt b/src/cli/CMakeLists.txt index 86edb9c01..4731f7be5 100644 --- a/src/cli/CMakeLists.txt +++ b/src/cli/CMakeLists.txt @@ -38,7 +38,7 @@ target_link_libraries(keepassxc-cli ${GCRYPT_LIBRARIES} ${GPGERROR_LIBRARIES} ${ZLIB_LIBRARIES} - zxcvbn) + ${ZXCVBN_FOUND}) install(TARGETS keepassxc-cli BUNDLE DESTINATION . COMPONENT Runtime diff --git a/src/cli/EntropyMeter.cpp b/src/cli/EntropyMeter.cpp index a62cd3077..5c531af5e 100644 --- a/src/cli/EntropyMeter.cpp +++ b/src/cli/EntropyMeter.cpp @@ -20,7 +20,7 @@ #include #include #include -#include "zxcvbn/zxcvbn.h" +#include /* For pre-compiled headers under windows */ #ifdef _WIN32 diff --git a/src/core/PasswordGenerator.cpp b/src/core/PasswordGenerator.cpp index cdff204a0..21aa590e0 100644 --- a/src/core/PasswordGenerator.cpp +++ b/src/core/PasswordGenerator.cpp @@ -19,7 +19,7 @@ #include "PasswordGenerator.h" #include "crypto/Random.h" -#include "zxcvbn/zxcvbn.h" +#include PasswordGenerator::PasswordGenerator() : m_length(0) From 34ff6d5f6bc02c6a691a4371c5286d56aac8e233 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 28 Jun 2017 15:18:24 +0200 Subject: [PATCH 2/2] Change from ZXCVBN_FOUND to ZXCVBN_LIBRARIES to be aligned with other libraries --- src/CMakeLists.txt | 10 +++++----- src/cli/CMakeLists.txt | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 05642ea8d..18d737d2e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -27,12 +27,12 @@ if (NOT GIT_HEAD OR NOT GIT_DESCRIBE) set(GIT_DESCRIBE "") endif() -find_library(ZXCVBN_FOUND zxcvbn) -if(NOT ZXCVBN_FOUND) +find_library(ZXCVBN_LIBRARIES zxcvbn) +if(NOT ZXCVBN_LIBRARIES) add_library(zxcvbn STATIC zxcvbn/zxcvbn.cpp) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/zxcvbn) - set(ZXCVBN_FOUND zxcvbn) -endif(NOT ZXCVBN_FOUND) + set(ZXCVBN_LIBRARIES zxcvbn) +endif(NOT ZXCVBN_LIBRARIES) configure_file(version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/version.h @ONLY) @@ -222,7 +222,7 @@ target_link_libraries(keepassx_core ${keepasshttp_LIB} ${autotype_LIB} ${YUBIKEY_LIBRARIES} - ${ZXCVBN_FOUND} + ${ZXCVBN_LIBRARIES} Qt5::Core Qt5::Network Qt5::Concurrent diff --git a/src/cli/CMakeLists.txt b/src/cli/CMakeLists.txt index 4731f7be5..0e27f2060 100644 --- a/src/cli/CMakeLists.txt +++ b/src/cli/CMakeLists.txt @@ -38,7 +38,7 @@ target_link_libraries(keepassxc-cli ${GCRYPT_LIBRARIES} ${GPGERROR_LIBRARIES} ${ZLIB_LIBRARIES} - ${ZXCVBN_FOUND}) + ${ZXCVBN_LIBRARIES}) install(TARGETS keepassxc-cli BUNDLE DESTINATION . COMPONENT Runtime