Add code to detect a system library for zxcvbn, with fallback to the embedded one in case it is not found

This commit is contained in:
Gianfranco Costamagna 2017-06-28 14:58:29 +02:00
parent 079e383319
commit 640b09c6b2
4 changed files with 11 additions and 7 deletions

View File

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

View File

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

View File

@ -20,7 +20,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "zxcvbn/zxcvbn.h"
#include <zxcvbn.h>
/* For pre-compiled headers under windows */
#ifdef _WIN32

View File

@ -19,7 +19,7 @@
#include "PasswordGenerator.h"
#include "crypto/Random.h"
#include "zxcvbn/zxcvbn.h"
#include <zxcvbn.h>
PasswordGenerator::PasswordGenerator()
: m_length(0)